[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"detail-sidebar-cat-1-en-105":3,"doc-seo-571746-105":53,"doc-detail-571746-en":127},{"code":4,"msg":5,"data":6},0,"success",[7,14,19,24,29,34,39,44,49],{"id":8,"doc_module":9,"doc_module_name":10,"category_name":11,"show_sort_weight":12,"slug":13},11,1,"Template","Presentations",90,"presentations",{"id":15,"doc_module":9,"doc_module_name":10,"category_name":16,"show_sort_weight":17,"slug":18},12,"Resumes",80,"resumes",{"id":20,"doc_module":9,"doc_module_name":10,"category_name":21,"show_sort_weight":22,"slug":23},14,"Invoices",70,"invoices",{"id":25,"doc_module":9,"doc_module_name":10,"category_name":26,"show_sort_weight":27,"slug":28},15,"Posters",60,"posters",{"id":30,"doc_module":9,"doc_module_name":10,"category_name":31,"show_sort_weight":32,"slug":33},16,"Social Media",50,"social-media",{"id":35,"doc_module":9,"doc_module_name":10,"category_name":36,"show_sort_weight":37,"slug":38},17,"Forms",40,"forms",{"id":40,"doc_module":9,"doc_module_name":10,"category_name":41,"show_sort_weight":42,"slug":43},18,"Letters",30,"letters",{"id":45,"doc_module":9,"doc_module_name":10,"category_name":46,"show_sort_weight":47,"slug":48},21,"Paper Templates",5,"papers-templates",{"id":50,"doc_module":9,"doc_module_name":10,"category_name":51,"show_sort_weight":4,"slug":52},158,"General","general-158",{"code":4,"msg":54,"data":55},"ok",{"site_id":56,"language":57,"slug":58,"title":59,"keywords":60,"description":61,"schema_data":62,"social_meta":120,"head_meta":122,"extra_data":124,"updated_unix":126},105,"en","gdb-cheatsheet-basic","GDB Cheatsheet (Basic)","","GDB Cheatsheet (Basic) provides a compact, practical command reference for using the GNU Debugger effectively. It covers invoking and exiting GDB, attaching to running processes, handling child processes, and connecting to remote targets for debugging. It details breakpoints and watchpoints, common execution controls like continue, step, next, until, and stepping by machine instruction. It also explains how to list and disassemble code, examine or modify data and memory, inspect stack frames and variables, view registers, perform backtraces, switch among threads, and jump to specific locations.",{"@graph":63,"@context":119},[64,80,102],{"@type":65,"itemListElement":66},"BreadcrumbList",[67,71,74,77],{"item":68,"name":69,"@type":70,"position":9},"https://docshare.wps.com","Home","ListItem",{"item":72,"name":10,"@type":70,"position":73},"https://docshare.wps.com/template/",2,{"item":75,"name":11,"@type":70,"position":76},"https://docshare.wps.com/template/presentations/",3,{"item":78,"name":59,"@type":70,"position":79},"https://docshare.wps.com/template/gdb-cheatsheet-basic/571746/",4,{"url":78,"name":59,"@type":81,"image":82,"author":87,"headline":59,"publisher":90,"fileFormat":93,"inLanguage":57,"description":61,"dateModified":94,"datePublished":95,"encodingFormat":93,"isAccessibleForFree":96,"interactionStatistic":97},"DigitalDocument",{"url":83,"@type":84,"width":85,"height":86},"https://docshare.wps.com/thumbnails/gdb-cheatsheet-basic/571746.png","ImageObject",442,249,{"name":88,"@type":89},"Pentious","Person",{"url":68,"name":91,"@type":92},"DocShare","Organization","application/pdf","2026-10-22","2026-10-13",true,{"@type":98,"interactionType":99,"userInteractionCount":101},"InteractionCounter",{"@type":100},"ViewAction",6,{"@type":103,"mainEntity":104},"FAQPage",[105,111,115],{"name":106,"@type":107,"acceptedAnswer":108},"How do I start GDB and attach it to a running process?","Question",{"text":109,"@type":110},"Start GDB with gdb your_executable. Attach to a running process using gdb -p pid. The document also notes using pgrep exec_name inside the -p form.","Answer",{"name":112,"@type":107,"acceptedAnswer":113},"What are the key commands for breakpoints and conditional breakpoints?",{"text":114,"@type":110},"Use b file:line for line breakpoints. Use b . . . if cond for conditional breakpoints (breaks when the condition evaluates as specified). It also includes regex-based function matching and deletion commands like delete or clear.",{"name":116,"@type":107,"acceptedAnswer":117},"How can I inspect data, stack frames, and registers while debugging?",{"text":118,"@type":110},"Use p expr to print expression values and x/\u003Cn>\u003Cf>\u003Cu> addr to examine memory with display formats. For frames, use f, info f, info locals, and info args. For registers, use info registers [reg] to view one or all registers.","https://schema.org",{"og:url":78,"og:type":121,"og:title":59,"og:site_name":91,"og:description":61},"article",{"robots":123,"canonical":78},"index,follow",{"doc_id":125,"site_id":56},571746,1792360024,{"code":4,"msg":5,"data":128},{"doc_id":125,"user_id":129,"nickname":88,"user_avatar":130,"doc_module":9,"category_id":8,"category_name":11,"doc_title":59,"doc_description":61,"doc_content":131,"file_id":132,"file_url":133,"file_type":134,"file_size":135,"view_count":101,"is_deleted":4,"is_public":9,"is_downloadable":9,"audit_status":9,"page_count":47,"language":136,"language_code":57,"site_id":56,"html_lang":57,"table_of_contents":137,"faqs":138,"seo_title":139,"seo_description":61,"update_tm":140,"read_time":73},1374404730887,"https://ap-avatar.wpscdn.com/davatar_6f874abed73319feea01a86fa6f0fab8","GDB Cheatsheet (Basic)  \n Author: Guanzhou Jose Hu胡冠洲@ ShanghaiTech  \nGNU's official doc: [https://sourceware.org/gdb/current/onlinedocs/gdb/](https://sourceware.org/gdb/current/onlinedocs/gdb/) . Remember to compile with debugging info by setting flag -g . Invoke / Exit GDB  \n $ gdb your_executable ;  $ gdb -p pid to invoke GDB  \n often used trick:  $ gdb -p $ (pgrep exec_name) to debug a running executable  \n flag  -f forces GDB to catch every child process that the executable forks  \n target remote host:port  \n link a remote target who is listening for GDB connection on  host:port  \n commonly used pattern is localhost:1234 for debugging a kernel with QEMU  \n r [args]   \n start running the program  \n command-line args to the program should be provided here, not at GDB invocation  q  \n quit GDB, need confirmation if program is still running  \nBreakpoints  \nbreak at function entrance, right after stack setup  \n file name can be a path  \n b file :line   \n break at line in file, right before this line is executed  \n b . . . if cond   \n conditionally break if cond != 0 when reaching the breakpoint  \n  cond can be any valid expression  \n b *addr   \n break at code instruction at address addr  \nmatch function name with regex expression  \n regex specification follows  $ man grep   \n info b  \n view the info of all breakpoints  \n clear . . .   \n clear a breakpoint by  (just like how you set them)  \ndelete  \n delete all breakpoints (and watchpoints)  \nWatchpoints  \nbreak whenever var is written and the value changes  \n watching requires special hardware support, otherwise GDB inserts software watchpoints that make the execution very slow  \nwatch *addr  \n break whenever address  addr is written into and is modified  \n rwatch . . .  \n break whenever the thing is read  \n awatch . . .  \n break whenever the thing is read or written  \n info watch  \n view the info of all watchpoints  \nContinue Execution  \n c  \n continue running, until finish or reaching the next breakpoint  \nstep forward 1 / count source lines  \n will go inside function calls  \nstep forward 1 / count source lines  \n will proceed until function calls in the line return  \n u location  \n continue running until either the specified location or the current stack frame returns  \n  location can be in any acceptable form that  b accepts  \n si   \n step forward one machine code instruction  ni   \n step forward one machine code instruction  \n if that is a function call, will proceed until the function returns  \nCode Listing  \nshow 10 source lines around certain line  \n default is the current position of execution  l -  ;  l +   \n show 10 source lines before/after the previous listing  \nshow the starting & ending address of the compiled code of source line/function  \nshow disassembled machine instructions of function function  or instructions from memory address start    end  \n if current execution is pausing at somewhere within the instructions shown, that instruction will be prefixed with a  =>  \n disass /m . . .   \n show disassembled stuff along with the source code  \nExamine / Modify Data  \n p expr   \n execute the expression expr and show its value  \n  expr can be any valid expression:  \n variable name  \n&arr [0] : start address of a buffer  \n  *arr@len : first  len elements in arr   \n  arr [idx]@len : the idx th to  idx + len - 1 th elements in arr  \n  expr can modify the program state (e.g., an assignment), so it can be used for modifying variables  \n x/\u003Cn>\u003Cf>\u003Cu> addr  \n examine memory content at  addr  \n configurations:  \n \u003Cn> is the repeat count (how much after addr you want to examine)  \n \u003Cf> is the display format just like those in  printf (e.g.,  x ,  d ,  c , ...)  \n \u003Cu> is the unit size, which is any of:  \n  b -byte  \n  h -halfword (2 bytes)  \n w -word (4 bytes)  \n  g -giantword (8 bytes)  \n display expr   \n automatically show the value of expr every time we break  \nExamine Frame  \n f  \n show a brief info of the current stack frame  \n info f  \n show a more verbose info of the","cbCaiqpZyyEyeSRR","https://ap.wps.com/l/cbCaiqpZyyEyeSRR","pdf",201940,"English","# Invoke / Exit GDB\n# Breakpoints\n# Watchpoints\n# Continue Execution\n# Code Listing\n# Examine / Modify Data\n# Examine Frame\n# Backtracing\n# Multiple Threads\n# Jumping\n# Examine Registers\n# Miscellaneous","[{\"question\":\"How do I start GDB and attach it to a running process?\",\"answer\":\"Start GDB with gdb your_executable. Attach to a running process using gdb -p pid. The document also notes using pgrep exec_name inside the -p form.\"},{\"question\":\"What are the key commands for breakpoints and conditional breakpoints?\",\"answer\":\"Use b file:line for line breakpoints. Use b . . . if cond for conditional breakpoints (breaks when the condition evaluates as specified). It also includes regex-based function matching and deletion commands like delete or clear.\"},{\"question\":\"How can I inspect data, stack frames, and registers while debugging?\",\"answer\":\"Use p expr to print expression values and x/\\u003cn\\u003e\\u003cf\\u003e\\u003cu\\u003e addr to examine memory with display formats. For frames, use f, info f, info locals, and info args. For registers, use info registers [reg] to view one or all registers.\"}]","GDB Cheatsheet (Basic) | PDF",1791923529]