Difference between revisions of "LU-LSP-b11:L11"
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
LSP11: |
|||
Kods: |
|||
⚫ | |||
⚫ | |||
#include <stdio.h> |
#include <stdio.h> |
||
Line 9: | Line 7: | ||
#include <stdlib.h> |
#include <stdlib.h> |
||
#include <unistd.h> |
#include <unistd.h> |
||
char string[] = "hello world 1234567890"; |
char string[] = "hello world 1234567890"; |
||
int crash(int *pi) |
int crash(int *pi) |
||
{ |
{ |
||
Line 28: | Line 26: | ||
return 0; |
return 0; |
||
} |
} |
||
Makefile: |
|||
all: |
|||
gcc -g a.c -o pd11 |
|||
Lietošana: |
|||
gdb ./pd11 |
|||
run |
|||
continue |
|||
break <address> |
|||
print <variable> |
|||
set <variable> |
|||
next |
|||
step |
|||
⚫ | |||
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 |
Latest revision as of 17:12, 22 November 2011
gdb lietošana
Kods:
#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; }
Makefile:
all: gcc -g a.c -o pd11
Lietošana:
gdb ./pd11 run continue break <address> print <variable> set <variable> next step
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