diff options
author | johannst <johannst@users.noreply.github.com> | 2021-02-17 22:45:32 +0000 |
---|---|---|
committer | johannst <johannst@users.noreply.github.com> | 2021-02-17 22:45:32 +0000 |
commit | a703aed9ec0380d8a08e42792ff6c87294d3760b (patch) | |
tree | e17f8ab10216ae15c720be458abe7fb10f173c03 /print.html | |
parent | f2d341eb19d222c96446a3a7f20eaef53dbcacfa (diff) | |
download | notes-a703aed9ec0380d8a08e42792ff6c87294d3760b.tar.gz notes-a703aed9ec0380d8a08e42792ff6c87294d3760b.zip |
deploy: f2a7581c71fe5863a527850e4c0e2906f02e4d2d
Diffstat (limited to 'print.html')
-rw-r--r-- | print.html | 103 |
1 files changed, 93 insertions, 10 deletions
@@ -1388,25 +1388,49 @@ gpg --verify <file>.asc <file> --tty <tty> set I/O tty for debugee </code></pre> <h1><a class="header" href="#interactive-usage" id="interactive-usage">Interactive usage</a></h1> +<h2><a class="header" href="#misc" id="misc">Misc</a></h2> <pre><code class="language-markdown"> tty <tty> Set <tty> as tty for debugee. Make sure nobody reads from target tty, easiest is to spawn a shell and run following in target tty: > while true; do sleep 1024; done - set follow-fork-mode <child | parent> - Specify which process to follow when debuggee makes a fork(2) - syscall. - sharedlibrary [<regex>] Load symbols of shared libs loaded by debugee. Optionally use <regex> to filter libs for symbol loading. - break [-qualified] <sym> thread <tnum> + display [/FMT] <expr> + Print <expr> every time debugee stops. Eg print next instr, see + examples below. + + undisplay [<num>] + Delete display expressions either all or one referenced by <num>. + + info display + List display expressions. +</code></pre> +<h2><a class="header" href="#breakpoints" id="breakpoints">Breakpoints</a></h2> +<pre><code class="language-markdown"> break [-qualified] <sym> thread <tnum> Set a breakpoint only for a specific thread. - -qualified: Tred <sym> as fully qualified symbol (quiet handy to set + -qualified: Treat <sym> as fully qualified symbol (quiet handy to set breakpoints on C symbols in C++ contexts) + break <sym> if <cond> + Set conditional breakpoint (see examples below). + + delete [<num>] + Delete breakpoint either all or one referenced by <num>. + + info break + List breakpoints. + + cond <bp> <cond> + Make existing breakpoint <bp> conditional with <cond>. + + tbreak + Set temporary breakpoint, will be deleted when hit. + Same syntax as `break`. + rbreak <regex> Set breakpoints matching <regex>, where matching internally is done on: .*<regex>.* @@ -1418,16 +1442,18 @@ gpg --verify <file>.asc <file> <bp_list>: Space separates list, eg 'command 2 5-8' to run command for breakpoints: 2,5,6,7,8. - - info functions [<regex>] +</code></pre> +<h2><a class="header" href="#inspection-1" id="inspection-1">Inspection</a></h2> +<pre><code class="language-markdown"> info functions [<regex>] List functions matching <regex>. List all functions if no <regex> provided. info variables [<regex>] List variables matching <regex>. List all variables if no <regex> provided. - - info handle [<signal>] +</code></pre> +<h2><a class="header" href="#signal-handling" id="signal-handling">Signal handling</a></h2> +<pre><code class="language-markdown"> info handle [<signal>] Print how to handle <signal>. If no <signal> specified print for all signals. @@ -1441,6 +1467,45 @@ gpg --verify <file>.asc <file> catch signal <signal> Create a catchpoint for <signal>. </code></pre> +<h2><a class="header" href="#source-file-locations" id="source-file-locations">Source file locations</a></h2> +<pre><code class="language-markdown"> dir <path> + Add <path> to the beginning of the searh path for source files. + + show dir + Show current search path. + + set substitute-path <from> <to> + Add substitution rule checked during source file lookup. + + show substitute-path + Show current substitution rules. +</code></pre> +<h2><a class="header" href="#configuration" id="configuration">Configuration</a></h2> +<pre><code class="language-markdown"> set follow-fork-mode <child | parent> + Specify which process to follow when debuggee makes a fork(2) + syscall. + + set pagination <on | off> + Turn on/off gdb's pagination. + + set breakpoint pending <on | off | auto> + on: always set pending breakpoints. + off: error when trying to set pending breakpoints. + auto: interatively query user to set breakpoint. + + set print pretty <on | off> + Turn on/off pertty printing of structures. + + set logging <on | off> + Enable output logging to file (default gdb.txt). + + set logging file <fname> + Change output log file to <fname> + + set logging redirect <on/off> + on: only log to file. + off: log to file and tty. +</code></pre> <h1><a class="header" href="#user-commands-macros" id="user-commands-macros">User commands (macros)</a></h1> <p>Gdb allows to create & document user commands as follows:</p> <pre><code class="language-markdown"> define <cmd> @@ -1470,6 +1535,24 @@ gpg --verify <file>.asc <file> end </code></pre> <h1><a class="header" href="#examples-1" id="examples-1">Examples</a></h1> +<h2><a class="header" href="#automatically-print-next-instr" id="automatically-print-next-instr">Automatically print next instr</a></h2> +<p>When ever the debugee stops automatically print the memory at the current +instruction pointer (<code>$rip</code> x86) and format as instruction <code>/i</code>.</p> +<pre><code class="language-markdown"> # rip - x86 + display /i $rip + + # step instruction, after the step the next instruction is automatically printed + si +</code></pre> +<h2><a class="header" href="#conditional-breakpoints" id="conditional-breakpoints">Conditional breakpoints</a></h2> +<p>Create conditional breakpoints for a function <code>void foo(int i)</code> in the debugee.</p> +<pre><code class="language-markdown"> # Create conditional breakpoint + b foo if i == 42 + + b foo # would create bp 2 + # Make existing breakpoint conditional + cond 2 if i == 7 +</code></pre> <h2><a class="header" href="#catch-sigsegv-and-execute-commands" id="catch-sigsegv-and-execute-commands">Catch SIGSEGV and execute commands</a></h2> <p>This creates a <code>catchpoint</code> for the <code>SIGSEGV</code> signal and attached the <code>command</code> to it.</p> |