1

I don't use emacs, but I know xemacs can be used as a front-end for gdb (used it before). However, my code is cross-compiled, so I can't run gdb, I have to run a specific version of gdb that's for the cross-compiled code (let's call it gdb-foo). How do I set xemacs up to run the alternate gdb?

When I use M-x, gdb I get the prompt:

Run gdb on file:

I remember seeing something like this:

Run gdb like this:

But I don't know how to get that.

Next, once I learn how to do it this way, how can I do it as a one-liner I can run from bash, including gdb-foo and attach options? (I know bash scripting; I just need the incantation for xemacs.)

Jeff Learman
  • 2,914
  • 1
  • 22
  • 31

1 Answers1

1

The idea is to change gdb executable. Let's see how to retrieve this kind of information using emacs.

Under emacs, you can do C-h f gdb to print gdb function help:

gdb is an interactive autoloaded compiled Lisp function in
‘gdb-mi.el’.

It is bound to <menu-bar> <tools> <gdb>.... etc.

Then click on gdb-mi.el to go to the lisp source. From there you can search for "executable" (C-s executable, then C-s for next occurrence). You will find this customizable variable:

(defcustom gud-gdb-command-name "gdb -i=mi"
  "Default command to execute an executable under the GDB debugger."
  :type 'string
  :group 'gdb)

And that's it! You have all the information you need.

Now to effectively change gdb to gdb-foo, run the customize command: M-x customize. Then type "gud-gdb-command-name" in the search field + return. You should get something like:

gud-gdb-command-name                              Search 

Operate on all settings in this buffer:
 Revert...   Apply   Apply and Save 

Hide Gud Gdb Command Name: gdb -i=mi      <---- MODIFY ME!
    State : STANDARD.
   Default command to execute an executable under the GDB debugger.
Groups: Gdb

You can modify "gdb -i=mi" to "gdb-foo -i=mi" then "Apply" or "Apply and Save".

Picaud Vincent
  • 10,518
  • 5
  • 31
  • 70
  • Thanks! but I get `\`gdb' is an interactive autoloaded Lisp function -- autoloads from "gdb"` and clicking on `gdb` does nothing; double-clicking it just sets a mark. I'm running `XEmacs 21.4 (patch 22) "Instant Classic" [Lucid] (x86_64-linux-gnu, Mule) of Mon Nov 4 2013 on toyol` – Jeff Learman Feb 08 '18 at 19:03
  • 1
    And jumping directly to "M-x customize", then "gud-gdb-command-name " in the search field? (my idea was to describe all the steps I used to get the solution I proposed) – Picaud Vincent Feb 08 '18 at 19:47
  • 1
    However, you only have to customize the "gud-gdb-command-name" variable (at least with my Emacs version 25.5, not sure if my proposal is still ok with your version) – Picaud Vincent Feb 08 '18 at 19:49
  • I've been busy with other things. I originally tried what you suggest and it led nowhere, but I need to post back with specifics. I believe it's a version difference issue, plus general emacs ignorance on my part. – Jeff Learman Feb 09 '18 at 16:33
  • I hope I am not orientating you in a wrong direction, however I think it is the right way (customization of the `gud-gdb-command-name` variable). Thanks for the feedback. – Picaud Vincent Feb 09 '18 at 16:44