{"id":281,"date":"2009-04-25T01:36:39","date_gmt":"2009-04-25T06:36:39","guid":{"rendered":"http:\/\/www.visophyte.org\/blog\/?p=281"},"modified":"2009-04-25T01:36:39","modified_gmt":"2009-04-25T06:36:39","slug":"gaudily-syntax-highlighted-code-listings-in-archer-gdb","status":"publish","type":"post","link":"https:\/\/www.visophyte.org\/blog\/2009\/04\/25\/gaudily-syntax-highlighted-code-listings-in-archer-gdb\/","title":{"rendered":"gaudily syntax-highlighted code listings in (archer) gdb"},"content":{"rendered":"<p><a href=\"http:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/04\/pyglist.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-282\" title=\"pyglist sl command output\" src=\"http:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/04\/pyglist.png\" alt=\"pyglist sl command output\" width=\"926\" height=\"498\" srcset=\"https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/04\/pyglist.png 926w, https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/04\/pyglist-600x322.png 600w, https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/04\/pyglist-300x161.png 300w\" sizes=\"auto, (max-width: 926px) 100vw, 926px\" \/><\/a><\/p>\n<p>Gaudily syntax-highlighted code listing in gdb joins the gaudy gdb plugin family!\u00a0 (Other members include <a href=\"http:\/\/www.visophyte.org\/blog\/2009\/03\/04\/gaudily-colorized-gdb-backtraces-woo\/\">gaudily colorized backtraces<\/a>, which you can also see in the bottom of the screenshot.)\u00a0 This, of course, requires <a href=\"http:\/\/sourceware.org\/gdb\/wiki\/PythonGdb\">gdb with python crammed inside<\/a>.\u00a0 It might require one crammed a few months ago too; I haven&#8217;t updated my archer-gdb repo for at least that long.<\/p>\n<p>The &#8220;sl&#8221; plugin uses <a href=\"http:\/\/pygments.org\/\">Pygments<\/a> for the syntax highlighting.\u00a0 Although pygments has a 256 color terminal formatter (woo!), I ended up using my pyflam module because it did not support my need to color the background of the current line without doing something convoluted.\u00a0 (I would have had to create a filter that did its own line-counting and created background-color-styled token variant of every token on the desired line.)\u00a0 Also, it didn&#8217;t do line numbers.<\/p>\n<p>The color theme is based off the &#8220;fruity&#8221; color theme.\u00a0 Much of the gaudy comes from a filter I added that tries to do various Mozilla C++-aware code styling things by recognizing naming patterns of Name tokens.\u00a0 Before you complain about the colors hurting your brain, remember that this is the alternative:<\/p>\n<p><a href=\"http:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/04\/not-pyglist.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-285\" title=\"not-pyglist, standard list command\" src=\"http:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/04\/not-pyglist.png\" alt=\"not-pyglist, standard list command\" width=\"770\" height=\"206\" srcset=\"https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/04\/not-pyglist.png 770w, https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/04\/not-pyglist-600x160.png 600w, https:\/\/www.visophyte.org\/blog\/wp-content\/uploads\/2009\/04\/not-pyglist-300x80.png 300w\" sizes=\"auto, (max-width: 770px) 100vw, 770px\" \/><\/a><\/p>\n<p>That&#8217;s right.\u00a0 It&#8217;s like looking at static.\u00a0 You can barely make anything out.\u00a0 And imagine if it was more than just the 10 lines &#8220;list&#8221; gives you.<\/p>\n<p>Anywho, the repo is here: <a href=\"http:\/\/hg.mozilla.org\/users\/bugmail_asutherland.org\/pythongdb-gaudy\/\">http:\/\/hg.mozilla.org\/users\/bugmail_asutherland.org\/pythongdb-gaudy\/<\/a><\/p>\n<p>The README tells you what to do.\u00a0 For complete-ness, and because I went to all the effort to write documentation for the command, here is what it does!<\/p>\n<pre>Prints a syntax-highlighted source listing.  Currently limited to only\r\nwork based on the current debug frame and position.\r\n\r\nBy default, the 11 lines before the current position and 8 lines after are\r\ndisplayed.  A line context is saved between command invocations if the current\r\nsource line does not change.\r\n\r\nArguments when used in a new context:\r\n  (none)  Shows the 11 lines before the current position and 8 lines after.\r\n  N       Shows the N\/2 lines befores the current position and N\/2 lines after.\r\n  -N      Shows the N lines before the current position and 8 lines after.\r\n  +N      Shows the 11 lines before the current position and N lines after.\r\n  M N     Shows the M lines before the current position and N lines after.\r\n\r\nArguments in an existing context:\r\n  (none)  Shows the 20 lines after the last-shown lines.\r\n  -       Shows the 20 lines preceding the last-shown lines.\r\n  N       Shows the N lines after the last-shown lines.\r\n  -N      Shows the N lines preceding the last-shown lines.\r\n  M N     Shows the M last lines of the last-shown lines and N lines after the\r\n            last-shown lines.\r\n\r\nArguments regardless of context\r\n  @A,B    Shows lines A through B.<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Gaudily syntax-highlighted code listing in gdb joins the gaudy gdb plugin family!\u00a0 (Other members include gaudily colorized backtraces, which you can also see in the bottom of the screenshot.)\u00a0 This, of course, requires gdb with python crammed inside.\u00a0 It might &hellip; <a href=\"https:\/\/www.visophyte.org\/blog\/2009\/04\/25\/gaudily-syntax-highlighted-code-listings-in-archer-gdb\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[7],"tags":[27,58,31,57,128],"class_list":["post-281","post","type-post","status-publish","format-standard","hentry","category-debugging","tag-colors","tag-gaudy","tag-gdb","tag-pyflam","tag-shiny"],"_links":{"self":[{"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/posts\/281","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/comments?post=281"}],"version-history":[{"count":7,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/posts\/281\/revisions"}],"predecessor-version":[{"id":290,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/posts\/281\/revisions\/290"}],"wp:attachment":[{"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/media?parent=281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/categories?post=281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.visophyte.org\/blog\/wp-json\/wp\/v2\/tags?post=281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}