gdb日志文件格式

时间:2010-10-05 09:01:57

标签: gdb cgdb

当我在gdb中使用set logging on时,日志文件的输出格式与我在终端屏幕上看到的格式不同。日志文件不是很易读。如何以可读格式获取日志文件?

输出到屏幕很好:

(gdb) p foo
$1 = {
  static npos = 18446744073709551615,
  _M_dataplus = {
    <std::allocator<char>> = {
      <__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>},
    members of std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Alloc_hider:
    _M_p = 0x601028 "Hello World!\n"
  }
}

输出到日志文件的可读性不高:

^Z^Zpost-prompt

^Z^Zbreakpoints-headers

^Z^Zfield 0
Num     
^Z^Zfield 1
Type           
^Z^Zfield 2
Disp 
^Z^Zfield 3
Enb 
^Z^Zfield 4
Address            
^Z^Zfield 5
What

^Z^Zbreakpoints-table

^Z^Zrecord

^Z^Zfield 0
1       
^Z^Zfield 1
breakpoint     
^Z^Zfield 2
keep 
^Z^Zfield 3
y   
^Z^Zfield 4
0x0000000000400961 
^Z^Zfield 5
in main at test.cpp:9
        breakpoint already hit 1 time

^Z^Zbreakpoints-table-end

^Z^Zpost-prompt

^Z^Zvalue-history-begin 1 -
$1 = 
^Z^Zvalue-history-value
{

^Z^Zfield-begin -
static npos
^Z^Zfield-name-end
 = 
^Z^Zfield-value
18446744073709551615
^Z^Zfield-end
, 

^Z^Zfield-begin -
_M_dataplus
^Z^Zfield-name-end
 = 
^Z^Zfield-value
{
    <std::allocator<char>> = {
      <__gnu_cxx::new_allocator<char>> = {<No data fields>}, <No data fields>}, 
    members of std::basic_string<char,std::char_traits<char>,std::allocator<char> >::_Alloc_hider: 

^Z^Zfield-begin *
_M_p
^Z^Zfield-name-end
 = 
^Z^Zfield-value
0x601028 "Hello World!\n"
^Z^Zfield-end

  }
^Z^Zfield-end

}

^Z^Zvalue-history-end

^Z^Zpost-prompt

^Z^Zbreakpoints-headers

^Z^Zfield 0
Num     
^Z^Zfield 1
Type           
^Z^Zfield 2
Disp 
^Z^Zfield 3
Enb 
^Z^Zfield 4
Address            
^Z^Zfield 5
What

^Z^Zbreakpoints-table

^Z^Zrecord

^Z^Zfield 0
1       
^Z^Zfield 1
breakpoint     
^Z^Zfield 2
keep 
^Z^Zfield 3
y   
^Z^Zfield 4
0x0000000000400961 
^Z^Zfield 5
in main at test.cpp:9
        breakpoint already hit 1 time

^Z^Zbreakpoints-table-end

^Z^Zpost-prompt

1 个答案:

答案 0 :(得分:6)

您必须在某种IDE中使用它,这会打开MI(机器界面)。您看到的输出是为了便于另一个程序解析,但不供人类使用。

MI接口也可能影响gdb.txt日志格式的错误。请提交有关它的错误here

作为一种解决方法,在IDE外部运行GDB以收集易于阅读的gdb.txt