<story><title>Writing a debugger from scratch: Breakpoints</title><url>https://www.timdbg.com/posts/writing-a-debugger-from-scratch-part-5/</url></story><parent_chain></parent_chain><comment><author>whartung</author><text>I’ll share this anecdote told by a friend of mine.&lt;p&gt;He was on a team building a Modula-2 compiler for OS&amp;#x2F;2, and his group was working on the debugger.&lt;p&gt;At some point a debugger becomes feature complete enough that you can use the debugger to ... debug the debugger.&lt;p&gt;But this was OS&amp;#x2F;2 which has true multiple processes (unlike it’s contemporary Windows 3.1). So you could, naturally, run the debugger in one process and attached it to another process which, just so happens to be another instance of the debugger.&lt;p&gt;As with all things, while doing this they encountered bugs in the debugger that, well, needed to be debugged.&lt;p&gt;He said there was a certain epiphany when they realized, because of the multi process nature of OS&amp;#x2F;2, that they could debug the debugger debugging the debugger.&lt;p&gt;I would imagine this took a bit of focus. Turn away for a moment and probably really messes with your head.</text></comment>
<story><title>Writing a debugger from scratch: Breakpoints</title><url>https://www.timdbg.com/posts/writing-a-debugger-from-scratch-part-5/</url></story><parent_chain></parent_chain><comment><author>ekidd</author><text>This is a great series!&lt;p&gt;I noticed that the author was using &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;hydro-project&amp;#x2F;rust-sitter&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;hydro-project&amp;#x2F;rust-sitter&lt;/a&gt; as a parser. Which is based on &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;tree-sitter.github.io&amp;#x2F;tree-sitter&amp;#x2F;&quot; rel=&quot;nofollow noreferrer&quot;&gt;https:&amp;#x2F;&amp;#x2F;tree-sitter.github.io&amp;#x2F;tree-sitter&amp;#x2F;&lt;/a&gt;. I&amp;#x27;ve been hearing about Tree-sitter a lot recently, so I dug into it.&lt;p&gt;Tree-sitter is a tool for generating fast, incremental parsers. In particular, the algorithm is suited towards writing &amp;quot;language servers&amp;quot; for IDEs, which re-parse code incrementally as the user works. These kinds of incremental parsers have historically been a huge problem. It looks like Tree-sitter is an enormous practical advance in this area.&lt;p&gt;And discovering that there&amp;#x27;s a way to use Tree-sitter from Rust is &lt;i&gt;fantastic&lt;/i&gt;. From the post:&lt;p&gt;&lt;pre&gt;&lt;code&gt;    #[rust_sitter::language]
    pub enum EvalExpr {
        Number(
            #[rust_sitter::leaf(
                pattern = r&amp;quot;(\d+|0x[0-9a-fA-F]+)&amp;quot;,
                transform = parse_int
            )]
            u64
        ),
        Symbol(
            #[rust_sitter::leaf(
                pattern = r&amp;quot;(([a-zA-Z0-9_@#.]+!)?[a-zA-Z0-9_@#.]+)&amp;quot;,
                transform = parse_sym
            )]
            String
        ),
        &amp;#x2F;&amp;#x2F; ...
&lt;/code&gt;&lt;/pre&gt;
Getting easy access to fast, incremental parsing is a huge win. And Tree-Sitter has support for being used from a huge list of languages, not just Rust.</text></comment>