Presentation is loading. Please wait.

Presentation is loading. Please wait.

Debugovani ● debugovaci informace ● STABS format (nyni zastarale) ● DWARF formaty ● gdb ● ddd.

Similar presentations


Presentation on theme: "Debugovani ● debugovaci informace ● STABS format (nyni zastarale) ● DWARF formaty ● gdb ● ddd."— Presentation transcript:

1 Debugovani ● debugovaci informace ● STABS format (nyni zastarale) ● DWARF formaty ● gdb ● ddd

2 Debugovaci informace gcc: ● -g, -ggdbgeneruje debugovaci informace relevantni pro gdb ● -gdwarf-4generuje debugovaci informace ve formatu dwarf-4 ● -g nastavy pozadovany format debugovacich dat ● -s odstrani mimo jine i debugovaci data

3 Debugovaci informace Rozdil mezi ● gcc -O0 -g ● gcc -O2 -g vypsani dwarf debug. dat pro danou binarky ● readelfvypisuje informace o ELF ● readelf -wvypise vsechny zaznamy ● readelf -wivypise dwarf zaznamy v.debug_info sekci ● readelf -w[lLiaprmfFsoR]

4 STABS format ● “symbol table entries” ● Peter Kessler (University of California) vytvoril format pro Pascal debugger - ?1988? ● 4 typy zaznamu: –.stabs "string",type,other,desc,value –.stabn type,other,desc,value –.stabd type,other,desc –.stabx "string",value,type,sdb-type

5 STABS format Cast z obsahu pogram.s souboru 18.stabs "double:t13=r1;8;0;",128,0,0,0 19.stabs "long double:t14=r1;8;0;",128,0,0,0 20.stabs "void:t15=15",128,0,0,0 21.align 4 22 LC0: 23.ascii "Hello, world!\12\0" 24.align 4 25.global _main 26.proc 1 27 _main: 28.stabn 68,0,4,LM1

6 DWARF format (1) ● 'Debugging With Attributed Record Formats' ● vytvoren spolu s formatem ELF ● DWARF 1 prilis pametove narocne, ne prilis rozsiren ● DWARF 2 (1990) mensi pametova narocnost, vice rozsiren ● DWARF 3 (2006) obsahuje c++ namespaces,.. ● DWARF 4 (2010) lepsi podpora c++ a optimalizoveho kodu

7 DWARF format (2) ● K reprezentaci promennych, typu a procedur pouzva struktury Debugging Information Entry (DIE) ● Zaznamy rozdeleny do sekci –.debug_ sekce

8 DWARF format (3) $ readelf -wi sdwarf2 Contents of the.debug_info section: Compilation Unit @ offset 0x0: Length: 0x94 (32-bit) Version: 2 Abbrev Offset: 0 Pointer Size: 4 : Abbrev Number: 1 (DW_TAG_compile_unit) DW_AT_producer : (indirect string, offset: 0x33): GNU C 4.4.4 20100630 (Red Hat 4.4.4-10) DW_AT_language : 1(ANSI C) DW_AT_name : (indirect string, offset: 0x60): test.c DW_AT_comp_dir : (indirect string, offset: 0x7a): /tmp DW_AT_low_pc : 0x80483f4 DW_AT_high_pc : 0x8048436 DW_AT_stmt_list : 0x0 : Abbrev Number: 2 (DW_TAG_base_type) DW_AT_byte_size : 4 DW_AT_encoding : 7(unsigned) DW_AT_name : (indirect string, offset: 0x26): unsigned int

9 gdb(1) ● The GNU Project Debugger (version 7.2) ● napsan Richardem Stallmanem v roce 1986 – zakladatel GNU projektu a Free Software Foundation ● verze pouziva format DWARF (od gdb-4.3 obsahuje DWARF support) ● nyni vyvijeno skupinou “GDB Steering Committee” ● Obsahuje pouze command line interface

10 SPUSTENI ● gdb program ● gdb progam.c core ● gdb program $PID ZAVRENI ● q,quit, +D ● +C

11 gdb (2) SPUSTENI PROGRAMU ● run spustit program s defaultnimi argumenty ● run spustit program s danymi/defaultnimi argumenty ● run... outf ● killukonci spusteny program

12 gdb(3) PARAMETRY SPUSTENI ● set args argsnastavi seznam arg. pro nasledne spusteni programu ● show argsukaze seznam nastavenych argumentu ● set env nastavi promennou prosredi ● show env ukaze promenne prostredi

13 gdb(4) BREAKPOINTY ● b [file:]linenastavi breakpoint na radek linefile:]line ● b [file:]funcnastavi breakpoint na funkci function ● watch exprnastavi watchpoint na vyraz expr ● info breakukaze nastavene breakpoint ● info watchukaze nastavene watche ● delete [n]smaze breakpoint cislo n

14 gdb(5) DATA O ZASOBNIKU ● info localsvypise lokalni promenne ● btbacktrace

15 gdb(6) VYKONAVANI KODU ● c,continuepokracuj v behu programu ● s,steppokracuj do dalsi radky ● n,nextpokracuj do dalsi radky, vcettne pruchodu funkci ● n(5)proved n 5-krat za sebou ● j pokracuj do radku cislo line

16 gdb(7) DALSI ● p, printvytiskni hodnotu promenne ● shell proved prikaz shellu ● whatis vrati typ argumentu ● ptype vrati definici typu

17 ddd

18 ddd (2) ● Prikazovy radek

19 ddd(3) ● Kod programu (+ breakpointy,..)

20 ddd(4) ● vypis hodnot promennych


Download ppt "Debugovani ● debugovaci informace ● STABS format (nyni zastarale) ● DWARF formaty ● gdb ● ddd."

Similar presentations


Ads by Google