[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-571745-105":3,"detail-sidebar-cat-1-en-105":81,"doc-detail-571745-en":127},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":74,"head_meta":76,"extra_data":78,"updated_unix":80},105,"en","gdb-cheat-sheet-quick-reference","GDB Cheat Sheet - Quick Reference","","GDB Cheat Sheet provides a compact, practical command reference for debugging programs with GNU Debugger. It covers initialization (opening files, using layout to view C or assembly and registers), breakpoint management (at functions, main, and specific instruction offsets), and core execution controls (run, continue, next, step, quit/exit). It also includes commands for inspecting program state, printing variables and register values, examining memory with different formats, and checking or deleting breakpoints, plus common help and terminal graphics reset guidance.",{"@graph":14,"@context":73},[15,34,56],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/template/","Template",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/template/presentations/","Presentations",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/template/gdb-cheat-sheet-quick-reference/571745/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/gdb-cheat-sheet-quick-reference/571745.png","ImageObject",442,249,{"name":42,"@type":43},"Adam","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-10-22","2026-10-13",true,{"@type":52,"interactionType":53,"userInteractionCount":55},"InteractionCounter",{"@type":54},"ViewAction",6,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"How do you start debugging a program in gdb?","Question",{"text":63,"@type":64},"Use gdb ./filename to open the target in gdb, then use run to start from the beginning. Breakpoints you set beforehand are preserved across runs.","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"How can you set breakpoints for functions and assembly offsets?",{"text":68,"@type":64},"Use break function_name to stop at a function’s start and break main for the start of main. For assembly, use break *functionname+n to break n bytes into a function.",{"name":70,"@type":61,"acceptedAnswer":71},"How do you inspect variables, registers, and memory contents?",{"text":72,"@type":64},"Use p variablename to print variables and display $register (or p $register) to view register contents when hitting a breakpoint. Use x/s, x/wd, or x/wx with an address like $register+0xn to examine memory as strings, decimal, or hexadecimal.","https://schema.org",{"og:url":32,"og:type":75,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":77,"canonical":32},"index,follow",{"doc_id":79,"site_id":7},571745,1792338112,{"code":4,"msg":82,"data":83},"success",[84,88,93,98,103,108,113,118,123],{"id":85,"doc_module":22,"doc_module_name":25,"category_name":29,"show_sort_weight":86,"slug":87},11,90,"presentations",{"id":89,"doc_module":22,"doc_module_name":25,"category_name":90,"show_sort_weight":91,"slug":92},12,"Resumes",80,"resumes",{"id":94,"doc_module":22,"doc_module_name":25,"category_name":95,"show_sort_weight":96,"slug":97},14,"Invoices",70,"invoices",{"id":99,"doc_module":22,"doc_module_name":25,"category_name":100,"show_sort_weight":101,"slug":102},15,"Posters",60,"posters",{"id":104,"doc_module":22,"doc_module_name":25,"category_name":105,"show_sort_weight":106,"slug":107},16,"Social Media",50,"social-media",{"id":109,"doc_module":22,"doc_module_name":25,"category_name":110,"show_sort_weight":111,"slug":112},17,"Forms",40,"forms",{"id":114,"doc_module":22,"doc_module_name":25,"category_name":115,"show_sort_weight":116,"slug":117},18,"Letters",30,"letters",{"id":119,"doc_module":22,"doc_module_name":25,"category_name":120,"show_sort_weight":121,"slug":122},21,"Paper Templates",5,"papers-templates",{"id":124,"doc_module":22,"doc_module_name":25,"category_name":125,"show_sort_weight":4,"slug":126},158,"General","general-158",{"code":4,"msg":82,"data":128},{"doc_id":79,"user_id":129,"nickname":42,"user_avatar":130,"doc_module":22,"category_id":85,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":131,"file_id":132,"file_url":133,"file_type":134,"file_size":135,"view_count":55,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":26,"language":136,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":137,"faqs":138,"seo_title":139,"seo_description":12,"update_tm":140,"read_time":22},1374404737137,"https://ap-avatar.wpscdn.com/davatar_155a257f0dc6eb9ab79c44ca47cae57d","GDB Cheat Sheet  \nsetup (do this before running)  \ngdb ./filename: opens file in gdb  \nlayout src: displays C code  \nbreak function_name: sets breakpoint at start of function  \nbreak main (sets break point at the start of main function)  \nrunning  \nrun: runs program from the beginning  \n(can run as many times as you like and break points are preserved) run other_file_name: runs with file argument (soln.txt)  \nrun floats.txt (run the program with floats.txt passed as an argument) continue: runs program from current breakpoint  \nnext: executes current line and pauses before next line of code  \nstep: steps into a function  \nquit: kills program  \nexit: leave gdb  \nother helpful commands:  \np variablename: prints a variable  \nwhere: shows you which stack frames you are in and called your current function frame \\# : lets you look at a frame other than the current frame you are in info break: see what break points you have set  \ndel 2 : delete listed \\#2 break point  \nhelp gdbcommand: provides information about that command  \n( note: hitting enter will repeat the last gdb command,  \nuse the up/down arrows to find previous commands)  \n***use keys “ctrl-l” to reset the graphics after print output when screen output gets funky  \nGDB for assembly code debugging (weeks 6 & 7)  \nSet up:  \ngdb ./filename: opens file in gdb  \nlayout asm: displays assembly code  \nlayout register: displays registers  \nbreak function_name: sets breakpoint at start of function  \nbreak *functionname+n: sets breakpoint n bytes into a function  \nrunning  \nrun: runs program from the beginning  \nni: execute the next instruction in the program and pause  \nsi: steps into a function at current instruction  \nexamining state  \ndisplay $register: shows contents of register when breakpoint is hit p $register: prints value of register (/d=decimal,/c=char,/t=binary (0b) ,/x=hex(0x)) x/s $register+0xn: examines value at memory address as string  \nx/wd $register+0xn: examines value at memory address as decimal  \nx/wx $register+0xn: examines value at memory address as hexadecimal info registers: displays information about registers","cbCaifIpxw5DIRM5","https://ap.wps.com/l/cbCaifIpxw5DIRM5","pdf",99989,"English","# Setup\n## Running and execution control\n## Breakpoints\n# Inspecting state\n## Printing and examining values\n## Registers and memory formats\n# Useful helpers","[{\"question\":\"How do you start debugging a program in gdb?\",\"answer\":\"Use gdb ./filename to open the target in gdb, then use run to start from the beginning. Breakpoints you set beforehand are preserved across runs.\"},{\"question\":\"How can you set breakpoints for functions and assembly offsets?\",\"answer\":\"Use break function_name to stop at a function’s start and break main for the start of main. For assembly, use break *functionname+n to break n bytes into a function.\"},{\"question\":\"How do you inspect variables, registers, and memory contents?\",\"answer\":\"Use p variablename to print variables and display $register (or p $register) to view register contents when hitting a breakpoint. Use x/s, x/wd, or x/wx with an address like $register+0xn to examine memory as strings, decimal, or hexadecimal.\"}]","GDB Cheat Sheet - Quick Reference | PDF",1791923528]