티스토리 뷰
Dynamic printf 기능은
gdb에서 recompile 없이, breakpoint 와 함께 결합된 printf () 를 즉석으로 추가하는 기능을 제공한다.
이런 소스가 있을때,
37 struct node *
38 insert (struct node *tree, char *data)
39 {
40 if (tree == NULL)
41 return alloc_node (NULL, NULL, data);
42 else
43 {
44 int cmp = strcmp (tree->data, data);
45
46 if (cmp > 0)
47 tree->left = insert (tree->left, data);
48 else if (cmp < 0)
49 tree->right = insert (tree->right, data);
50 return tree;
51 }
52 }
gdb 로 41라인에 대해서 이렇게 하면,
(gdb) dprintf 41,"Allocating node for data=%s\n", data
Dprintf 1 at 0x401281: file tree.c, line 41.
즉석으로 printf가 추가되며 breakpoint가 걸리는 이런 효과가 있다.
if (tree == NULL)
{ /* DEBUG - delete later. */
printf ("Allocating node for data=%s\n", data); /* DEBUG - delete later. */
return alloc_node (NULL, NULL, data);
} /* DEBUG - delete later. */
gdb manual -> https://sourceware.org/gdb/current/onlinedocs/gdb.html/Dynamic-Printf.html
Dynamic Printf (Debugging with GDB)
Set a “channel” for dprintf. If set to a non-empty value, GDB will evaluate it as an expression and pass the result as a first argument to the dprintf-function, in the manner of fprintf and similar functions. Otherwise, the dprintf format string will b
sourceware.org
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- oracle
- SQL
- dlerror()
- like
- LC_ALL #LANG #한글깨짐
- dlsym()
- dlopen()
- TDL
- ksh
- ORA-00845
- gdb #dprintf
- RedHat8 #network 껏다켜기
- common_parser #oracle19c #pro*c #DBIO
- jdk5 #autoboxing #unboxing #redjacob
- decode
- c #long_to_char_and_restore
- outlook 검색
- redhat9 #debuginfo
- struct padding #struct align
- dlclose()
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 |
글 보관함
