1

I'm using kgdb to debug something via a serial cable, so I "set remote /dev/ttyS1" in gdb, which gives me output from the remote machine through gdb.

Is there any way to redirect this output to a file WITHOUT redirecting the rest of gdb's output? It won't let me enable TUI, either. I'm using:

set logging file ~/gdb_output.log
set logging overwrite on
set logging redirect on
set logging on

Thanks!

Is both the serial coming in from my target machine and the output from gdb using stdout? What uses stdin, what uses stdoutm and what uses stderr?

12
  • Is there any part of the output strings you would like to have in the file unique that would allow you to use grep? Commented May 5, 2014 at 23:03
  • 1
    What is the output you want to redirect, just the kernel messages (aka dmesg) or also the program output? Is it ok to disable the kernel messages output to the serial instead of "redirecting" them to a file? You could grab them after using the "dmesg" command... Commented May 9, 2014 at 14:47
  • In this case the kernel messages are the program output coming in over serial, and that's what I want to redirect to a file. I want the GDB initiated output (i.e. not printk messages) and gdb print statements, etc, to still be in the main window. Commented May 9, 2014 at 21:13
  • You mean like this answer here: stackoverflow.com/questions/5941158/… ? Commented May 12, 2014 at 0:37
  • @Jordan, how about set logging redirect off? I don't grasp what kind of workflow you're trying to set up (perhaps using screen to record the debugging sessions would work better?), but GDB Manual has pretty good descriptions of the debugging options.. Commented May 12, 2014 at 12:54

1 Answer 1

0

How about using a redirect with run after setting up your remote target.

  1. Start gdb without giving the debug_kernel as input:
  2. Setup your remote connection

    (gdb) set remote /dev/ttyS1

  3. Load the debug kernel file for gdb to start debugging

    (gdb) file debug_kernel

  4. Run and pipe output to a file

    (gdb) run > file_to_save_kgdb_output

Check out this documentation for reference: http://sourceware.org/gdb/onlinedocs/gdb/Input_002fOutput.html

Sign up to request clarification or add additional context in comments.

3 Comments

Where would I run this, on my target machine or host?
I just realized I misunderstood the question. Ignore my last answer
Remote targets don't support the use of "run" though. It's "target remote" not "set remote" isn't it?

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.