2

Sorry for my ignorance but I saw there were a lot questions about .gdbinit file. I just cannot understand what this file brings to me. Seems that it is used for some python script for modern gdb, making the output of gdb more readable.

But what's the exact difference? How can I utilize this file in debugging environment such as Emacs/eclipse CDT?

Hongxu Chen
  • 5,240
  • 2
  • 45
  • 85

2 Answers2

2

Explained here: http://sourceware.org/gdb/current/onlinedocs/gdb/gdbinit-man.html

This is typically used to connect to remote target, configure memory types, etc.

dbrank0
  • 9,026
  • 2
  • 37
  • 55
  • You can write any required gdb commands to this file. And you can use conditions, loops, etc. You could for example put something like "target remote blah.blah.com:1234", "mem 0 0x100000 ro" to connect to remote system... – dbrank0 Jun 27 '13 at 13:37
  • But I saw one of the .gdbinit files containing some words like `python ... from libstdcxx.v6.printers import register_libstdcxx_printers ...`, and without this, gdb would emit a warning(something about not finding needed ) at the startup(http://stackoverflow.com/questions/4985414/enable-pretty-printing-for-gdb-in-eclipse-cdt). Then what's that supposed to be? – Hongxu Chen Jun 27 '13 at 14:12
  • BTW, is there any example/tutorial for this? – Hongxu Chen Jun 27 '13 at 14:12
  • Most of Debugging with gdb (http://sourceware.org/gdb/current/onlinedocs/gdb/index.html) applies. – dbrank0 Jun 27 '13 at 14:29
1

Look for "Next explains usage while debugging in Eclipse" to see how to install and configure .gdbinit file in eclipse.

.gdbinit allows running specific commands which comes in existing once gdb is executed. For example: Following command once specified in .gdbinit which will show assembly in Intel format.

set disassembly-flavor intel

Also gdb macros can be defined as per custom needed.

Here is sample .gdbinit.

Community
  • 1
  • 1
Tectrendz
  • 1,354
  • 2
  • 17
  • 36