0

With logging enabled as described here, I am using command to log and continue at a breakpoint as described here.

Full gdb interraction:

$ sudo gdb -p 30560 

(gdb) set logging file myDbg.log
(gdb) set logging on
Copying output to myDbg.log.
(gdb) set trace-commands on
(gdb) set pagination off
(gdb) br __libc_malloc
(gdb) conti

// Once the bp is hit:
(gdb) info stack         << Output for this shows up in myDbg.log 

(gdb) command
+command
Type commands for breakpoint(s) 1, one per line.
End with a line saying just "end".
>info stack
>conti
>end
(gdb) conti

// Now on the console I get:
Continuing.
[Switching to Thread 0x7fff98949700 (LWP 30627)]

Thread 49 "triggerproc" hit Breakpoint 1, 0x00007fffecc05f70 in malloc () from /lib64/libc.so.6
+info stack
#0  0x00007fffecc05f70 in malloc () from /lib64/libc.so.6
#1  0x00007fffed79d18d in operator new(unsigned long) () from /lib64/libstdc++.so.6
...
+conti
[Switching to Thread 0x942e700 (LWP 32191)]

// While the log file only has
Continuing.
[Switching to Thread 0x7fff98949700 (LWP 30627)]

Thread 49 "triggerproc" hit Breakpoint 1, 0x00007fffecc05f70 in malloc () from /lib64/libc.so.6
+info stack
                ** expected to see stack trace here **
+conti
[Switching to Thread 0x942e700 (LWP 32191)]

I don't get the info stack output in the log. If I do info stack outside of command, i.e. regular gdb prompt, its output is written to the log file. How do I get info ... outputs from within command into the log file? Application is a multithreaded C++ running on a CentOS VM, if that matters.

2
  • Works for me. Please show your actual interaction with GDB and the output you get. Commented Feb 29, 2024 at 5:13
  • With same gdb 8.2, this didn't happen on another machine. I will retry on the original machine and update the exact steps. On that machine same problem happened with gdb 12.1 as well. Thanks. Commented Mar 1, 2024 at 22:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.