Difference between revisions of "LU-LSP-b11:L11"
Line 1: | Line 1: | ||
LSP11: |
LSP11: |
||
''gdb'' lietošana |
=== ''gdb'' lietošana === |
||
⚫ | |||
Line 34: | Line 33: | ||
return 0; |
return 0; |
||
} |
} |
||
⚫ | |||
valgrind --leak-check=full ./pd11 |
|||
valgrind --tool=callgrind ./pd11 |
|||
Tiks izveidots šāds fails: ''callgrind.out.<pid>'', kur <pid> ir programmas ID. |
|||
Pēc tam to var skatīties ar: |
|||
kcachegrind callgrind.out.6413 |
Revision as of 17:11, 22 November 2011
LSP11:
gdb lietošana
Makefile:
all: gcc -g a.c -o pd11
#include <stdio.h> #include <memory.h> #include <stdlib.h> #include <unistd.h> char string[] = "hello world 1234567890"; int crash(int *pi) { *pi = 0x1; } int f(void) { crash(NULL); } int main() { f(); printf("%s\n", string); return 0; }
valgrind lietošana
valgrind --leak-check=full ./pd11
valgrind --tool=callgrind ./pd11
Tiks izveidots šāds fails: callgrind.out.<pid>, kur <pid> ir programmas ID. Pēc tam to var skatīties ar:
kcachegrind callgrind.out.6413