/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to Development/debugging/gdb/expecting.txt

  • Committer: Suren A. Chilingaryan
  • Date: 2015-08-21 03:52:00 UTC
  • Revision ID: csa@suren.me-20150821035200-xu1zh22cqlk2omcq
Profiling

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Navigating Stack
2
 
=================
3
 
 bt [count]             - backtrace (count limits the depth of backtrace)
4
 
                         + printed 'addr' is program counter (pc), not frame 
5
 
                         address
6
 
 
7
 
 info program           - Current status and position
8
 
                         + info line *addr - to get line number
9
 
 info frame [#num|addr] - various information on current or selected stack 
10
 
                        frame (incl. address)
11
 
                         
12
 
 frame(f) <#num>        - set current stack fram (doesn't adjust execution 
13
 
                        position just allows to examine variables, etc.)
14
 
 frame(f) <addr>        - select frame at address 'addr'
15
 
 select-frame ...       - do it silently (do not print anything)
16
 
 up/down [count]        - move up-and-down trough the stack
17
 
 *-silently             - do it silently
18
 
 
19
 
Show Sources
20
 
============
21
 
 * Sources
22
 
    Normally located automatically if '-g' is used
23
 
    dir dirname                 - Set additional directory to look for sources
24
 
 
25
 
 * Info
26
 
    info sources                - Information about known sources
27
 
    info source                 - Information about current source    
28
 
    info functions [regexp]     - List all functions matching regexp (by source)
29
 
    info variables [regexp]     - List all global variables (by source)
30
 
 
31
 
 * List
32
 
    list mrandom.c:252
33
 
    list mrandom.c:randomRun
34
 
    list *address               - Show function at that address
35
 
    list -/+                    - List lines before/after last printed
36
 
    set listsize ###            - Number of lines to display
37
 
 
38
 
 * Searching
39
 
    search regexp / reverse-search regexp
40
 
 
41
 
 * Disassembling
42
 
    info line <linespec>        - Show information (address, etc)
43
 
    info line *addr             - Show begining/end address of corespondent code
44
 
    disasm from_add to_addr     - Without asterix
45
 
    
46
 
    set disassembly-flavor intel|att    - Set assembler syntax
47
 
 
48
 
Expecting Variables
49
 
==================
50
 
 * These functions by default are working with currnet stack frame (see section
51
 
    'Navigating Stack' for details.
52
 
 
53
 
  * p 'mrandom.c'::randomRun::ctx       - quotes are mandatory
54
 
    + ::ctx->ictx_complex               - works
55
 
    + 'mrandom.c'::randomRun            - address of a function
56
 
    
57
 
   p {type} ptr                         - Shows value referenced by stored 
58
 
   p *ptr@5                             - Shows array of 5 elements by addr 5
59
 
   p/# ...                              - # is number format
60
 
    x (hex), d (dec), u(unsigned), o(oct), t(bin), a(addr), c(char), f(fp)
61
 
   
62
 
 
63
 
 Info on Variables and Types
64
 
 ---------------------------
65
 
   whatis [expr]                        - Outputs type of expression, if 'expr'
66
 
                                        omitted - last evaluated expression
67
 
   ptype [typename|expr]                - Info's on struct, union, enum, class
68
 
 
69
 
   info locals                          - Print all local variables
70
 
   info args                            - Print all function arguments
71
 
   info catch                           - Print all active exception handlers
72
 
 
73
 
   info types [regexp]                  - Prints all types matching regexp
74
 
   info scope [*addr|func|code-line]    - List variables local to paticular 
75
 
                                        scope
76
 
   
77
 
 
78
 
 Altering variables
79
 
 ------------------
80
 
    p i = 4                     - Setting new value to variable 'i'
81
 
    set var i = 4               - Silently set new value of variable
82
 
                                 + 'var' could be omited if 'i' is  not special
83
 
                                 command of gdb 'set' statement
84
 
 Function calls
85
 
 ----------------
86
 
    - It is theoretically possible to call functions from gdb, but this seems
87
 
    doesn't work if gdb is attached to process (threading, or something other
88
 
    also could be a reson, I'm not sure really)
89
 
    
90
 
    p i = fabs(j)               - Allowable
91
 
    call fabs(j)                - Do not inform about 'void' results
92
 
 
93
 
 Temporary variables
94
 
 -------------------
95
 
   set $i = 0           - do not mix with registers, check prior to assignment
96
 
 
97
 
 Examining memory
98
 
 ------------------
99
 
   x[/nfu]  addr
100
 
    n - repeat count
101
 
    f - format ( s(str), i(machine instruction), x(hex), ...)
102
 
    u - unit size (b - bytes, h - half word (2bytes), w - word, g - double word)
103
 
 
104
 
Registers
105
 
=========
106
 
 info registers                         
107
 
 info all-registers                     - Includes FP registers
108
 
 info registers rax                     - Shows 'rax' register only
109
 
 p/x $rax                               - Also show register
110
 
 set $rax += 4                          - Adjusting values
111
 
    
112
 
 info float                             - FP hardware info
113
 
 info vector                            - Vector Unit Info
114
 
   
115
 
Expanding macros
116
 
================ 
117
 
 * Sources should be compiled with gcc4 and flags:
118
 
    `-gdwarf-2' `-g3'
119
 
 * Constructs like ('##', variable arity, ...) are not supported
120
 
 * Do not work for complex cases for me
121
 
 
122
 
    info macro <macro>
123
 
    macro exp <expr>
124
 
    
125
 
   
126
 
Memory Regions
127
 
==============
128
 
 Memory region attributes allow you to describe special handling required by 
129
 
 regions of your target's memory. GDB uses attributes to determine whether to 
130
 
 allow certain types of memory accesses; whether to use specific width accesses,
131
 
 and whether to cache target memory.
132
 
 
133
 
 mem lower upper attributes
134
 
 delete/disable/enable mem ###
135
 
 info mem
136
 
 
137
 
 * Dump memory region to file
138
 
 dump/append [binary/ihex/srec/tekhex] [memory/value] <filename> start_addr end_addr
139
 
  - Formats    
140
 
    binary - raw memory
141
 
    ihex - Intel hex format
142
 
  - What
143
 
    memory - dump memory from start_addr to end_addr
144
 
    value - instead of addresses specify expression and dump it's value
145
 
 
146