2

This starts partially from why doesn't gdb like aliases

Now I put the following arguments -

gdb firefox-esr
(gdb) set logging file my-firefox-esr-1802018.log
(gdb) set pagination 0
(gdb) show logging 
Future logs will be written to firefox-esr-020818.log.
Logs will be appended to the log file.
Output will be logged and displayed.
(gdb) run --safe-mode

when it crashed I did -

(gdb) bt
(gdb) thread apply all bt

When it finished showing all the threads and the outputs therein I put

(gdb) quit

But now when I am in /home/shirish I don't see that log file. Should I have given the whole path ?

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
shirish
  • 12,356

2 Answers2

3

By default the directive set logging file in gdb will write to the current directory.

So, in your example, the log file would be written to the directory where firefox-esr is located, if the user being used has write rights on that directory.

So the answer is yes, to write the log file in your home directory, you have to give the whole path to set logging file.

See gdb backtrace to file for an interesting hack to accomplish your actions:

alias bt='echo 0 | gdb -batch-silent -ex "run" -ex "set logging overwrite on" -ex "set logging file gdb.bt" -ex "set logging on" -ex "set pagination off" -ex "handle SIG33 pass nostop noprint" -ex "echo backtrace:\n" -ex "backtrace full" -ex "echo \n\nregisters:\n" -ex "info registers" -ex "echo \n\ncurrent instructions:\n" -ex "x/16i \$pc" -ex "echo \n\nthreads backtrace:\n" -ex "thread apply all backtrace" -ex "set logging off" -ex "quit" --args'

bt $crashing_application

See also Backtraces with Gentoo

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
0

The gdb.txt or custom-log-file file will not be created in pwd always, by gdb. It has to be explicitly specified by executing command 'set logging on' in gdb terminal. Only then the output will be logged.

Phani
  • 1
  • 1