Tuesday, October 16, 2007

GDB Server i zdalne debugowanie

UWAGI: Nie bardzo da sie przechwytywac procesow puszczonych przez proces init (albo sprawia to kłopoty) - lepiej wiec wyjac je z inittab i puscic z ręki. Ważne jest też, żeby miec odpowiednio nowe narzędzia ‘cross’ z rodziny gdb (ja mialem 6.3-11), chodzi tu oczywiscie o toolchain sh4-linux.
1. Budujemy wszystko co sie da w wersji debug (najczesciej: -g -DDEBUG -fno-inline -fstack-check)
2. Umieszczamy debugowego execa i liby na skrzynce.
3. Odpalamy server: gdbserver : | <–attach=PID >
Bind address mozy byc ANY - czyli np mozna wolac gdbserver 0:5555 –attach=234
4. Za pomoca ddd, emacsa (gud-mode) lub command line’a uruchamiamy gdb na PC:
sh4-linux-gdb
Jesli ddd to tak: # ddd –debugger sh4-linux-gdb
5. Ustawiamy sciezke do libow: set solib-absolute-prefix
6 Łączymy sie z serverem: target remote
i debugujemy - kilka uzytecznych komend:
help - pomoc
cont - kontynuacja
step, next - praca krokowa
print, display - stan zmiennych, pamieci
detach - koniec debugowania
break [nazwa funkcji] | [plik:linia] - postawienie breakpointa
info break
cond break
where - wyswietlenie callstacka
info threads
thread [number] - przelaczenie sie na konkretny watek
list - wylistowanie kodu za biezacym miejscem
up,down [n pozycji] - poruszanie sie po stosie -domyslnie o 1 krok
etc.

==== hardware breakpoint ====
hbreak *0x address - stop jesli PC=address
display /i $pc - pokazuj pc i instrukcje
si, ni - krok o jedna instrukcje
C-x C-a
C-x a
C-x A
Enter or leave the TUI mode. When the TUI mode is left, the curses window management is left and GDB operates using its standard mode writing on the terminal directly. When the TUI mode is entered, the control is given back to the curses windows. The screen is then refreshed.
C-x 1
Use a TUI layout with only one window. The layout will either be `source' or `assembly'. When the TUI mode is not active, it will switch to the TUI mode. Think of this key binding as the Emacs C-x 1 binding.
C-x 2



1 comment:

Anonymous said...

Myslę ze eclipse 3.3 (Europa) + CDT (C/C++ Development Tooling) byłby o wiele lepszy do debagowania ;)