<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Debug on Institute of Ineptitude</title><link>https://ineptitude.ca/tags/debug/</link><description>Recent content in Debug on Institute of Ineptitude</description><generator>Hugo -- 0.153.1</generator><language>en</language><lastBuildDate>Sat, 06 Dec 2025 21:41:18 -0700</lastBuildDate><atom:link href="https://ineptitude.ca/tags/debug/index.xml" rel="self" type="application/rss+xml"/><item><title>Condition Evaluation Utility</title><link>https://ineptitude.ca/writing/condition-evaluation-utility/</link><pubDate>Sat, 06 Dec 2025 21:41:18 -0700</pubDate><guid>https://ineptitude.ca/writing/condition-evaluation-utility/</guid><description>&lt;p&gt;After you run a command in UNIX shell (bourne, bash, etc), &lt;code&gt;$?&lt;/code&gt; has
the exit code (return value) of the prior run command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh-session" data-lang="sh-session"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt; $? Expands to the exit status of the most recent pipeline.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Shell scripting is a bit &lt;em&gt;weird&lt;/em&gt; in that the return value of a program
is evaluated as &lt;code&gt;true&lt;/code&gt; if it&amp;rsquo;s &lt;code&gt;0&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt; if it&amp;rsquo;s &lt;code&gt;non-zero.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This is useful as by convention unix commands return &lt;code&gt;0&lt;/code&gt; on success
or any other integer code to map to specific error conditions.&lt;/p&gt;</description></item><item><title>Assemble an MS-DOS .COM binary with DEBUG.EXE</title><link>https://ineptitude.ca/writing/assemble-dos-com/</link><pubDate>Tue, 11 Nov 2025 14:57:43 -0700</pubDate><guid>https://ineptitude.ca/writing/assemble-dos-com/</guid><description>&lt;p&gt;&lt;a href="https://www.youtube.com/The8BitGuy"&gt;The 8-Bit Guy&lt;/a&gt; has a video
where he &lt;a href="https://www.youtube.com/watch?v=HWpi9n2H3kE"&gt;demonstrates the assembler built right into the monitor
ROM on a C64&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This fascinated me and made me wonder&amp;hellip; If I was stuck on an old MS-DOS machine and wanted to assemble a binary&amp;hellip; Could I do it? Byte by byte? With what tool? Those of us stuck with &amp;ldquo;IBM compatible&amp;rdquo; PCs didn&amp;rsquo;t have no fancy monitor ROMs.&lt;/p&gt;
&lt;p&gt;Turns out MS-DOS&amp;rsquo; &lt;code&gt;DEBUG.EXE&lt;/code&gt; is and was entirely up for the job.&lt;/p&gt;</description></item><item><title>ASCII case bit twiddling</title><link>https://ineptitude.ca/writing/ascii-case-bit-twiddling/</link><pubDate>Tue, 10 Dec 2024 21:49:28 -0700</pubDate><guid>https://ineptitude.ca/writing/ascii-case-bit-twiddling/</guid><description>&lt;p&gt;If you pay a special sort of attention, you may notice that the
upper-case and lower-case alphabet characters on the ASCII table
are always exactly offset from each other by 32.&lt;/p&gt;
&lt;p&gt;For example, upper-case &lt;code&gt;A&lt;/code&gt; is &lt;code&gt;65&lt;/code&gt;, while the lowercase &lt;code&gt;a&lt;/code&gt; is &lt;code&gt;97&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;As such the way the binary place value works out, you can manipulate
the case of a character by setting or clearing the sixth bit&amp;hellip;
(2^5 = 32, we start counting bits and everything at 0, we&amp;rsquo;re
programmers!)&lt;/p&gt;
&lt;p&gt;Decimal &lt;code&gt;32&lt;/code&gt; expressed as hexadecimal is &lt;code&gt;0x20&lt;/code&gt; and expressed as
binary is &lt;code&gt;00100000&lt;/code&gt;&lt;/p&gt;</description></item><item><title>Environment variables</title><link>https://ineptitude.ca/writing/env-vars/</link><pubDate>Wed, 27 Nov 2024 23:29:21 -0700</pubDate><guid>https://ineptitude.ca/writing/env-vars/</guid><description>&lt;p&gt;I had the sudden realization that I didn’t &lt;em&gt;really&lt;/em&gt; know how environment
variables work. I think We &lt;em&gt;all&lt;/em&gt; take them for granted, regardless of OS&amp;hellip;&lt;/p&gt;
&lt;p&gt;Some high level details about some such variables and their purpose
can be found in the &lt;a href="https://docs.freebsd.org/en/books/handbook/book/"&gt;FreeBSD
Handbook&lt;/a&gt; section
&lt;a href="https://docs.freebsd.org/en/books/handbook/book/#shells"&gt;3.9. Shells&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;You can view such variables in your shell using the
&lt;a href="https://man.freebsd.org/cgi/man.cgi?env"&gt;env&lt;/a&gt; command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh-session" data-lang="sh-session"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;root@freebsd:~ # env
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;PAGER=less
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;LANG=C.UTF-8
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;MAIL=/var/mail/root
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;ENV=/root/.shrc
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;OLDPWD=/
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;PWD=/root
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;TERM=xterm-256color
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;USER=root
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;HOME=/root
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;SHELL=/bin/sh
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;MM_CHARSET=UTF-8
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;BLOCKSIZE=K
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="go"&gt;root@freebsd:~ #
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&amp;hellip;but what are all the low level specifics that nobody bothers to ask?&lt;/p&gt;</description></item><item><title>Initialize your variables</title><link>https://ineptitude.ca/writing/init-your-vars/</link><pubDate>Sat, 17 Aug 2024 15:51:13 -0700</pubDate><guid>https://ineptitude.ca/writing/init-your-vars/</guid><description>&lt;p&gt;There&amp;rsquo;s no shortage of material that explains variables in C should
be initialized&amp;hellip; but I&amp;rsquo;ve often found the explanation of &lt;em&gt;why&lt;/em&gt; to
be somewhat lacking.&lt;/p&gt;
&lt;p&gt;Where do the initial values of a variable come from if you don&amp;rsquo;t
explicitly initialize?&lt;/p&gt;</description></item><item><title>Guess the number...</title><link>https://ineptitude.ca/writing/guess-the-number/</link><pubDate>Fri, 05 Apr 2024 00:00:00 +0000</pubDate><guid>https://ineptitude.ca/writing/guess-the-number/</guid><description>&lt;p&gt;A quick demonstration of how one can use a debugger to interactively inspect variables in a running program&amp;hellip;&lt;/p&gt;</description></item><item><title>Patching Binaries</title><link>https://ineptitude.ca/writing/patching-binaries/</link><pubDate>Sat, 13 Mar 2021 11:19:00 -0600</pubDate><guid>https://ineptitude.ca/writing/patching-binaries/</guid><description>&lt;h2 id="exercise-summary"&gt;Exercise Summary&lt;/h2&gt;
&lt;p&gt;The idea of this self-inflicted exercise was to see if I could
inspect and patch a binary to change the outcome of some conditional
code. In days of long past up I had found tutorials on how to patch
a binary to bypass copyright protection schemes. The type that would
ask a random question, where the answer found in a manual.&lt;/p&gt;
&lt;p&gt;You know, the one you would have had if the game wasn&amp;rsquo;t recieved
on bootleg floppy diskettes.&lt;/p&gt;</description></item></channel></rss>