Skip to main contentSkip to footer
  • 6/23/2025
Hey coders, ever wonder why your program?s acting funky? Join me to master debugging with xxd! This vid walks you through inspecting text or binary file output at the byte level, catching sneaky characters like null bytes that mess up automation or school assignments. From assembly to redirects, learn practical tips to ensure clean output. Perfect for beginners and pros alike! Hit subscribe for more coding tutorials, and check my site for extra goodies. Let?s debug smarter, not harder!

Introduction to xxd 00:00:00
Purpose of debugging 00:00:12
Why debug output 00:00:23
Example assembly program 00:00:56
Running the program 00:01:26
Corrupting the message 00:01:45
Terminal vs automation 00:02:27
Installing xxd 00:03:16
Redirecting output 00:03:29
Using xxd to debug 00:04:33
Identifying newline issue 00:05:36
Finding zero in string 00:06:04
Debugging conclusion 00:06:32
Weird symbols warning 00:06:47
Debugging standard error 00:07:23
Closing remarks 00:07:40
Call to subscribe 00:07:56
QR code and website 00:08:45
Request for comments 00:09:09
Fade out 00:09:31

Thanks for watching!

Find us on other social media here:
- https://www.NeuralLantern.com/social

Please help support us!

- Subscribing + Sharing on Social Media
- Leaving a comment or suggestion
- Subscribing to our Blog
- Watching the main "pinned" video of this channel for offers and extras

