0

exeをデバッグするためにいくつかの代替手段を試した後、かなり失敗しましたが、gdbを試してWindows環境で実行可能ファイルをデバッグすることにしました。

exeのコンパイルに使用されているオプションは次のようになります

/nologo /Z7  /Zi /MT /W3 /GX /O2 /D /DEBUG

これらは、実行可能ファイルをgdbにロードするために使用しているオプションです

target exec setup
run -debug ( this is the option against which I would like to perform some debugging)

そうしないと有効なブレークポイントを設定できないため、ソース/シンボルを GDB にロードする方法が必要です。

これは、ブレークポイントを設定するために私が試したものです(通常の方法以外)

(gdb) set breakpoint pending on
(gdb) break runInstaller.c:6318
 No symbol table is loaded.  Use the "file" command.
 Breakpoint 2 (runInstaller.c:6318) pending.
 (gdb) pwd
 Working directory C:\
 (gdb) info b
  Num     Type           Disp Enb Address    What
  1       breakpoint     keep y   <PENDING>  WinMain
  2       breakpoint     keep y   <PENDING>  runInstaller.c:6318

実行可能ファイルをロードするためにこれを試しました。

(gdb) file setup
 Reading symbols from setup...(no debugging symbols found)...done.

上記のエラーが原因で、実行可能ファイルがデバッグ オプションを使用してコンパイルされていないことがわかりました。そのため、gdb に gcc -g と同等のものがあるか、シンボル/ソース コードを gdb にロードするより良い方法があります。

編集 1: ブレークポイントを追加しようとするたびに、次のエラーが表示されます。

(gdb) b main_helper
 Function "main_helper" not defined.
 Make breakpoint pending on future shared library load? (y or [n]) y
 Breakpoint 5 (main_helper) pending.
4

1 に答える 1