This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
bune-practici [2015/11/30 16:16] catalin.vasile3004 [Segmentation Fault debugging: GDB quicky] |
bune-practici [2015/11/30 16:24] catalin.vasile3004 [Segmentation Fault debugging: GDB quicky] |
||
---|---|---|---|
Line 233: | Line 233: | ||
0x08048423 in keep_printing () | 0x08048423 in keep_printing () | ||
</code> | </code> | ||
+ | Pentru a vedea ce instrucţiunea a provocat segfault putem da următoarea comandă: | ||
+ | <code> | ||
+ | (gdb) display/10i $pc | ||
+ | 1: x/10i $pc | ||
+ | => 0x8048423 <keep_printing+1>: push DWORD PTR [ecx*4+0x804a02c] | ||
+ | 0x804842a <keep_printing+8>: push 0x804a020 | ||
+ | 0x804842f <keep_printing+13>: call 0x80482f0 <printf@plt> | ||
+ | 0x8048434 <keep_printing+18>: add esp,0x8 | ||
+ | 0x8048437 <keep_printing+21>: pop ecx | ||
+ | 0x8048438 <keep_printing+22>: inc ecx | ||
+ | 0x8048439 <keep_printing+23>: cmp ecx,DWORD PTR ds:0x804a040 | ||
+ | 0x804843f <keep_printing+29>: jl 0x8048422 <keep_printing> | ||
+ | 0x8048441 <keep_printing+31>: ret | ||
+ | 0x8048442 <keep_printing+32>: xchg ax,ax | ||
+ | </code> | ||
+ | * **$pc** este o variabilă **gdb**, şi vine de la **P**rogram **C**ounter (este pointer-ul la instrucţiunea curentă). | ||
+ | * **display** face dump de la un pointer dat ca argument, în cazul nostru **$pc** | ||
+ | * **i**-ul îi spune lui **display** să interpreteze datele de acolo ca şi cum ar fi instrucţiuni | ||
+ | * **10** îi sune lui **display** câţi operanzi/instrucţiuni de tipul **i** (instrucţiune) să afişeze\\ \\ | ||
+ | Prin ''<keep_printing+some_number>'', **gdb** incearcă să ne arate cam pe unde ar fi această instrucţiune. În cazul nostru instrucţiunea este aproape de label-ul **keep_printing**. | ||
===== Categorie 3 ===== | ===== Categorie 3 ===== | ||
* TODO | * TODO | ||
* TODO | * TODO |