2016-05-30 61 views
1

我想在一個文件中執行一些gdb命令。我也想讓命令運行並將輸出記錄到文件中。如何在記錄文件中包含GDB命令?

我在一個名爲gdb.in的文件中寫了下面的gdb腳本。

set logging file gdb.out 
set logging on 
echo hi\n 
printf "bye\n" 
quit 

但是,如果我執行這個gdb腳本,我只能看到輸出記錄到gdb.out。我看不到執行的命令。

$ gdb -x gdb.in 
GNU gdb (GDB) Red Hat Enterprise Linux (7.2-60.el6) 
Copyright (C) 2010 Free Software Foundation, Inc. 
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> 
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" 
and "show warranty" for details. 
This GDB was configured as "x86_64-redhat-linux-gnu". 
For bug reporting instructions, please see: 
<http://www.gnu.org/software/gdb/bugs/>. 
hi 
bye 
$ cat gdb.out 
hi 
bye 

據我記得,幾年前,我找到了一種記錄命令的方法。用於出現在日誌文件中的每個命令都以+作爲前綴。例如,幾年前我能夠得到這樣的輸出。

+ echo hi\n 
hi 
+ printf "bye\n" 
bye 
+ quit 

但我無法回想起我做了什麼來獲得這樣的輸出。搜索網絡也沒有幫助我。我在How to dump the entire GDB session to a file, including commands I type and their output?處遇到了這個問題,但那裏的答案沒有捕獲在日誌文件中執行的命令。

回答

1

這是GDB feature request,這是至少12歲:-(

目前還沒有辦法做到這一點。你可以使用script來記錄整個GDB會議的主題,但具有還記錄各種屏幕控制「垃圾」字符的明顯缺點。

相關問題