2011-08-25 73 views

回答

5

您可以通過-x file選項或-ex command選項做到這一點。從Gdb manual

-command file 
-x file 
Execute commands from file file. The contents of this file is evaluated exactly as the source command would. See Command files. 
-eval-command command 
-ex command 
Execute a single gdb command. 
This option may be used multiple times to call multiple commands. It may also be interleaved with `-command' as required. 

      gdb -ex 'target sim' -ex 'load' \ 
      -x setbreakpoints -ex 'run' a.out 
0

對於文件名是.gdbrc還是.gdbin,但GDB會在啓動時從主目錄讀取此文件,並且它可以給出任何GDB命令(包括設置斷點),因此interwebs不同。

還檢查了http://www.andrews.edu/~seidel/gdb.help

+0

剛纔檢查手冊頁,看看有什麼文件被調用時,它的.gdbinit你可以告訴GDB與-n忽略這個,還是要-nx,有我的目的,我一個更好的辦法剛剛在手冊頁中找到(對不起!):-x FILE,-command = FILE從文件文件執行GDB命令。人們可以在每個行中寫入解釋器在該文件中執行的命令。 – hennr

相關問題