Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdb log file format

Tags:

gdb

cgdb

When I use set logging on in gdb, the output to the log file has a different format than what I see on the terminal screen. The logfile is not very readable. How can I get the log file in a readable format?

Output to screen is fine:

(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"
  }
}

Output to log file is not very readable:

^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
like image 471
matthiash Avatar asked Oct 05 '10 09:10

matthiash


People also ask

How do I save GDB logs?

Logging GDB's output to a file This is done by first issuing the command set logging file my-gdb-log , followed by the command set logging on . Later on, you can issue the set logging off command to stop sending GDB output to the log file.

Where is GDB TXT located?

at the GDB prompt. GDB saves all output from this point in a text file called gdb. txt that resides in the directory in which you are running GDB (usually the same directory as your executable).

What is GDB command file?

A command file for GDB is a text file made of lines that are GDB commands. Comments (lines starting with # ) may also be included. An empty line in a command file does nothing; it does not mean to repeat the last command, as it would from the terminal.


1 Answers

You must be using this from some kind of IDE, which turns on MI (machine interface). The output you see is made for easy parsing by another program, but not for human consumption.

It is likely a bug that MI interface also affects the format of gdb.txt log. Please file a bug about it here.

As a workaround, run GDB outside of the IDE to collect easy to read gdb.txt.

like image 67
Employed Russian Avatar answered Sep 22 '22 04:09

Employed Russian