Transcript
00:00hey there i'd like to talk to you about debugging your program's output with xxd
00:06what am i talking about well there's a program called xxd that can sort of inspect
00:16at the byte level the output of some text file or binary file it's really useful for
00:23inspecting things why would you want to debug the output of your program well i don't know
00:27maybe when you print a message from your program the program might be printing some extra characters
00:32somewhere or some garbage and maybe maybe you don't notice because you're sort of looking at
00:36your program's output in the terminal but then maybe if your output is being sent to another
00:41program uh for the purposes of automation or like you're getting a grade from a class or something
00:47like that then um well it can it can sort of it can sort of get you without you realizing what's
00:53wrong so let me just give you an example real fast of what i'm talking about i have a simple
01:00assembly program here this is not a video about how to write assembly code so just assume that
01:04you know if you want to know assembly see my other videos but um i'm just going to print a simple
01:10message i'm just going to print hello i feel awesome and then the length of the message i'm
01:15specifying here you don't know you don't need to know too much about this for this particular video
01:19i'm just printing a string in assembly that's all i'm doing um and then here you can see i'm just
01:24kind of like printing it and then i'm like exiting so if we go back to the terminal here i can type
01:28make run this is not a make file video see my other videos i want to type make run just to compile and
01:35run the program and then here's the message that it prints right hello i feel awesome it looks good in
01:41the terminal i can't be 100 sure though because think about this what if i corrupted the message on
01:47purpose this can happen in assembly all the time if you get the length wrong or if you add extra
01:53characters at the end of it or even if you have you know a corrupted register somewhere that either
01:59reads from the wrong spot to get a string or maybe it writes over the string for some reason there's a
02:05lot of things that can go wrong so for now just suppose that i've corrupted my message somehow by
02:11i don't know let's put a zero in between uh the string so i'm going to say that it's going to be
02:17like h e l zero l o and what that should do uh well it should look like just the word hello
02:25but if i'm automating this program or sending it in to get a grade at a school somewhere then
02:30this should you know not match what is expected if i'm automating with like another system in some
02:38way but it should look okay in the terminal let's see i'm going to do clear and make run
02:44notice how the message looks the same hello i feel awesome so if i was automating you know if i was
02:51sending this string to another program for automation i might be convinced that i'm not doing anything
02:56wrong and i'll i'll think it's the other side that is wrong or or computers are just buggy or something
03:01like that but actually i've outputted a corrupted message for some reason
03:04so how can i really be sure that my message is what i think i'm seeing in the terminal
03:09that's the xxd program pretty easy xxd you can install it with i think sudo apt install xxd let
03:18me see if i have it on this system oh it's already installed okay good so um i'm going to do
03:25clear and make run again so there it is uh i would like to just redirect the standard output pipe
03:31to a file with a special command in the shell let me just show you real fast
03:36i am definitely printing to std out the standard pipe which is just a number one file descriptor
03:44if you don't understand that i have other videos but um i'm going to run the program again but then
03:49i'm going to redirect the output to uh a file and i'm going to call it std out.txt it's probably a good
03:56idea to eliminate spaces i think i've made mistakes in other videos where i didn't put a space
03:59before or after this little redirector symbol and i ended up creating a file just called the
04:04number two or the number one but uh pipe number one is standard output so i'm going to say anything
04:09that comes uh to pipe one which is standard output i'm just going to redirect it to a text file
04:14so when i hit enter notice how nothing prints to the screen but
04:18the standard output text file that i specified is now created
04:23if i spill the contents of std out it still looks normal
04:27so don't let that trick you but watch what happens if i use xxd
04:32xxd std out basically xxd is going to read it as a binary file
04:37and tell me what is the value of every single character in there
04:41file io i forgot to change the title of that that's not this video but notice right here
04:48where it says h-e-l-l-o and then right before that there's like a little dot
04:54if you look at the dot let's see what is the dot it's one two three four five six it's the sixth thing
04:59one two three four five six the dot is this
05:03one two three four five six seven eight nine ten twelve thirteen fourteen fifteen
05:13oh there's fifteen characters but there's not that many i think probably they're packing them by two
05:17here let me see if that makes more sense now one two three four five six one two three four five six
05:24yeah that makes a lot more sense so the sixth uh byte not the sixth uh word uh is basically
05:33oa and that maps to this dot right here and if you recall oa is a decimal 10 which is uh the
05:43beginning of a new line you know like a carriage return line feed um 13 comma 10 so that's what it
05:49is right there and then so now we know that there's xxd is figuring out here or helping us understand
05:56that there's a new line between slash main and then the message which if you recall that's exactly
06:00what happened and then when we look into our hello string there's a dot in the middle here
06:07what is that dot well we just have to figure out what number that corresponds to so
06:11the oa was that dot right there so we just got to go a couple more bytes forward one two three four
06:18bytes forward one two three four bytes forward it's this zero right here
06:26so xxd even though the terminal didn't help us originally xxd has helped us realize that we're
06:32actually printing a zero under the hood and we can't see it in the terminal so we have now debugged
06:39our output you know depending on where you print this you might see nothing like in the terminal it
06:45didn't really show anything but if you're on a web page somewhere or some other type of thing that's
06:50going to print the data for you you might see a weird symbol i mean it really depends this is not
06:54something you'll see everywhere but you might see a weird symbol that kind of looks like a black diamond
06:59with a question mark inside of it or some other weird symbol if you start seeing weird symbols all
07:03over the place or just in a place where you know there's not supposed to be a weird symbol that might
07:09be an indication to you that you have weird uh values sitting inside of your string and then you
07:14should probably try to debug with xxd so that's it that's the basics for debugging with xxd just you
07:20know file output anyway for your information if you wanted to debug the uh standard error pipe you could
07:27also do this you know because the error pipe is just a two um and that's basically it i'm not going to
07:36debug right now because it's that's too easy but i hope you enjoyed this video thank you for watching
07:41i hope you learned a little bit and had a little bit of fun i'll see you in the next video
07:48hey everybody thanks for watching this video again from the bottom of my heart i really appreciate it
07:53i do hope you did learn something and have some fun if you could do me a please a small little favor
07:58could you please subscribe and follow this channel or these videos or whatever it is you do on the current
08:05social media website that you're looking at right now it would really mean the world to me and it'll
08:09help make more videos and grow this community so we'll be able to do more videos longer videos better
08:14videos or just i'll be able to keep making videos in general so please do do me a kindness and uh and
08:22subscribe you know sometimes i'm sleeping in the middle of the night and i just wake up because i know
08:26somebody subscribed or followed it just wakes me up and i get filled with joy that's exactly what happens
08:31every single time so you could do it as a nice favor to me or you could you could troll me if you
08:35want to just wake me up in the middle of the night just subscribe and then i'll i'll just wake up i
08:39promise that's what will happen also uh if you look at the middle of the screen right now you should see
08:45a qr code which you can scan in order to go to the website which i think is also named somewhere at the
08:49bottom of this video and it'll take you to my main website where you can just kind of like see
08:54all the videos i published and the services and tutorials and things that i offer and all that good stuff and
09:00uh if you have a suggestion for uh uh clarifications or errata or just future videos that you want to
09:09see please leave a comment or if you just want to say hey what's up what's going on you know just send
09:14me a comment whatever i also wake up for those in the middle of the night i get i wake up in a cold
09:18sweat and i'm like it would really it really mean the world to me i would really appreciate it so
09:23again thank you so much for watching this video and um enjoy the cool music as as i fade into the
09:32darkness which is coming for us all
09:42so
10:02so
10:12so
10:14so
10:27so
10:39so
10:52so
10:54so
11:07so
11:09so
11:23so
11:25so
11:40so
11:42so
11:57so
11:59so
12:15so
12:17so
12:34you
12:36so

Recommended