タグ

ブックマーク / nari.hatenablog.com (1)

  • gdbでメモリダンプして構造体を発見するTips - I am Cruby!

    gdb知りたい構造体が見たくても見れない場合に便利。例えば、デバッグシンボルがないバイナリ内でSEGVしている場合など。*1 こんなコードを用意してみた。特徴コンパイルは-gなしhg->comment = "Hellow!" だとSEGVが発生  #include #include struct hoge { int id; char *comment; }; void throw_segv(char *comment) { int test[1000]; if(!strcmp(comment, "Hellow!")) test[-100000] = 9; } int main(void) { struct hoge *hg; hg = malloc(sizeof(struct hoge)); hg->id = 2565; hg->comment = "Hellow!"; throw_

    odawara
    odawara 2009/05/14
  • 1