/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/gdb.txt

  • Committer: Suren A. Chilingaryan
  • Date: 2009-04-09 03:21:08 UTC
  • Revision ID: csa@dside.dyndns.org-20090409032108-w4edamdh4adrgdu3
import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
IMPORTANT
 
2
=========
 
3
 * Be careful with gcc optimizations, they can cause strange effects
 
4
 * Runnig with altered LD_LIBRARY_PATH (environment?)
 
5
    LD_LIBRARY_PATH=./libopc/:./libds/ srv/opc-server
 
6
 troubles gdb in finding function names, etc.
 
7
 
 
8
Basic
 
9
=====
 
10
 * Enter - repeats last command
 
11
    for 'list' just continuing listing (paramters are not appended)
 
12
 
 
13
Loading Symbols
 
14
===============
 
15
 info files/target              - Show information on currently loaded app
 
16
                                executable name, sections, entry point, ...
 
17
 maintenance info sections <opt>- More information on sections
 
18
    ALLOBJ      - sections for all loaded object files (including shared libs)
 
19
    sections    - only named sections
 
20
    flags       - display only sections for which flags are true
 
21
        ALLOC   - Section will have space allocated in the process when loaded
 
22
        LOAD    - Section will be loaded from the file into the VM
 
23
        RELOC   - Section needs to be relocated before loading
 
24
        READONLY
 
25
        CODE    - Section contains executable code only
 
26
        DATA    - Section contains no executable code
 
27
        ROM     - Section will reside in ROM
 
28
        CONSTRUCTOR     - Section contains data for constructor/destructor lists
 
29
        HAS_CONTENTS    - Section is not empty
 
30
        NEVER_LOAD      - An instruction to the linker to not output the section
 
31
        IS_COMMON       - Section contains common symbols
 
32
        COFF_SHARED_LIBRARY     - contains COFF shared library information
 
33
        
 
34
 info address <symbol>          - Find address by symbol name
 
35
 info symbol <address>          - Find symbol by address
 
36
 
 
37
 info files/target              - Lists sections in executable files
 
38
 
 
39
 
 
40
 file <app>                     - Load file
 
41
 exec-file <app>                - Load and run
 
42
 
 
43
 info sharedlibrary             - List of loaded shared libraries
 
44
 sharedlibrary regex            - Load shared library matching regex (only loads
 
45
                                libraries required by debugged application)
 
46
 
 
47
 show auto-solib-add / set auto-solib-add <mode>
 
48
    if on, symbols from all shared object libraries will be loaded automatically,
 
49
    otherwise they must be loaded manually, using the sharedlibrary.
 
50
 
 
51
 symbol-file <name>             - Read symbol table from file
 
52
    + readnow - process all symbols at once, not on need
 
53
    + mapped - store symbol table in mmaped file
 
54
 add-symbol-file <file> <addr>  - Add additional symbols (for dynamicaly loaded
 
55
                                modules, addr specifies adress the module is 
 
56
                                loaded at)
 
57
    + -s<section> <address> - to give an explicit section name and base address 
 
58
    for that section.
 
59
 
 
60
 file                           - Discard all information on app and symbols
 
61
 symbol-file                    - Clear symbol information
 
62
 
 
63
 
 
64
  
 
65
 Core dumps
 
66
 ----------
 
67
 ulimit -c unlimited            - Allow core dumps (prior to run application)
 
68
 core <core-dump-file-name>     - Analys core dump i gdb
 
69
 
 
70
Executing GDB
 
71
=============
 
72
 - Fully automatic mode:
 
73
    gdb < cmds.txt > log.txt 2>&1
 
74
 
 
75
Preparing Sources
 
76
=================
 
77
 Use:
 
78
    CFLAGS="-g"
 
79
    CFLAGS="-gdwarf-2 -g3"      - For expanding macros
 
80
 
 
81
 Don't use:
 
82
    `-fomit-frame-pointer'      - Generates functions without a stack frame