| ページ一覧 | ブログ | twitter |  書式 | 書式(表) |

MyMemoWiki

差分

ナビゲーションに移動 検索に移動
編集の要約なし
==Linux C gdbによるデバッグ==
[[Programming C][Linux]]
以下の本からのメモ。良書。
{{amazon|4797328355}}
GNU gdb (GDB) Red Hat Enterprise Linux (7.0.1-23.el5_5.2)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <&lt;http://gnu.org/licenses/gpl.html>&gt;
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
This GDB was configured as "i386-redhat-linux-gnu".
For bug reporting instructions, please see:
<&lt;http://www.gnu.org/software/gdb/bugs/>&gt;...
Reading symbols from /root/workspace/myhead/src/myhead...done.
(gdb)
0x00bfe50b in ____strtol_l_internal () from /lib/libc.so.6
<&lt;blockquote>&gt;Segmentation fault が発生したので、その場所で停止し、問題の起きた場所を表示<&lt;/blockquote>&gt;
===スタックトレースを backtrace コマンドで表示する===
#3 0x0804862b in main (argc=3, argv=0xbfffe864) at myhead.c:31
31 nlines = atol(optarg);
<&lt;blockquote>&gt;実行中の関数が、main になり、実行中の行が表示される<&lt;/blockquote>&gt;
*もう少し広い範囲を見るときには、listコマンドを使用する
(gdb) list
(gdb) print optarg
$1 = 0x0
<&lt;blockquote>&gt;中身がNULL。Nullポインタがセグメンテーション違反の原因と判明<&lt;/blockquote>&gt;
===continue 、quit で、デバッグを終了する===

案内メニュー