[{"data":1,"prerenderedAt":729},["ShallowReactive",2],{"tags-pages-list-code":3},[4,670,688,705],{"id":5,"title":6,"body":7,"createdAt":658,"description":13,"draft":659,"extension":660,"image":661,"mastodonThread":661,"meta":662,"navigation":663,"path":664,"seo":665,"stem":666,"tags":667,"updatedAt":668,"__hash__":669},"content\u002FDebugging Techniques.md","Debugging_Techniques",{"type":8,"value":9,"toc":654},"minimark",[10,14],[11,12,13],"p",{},"A brain-dump of various approaches to debugging (code) things that I like.",[15,16,17,29,55,63,74,126,153,203,303,337,353,386,414,455,513,550,573,590,634],"ul",{},[18,19,20,21],"li",{},"Development is mostly debugging\n",[15,22,23,26],{},[18,24,25],{},"You could even say that it is ALL debugging",[18,27,28],{},"Implementing a feature is fixing the lack of that feature",[18,30,31,32],{},"Types of bugs\n",[15,33,34,37,40,43,46,49,52],{},[18,35,36],{},"Syntax",[18,38,39],{},"500 server error",[18,41,42],{},"Unexpected output",[18,44,45],{},"Legit issue that is not communicated to the user well",[18,47,48],{},"Configuration issue -- routes, library setup",[18,50,51],{},"Security issue",[18,53,54],{},"Generally undesired behavior",[18,56,57,58],{},"Read the documentation\n",[15,59,60],{},[18,61,62],{},"\"Use The Source, Luke\" -- Wise Sage",[18,64,65,66],{},"Dead Debugging vs Live Debugging\n",[15,67,68,71],{},[18,69,70],{},"Dead Debugging -- you can't (easily) run the code or modified versions",[18,72,73],{},"Live Debugging -- make a change, see result, breakpoints, everything",[18,75,76,77],{},"What's even happening\n",[15,78,79,101,118],{},[18,80,81,82],{},"Build your feedback loop\n",[15,83,84,87],{},[18,85,86],{},"Write log entries to SEE what is happening instead of guessing",[18,88,89,90],{},"Build shortcut to getting to the critical point\n",[15,91,92,95,98],{},[18,93,94],{},"This is a great spot for leveraging unit\u002Ffeature specs",[18,96,97],{},"Have a fast way to re-start -- like a save point in a game",[18,99,100],{},"Re-send XHR in browser, or open in new tab! Copy Curl command!",[18,102,103,104],{},"Get some visibility\n",[15,105,106,109,112,115],{},[18,107,108],{},"You can't debug what you can't observe or infer",[18,110,111],{},"Observing is easier than inferring",[18,113,114],{},"Log-based debugging (print \"here\")",[18,116,117],{},"Debugger-based debugging (binding.pry)",[18,119,120,121],{},"Why is it this way anyway?\n",[15,122,123],{},[18,124,125],{},"Revision control ... did someone do this on purpose?",[18,127,128,129],{},"State -- Best friend. Worst enemy.\n",[15,130,131,134,137,145],{},[18,132,133],{},"Think about inputs, outputs, and state",[18,135,136],{},"Local variables, parameters, scoped variables, global variables",[18,138,139,140],{},"Look at the actual database \u002F storage\n",[15,141,142],{},[18,143,144],{},"The state that exists even when your program isn't running",[18,146,147,148],{},"State CHANGES over TIME\n",[15,149,150],{},[18,151,152],{},"This is why multi-process debugging is so hard... competing timelines",[18,154,155,156],{},"Model the world. Beware of assumptions!\n",[15,157,158,189],{},[18,159,160,161],{},"Don't assume!\n",[15,162,163,166,169,172,175],{},[18,164,165],{},"LOOK at the contents of variables",[18,167,168],{},"RUN methods and see what they return",[18,170,171],{},"LOOK at the code you're calling and what calls you",[18,173,174],{},"VERIFY that it's even running this code at all",[18,176,177,178],{},"LOOK at the revision history to get some time-context\n",[15,179,180,183,186],{},[18,181,182],{},"Did this change recently?",[18,184,185],{},"Was this put here on purpose?",[18,187,188],{},"Look at the annotation, the commits, the commit-messages, the linked tickets",[18,190,191,192],{},"Verify assumptions\n",[15,193,194,197,200],{},[18,195,196],{},"Add an \"X\" and see if it shows up on the page where you expect",[18,198,199],{},"Add a syntax error and make sure it breaks. Delete everything and make sure it breaks.",[18,201,202],{},"Hard-wire weird values in place of method calls",[18,204,205,206],{},"Narrow the problem\n",[15,207,208,225,264,278,292,295],{},[18,209,210,211],{},"Simplify reproduction steps\n",[15,212,213,216,219,222],{},[18,214,215],{},"Try to figure out what you care about and what you don't",[18,217,218],{},"See if you can reproduce the issue without some of the nuance",[18,220,221],{},"Remove the weird bits one at a time",[18,223,224],{},"The less steps it takes to cause the problem, the less you have to think about",[18,226,227,228],{},"Figure out where this code even lives\n",[15,229,230,252,255,258,261],{},[18,231,232,236,237],{},[233,234,235],"code",{},"grep","!\n",[15,238,239,249],{},[18,240,241,244,245,248],{},[233,242,243],{},"ack",", ripgrep (",[233,246,247],{},"rg","), atom\u002Fvscode search, ...",[18,250,251],{},"See some text",[18,253,254],{},"Trace from entrypoints",[18,256,257],{},"Trace backwards from the error if you have one",[18,259,260],{},"Read the stacktrace!",[18,262,263],{},"Copy some random text from the screen and grep for that",[18,265,266,267],{},"Bracket the issue\n",[15,268,269,272,275],{},[18,270,271],{},"Hard-wire values",[18,273,274],{},"Interactive Unit Testing",[18,276,277],{},"Log state at various points of execution",[18,279,280,281],{},"Read the error message\n",[15,282,283,286,289],{},[18,284,285],{},"Sometimes ... often ... it will actually TELL you what is wrong",[18,287,288],{},"Even when it is vague or lying it is a good starting point to trace backwards from",[18,290,291],{},"Often it comes with a stack trace -- read the stack trace!",[18,293,294],{},"Read the log entries just before the error message",[18,296,297,298],{},"Trace forward and backward from the error\n",[15,299,300],{},[18,301,302],{},"Learning who calls what in any language is necessary knowledge",[18,304,305,306],{},"Execution Environment\n",[15,307,308,316],{},[18,309,310,311],{},"Use a completely different dataset \u002F environment to reproduce\n",[15,312,313],{},[18,314,315],{},"Go beyond \"Works on my machine!\"",[18,317,318,319],{},"Eliminate your environment as the unintended cause of the issue\n",[15,320,321,331,334],{},[18,322,323,324,327,328],{},"Speaking of environments, use ",[233,325,326],{},"asdf"," or similar and don't install using ",[233,329,330],{},"sudo",[18,332,333],{},"Try a different browser, or incognito, or different OS",[18,335,336],{},"Ask a friend!",[18,338,339,340],{},"Structured thinking\n",[15,341,342],{},[18,343,344,345],{},"Try to think about less things\n",[15,346,347,350],{},[18,348,349],{},"Chunk concepts into short-term memory",[18,351,352],{},"Take notes",[18,354,355,356],{},"Modify the world\n",[15,357,358,361,372,383],{},[18,359,360],{},"Don't suffer in the current world, switch to the one you wish you had",[18,362,363,364],{},"Build tiny scenarios\n",[15,365,366,369],{},[18,367,368],{},"Create toy worlds to play in",[18,370,371],{},"H1 tags should be clickable ... make a new component with an H1 tag and an onclick and ... click it",[18,373,374,375],{},"Edit your dependencies!\n",[15,376,377,380],{},[18,378,379],{},"bundle open",[18,381,382],{},"pry your way in",[18,384,385],{},"It's more obvious what a variable contains when it is hard-wired",[18,387,388,389],{},"Actual bug hunting in a living application\n",[15,390,391],{},[18,392,393,394],{},"Did this work before?\n",[15,395,396,399,402,405,408,411],{},[18,397,398],{},"What changed?",[18,400,401],{},"Assumptions about the data",[18,403,404],{},"Assumptions about the external world",[18,406,407],{},"Why did it change?",[18,409,410],{},"Why did this ever work?",[18,412,413],{},"Do we have tests around this? What do they assume?",[18,415,416,417],{},"Why does this work sometimes and not others?\n",[15,418,419,422,425,428,444],{},[18,420,421],{},"SOMETHING about the state is changing",[18,423,424],{},"The ordering in the sequence of events",[18,426,427],{},"The datatypes",[18,429,430,431],{},"External state is changing (and depended on)\n",[15,432,433,441],{},[18,434,435,436],{},"Time! My favorite. (TimeCop)\n",[15,437,438],{},[18,439,440],{},"Especially time zones, DST, and holidays",[18,442,443],{},"Other systems",[18,445,446,447],{},"The world is deterministic but chaotic\n",[15,448,449,452],{},[18,450,451],{},"Unless you are dealing with quantum physics",[18,453,454],{},"You are not dealing with quantum physics",[18,456,457,458],{},"When you are stuck\n",[15,459,460,474,510],{},[18,461,462,463],{},"Model the problem in detail\n",[15,464,465,468,471],{},[18,466,467],{},"Draw pictures of the data-flow",[18,469,470],{},"Draw pictures of the data-structures",[18,472,473],{},"Sequence diagrams are good for complex interactions, especially timing issues",[18,475,476,477],{},"Science!\n",[15,478,479,492,495,498,501,504,507],{},[18,480,481,482],{},"\"Remember kids, the only difference between screwing around and science is writing it down\" -- Adam Savage\n",[15,483,484],{},[18,485,486],{},[487,488,489],"a",{"href":489,"rel":490},"https:\u002F\u002Fwww.reddit.com\u002Fr\u002Fmythbusters\u002Fcomments\u002F3wgqgv\u002Fthe_origin_of_the_remember_kids_the_only\u002F",[491],"nofollow",[18,493,494],{},"The tool of last resort?",[18,496,497],{},"When things can't fit in our tiny brains",[18,499,500],{},"Write it as a test",[18,502,503],{},"Write it on paper",[18,505,506],{},"Write it on a whiteboard",[18,508,509],{},"Write it in code (aka Test Driven Debugging)",[18,511,512],{},"Ask for help!",[18,514,515,516],{},"The problem is not in the language\n",[15,517,518,521,524,527,530],{},[18,519,520],{},"You did not find an implementation error in Ruby (unless you are reading C code)",[18,522,523],{},"You did not find an implementation error in Linux (unless you are reading C code)",[18,525,526],{},"It is almost definitely not the framework",[18,528,529],{},"It is probably not the library",[18,531,532,533],{},"Prioritize your suspect list based on probability\n",[15,534,535,538,541,544,547],{},[18,536,537],{},"How many people use layer X without issue?",[18,539,540],{},"Linux -- LOTS",[18,542,543],{},"Ruby -- Lots",[18,545,546],{},"Rails -- Lots",[18,548,549],{},"app\u002Fmodels\u002Fmy_biz_logic.rb? Not so many",[18,551,552,553],{},"How to practice\n",[15,554,555,558,561,564,567,570],{},[18,556,557],{},"Pick something on the screen and find the code that makes it",[18,559,560],{},"Modify the code to see that you can affect change",[18,562,563],{},"Trace the code to see how it goes from Browser -> code -> Browser",[18,565,566],{},"Write failing tests that would have caught the issue",[18,568,569],{},"Try out different tools -- debuggers, REPLS, editors, git things",[18,571,572],{},"Read (trace!) code of your app, your dependencies, other applications",[18,574,575,576],{},"Write More Tests\n",[15,577,578,581,584,587],{},[18,579,580],{},"Unit tests are like robot-you that are validating assumptions all the time",[18,582,583],{},"Unit tests are a shortcut to get into situations quickly",[18,585,586],{},"Tests can contain bugs!",[18,588,589],{},"Feature (browser tests) verify that things fit together",[18,591,592,593],{},"Key tools\n",[15,594,595,602,605,617,620,625],{},[18,596,597,599,600],{},[233,598,235],{},"\u002F",[233,601,247],{},[18,603,604],{},"Your editor",[18,606,607,608,611,612],{},"Pry\u002Firb\u002Fbyebug, js ",[233,609,610],{},"debugger","+firefox\u002Fchrome\n",[15,613,614],{},[18,615,616],{},"pry-byebug",[18,618,619],{},"rspec\u002Fcapybara",[18,621,622],{},[233,623,624],{},"diff -u",[18,626,627,630,631],{},[233,628,629],{},"bundle open \u003Clib>"," \u002F ",[233,632,633],{},"gem open \u003Clib>",[18,635,636,637],{},"Crazy power tools\n",[15,638,639,642,645,648,651],{},[18,640,641],{},"git bisect",[18,643,644],{},"rspec bisect",[18,646,647],{},"ruby -rtracer hiya.rb",[18,649,650],{},"strace \u002F dtrace",[18,652,653],{},"wireshark\u002FProxy? xxd? decompiler?",{"title":655,"searchDepth":656,"depth":656,"links":657},"",2,[],"2020-05-20T14:53-04:00",false,"md",null,{},true,"\u002Fdebugging-techniques",{"title":6,"description":13},"Debugging Techniques",[233],"2020-05-21T10:08-04:00","CBUinuKlkszChf8qcOg2R1vUVYIvjliOizWJWr_QhKA",{"id":671,"title":672,"body":673,"createdAt":680,"description":677,"draft":659,"extension":660,"image":661,"mastodonThread":661,"meta":681,"navigation":663,"path":682,"seo":683,"stem":684,"tags":685,"updatedAt":680,"__hash__":687},"content\u002FProject Abstract - GOE.md","Project_Abstract_-_GOE",{"type":8,"value":674,"toc":678},[675],[11,676,677],{},"In Goe Object Environment I'm trying to create a smalltalk-like environment in Perl. This is possible through use of GTK bindings for a environment browser and Perl's own reflexive nature. This project has a lot of potential but I only touch it every other year or so.",{"title":655,"searchDepth":656,"depth":656,"links":679},[],"2003-08-31T19:39-04:00",{},"\u002Fproject-abstract-goe",{"title":672,"description":677},"Project Abstract - GOE",[686,233],"project","Td6QVtyHYoW-YiBOey78MO0NBlOjfLaEGgJaABgieY4",{"id":689,"title":690,"body":691,"createdAt":697,"description":677,"draft":659,"extension":660,"image":661,"mastodonThread":661,"meta":698,"navigation":663,"path":699,"seo":700,"stem":701,"tags":702,"updatedAt":703,"__hash__":704},"content\u002FProject - GOE.md","Project_-_GOE",{"type":8,"value":692,"toc":695},[693],[11,694,677],{},{"title":655,"searchDepth":656,"depth":656,"links":696},[],"2003-08-31T19:24-04:00",{},"\u002Fproject-goe",{"title":690,"description":677},"Project - GOE",[686,233],"2003-08-31T19:40-04:00","X-Gda_aDPPC28deyk_zaLxhcBeM-noWeVZbNBD3lCKs",{"id":706,"title":707,"body":708,"createdAt":720,"description":721,"draft":659,"extension":660,"image":661,"mastodonThread":661,"meta":722,"navigation":663,"path":723,"seo":724,"stem":725,"tags":726,"updatedAt":727,"__hash__":728},"content\u002FProject - GOE (abstract).md","Project_-_GOE_(abstract)",{"type":8,"value":709,"toc":718},[710,715],[11,711,712,713],{},"GOE - Goe Object Environment, see ",[487,714,701],{"href":699},[11,716,717],{},"This is a perl project relying heavily on Perl's reflexive nature. The idea is to build a smalltalk-like environment for Perl.",{"title":655,"searchDepth":656,"depth":656,"links":719},[],"2003-08-31T19:15-04:00","GOE - Goe Object Environment, see Project - GOE",{},"\u002Fproject-goe-(abstract)",{"title":707,"description":721},"Project - GOE (abstract)",[686,233],"2003-08-31T19:19-04:00","_nGY8A6xx2KyCHaHy1nKAyuRAYXwKF82Hfh6Px3gYqk",1778988316354]