Gdb with emacs tips

I recently switched to gdb-emacs integration, and that's cool, since you no longer need a source code list every time, although I missed a few functions or maybe I don't know how to make them?

I use emacs in command line mode emacs -nw because I don’t like being away from the console.

  • Now, when I execute some say c1 command under gdb and then want to execute it again, I think I can access my previous command using the up-arrow key. Instead it lifts me up. In x-window emacs mode, this can be done using ctrl+up-arrow . but not in this case.

  • The section in which the source code is displayed may be editable, I do not want this to be so, can I?

  • How to switch between two divided sections?

I usually use vi , so they are not intuitive for me, as they can, to emacs users;).

thanks.

+4
source share
2 answers

1 / Now when I execute the command, say c1 under gdb, and then want to re-execute this, I think I can access my previous one using the up arrow key. Instead it lifts me up. In emacs x-window, this can be done with Ctrl + up arrow. but not in this case.

In my case, it works using C-up even when running emacs with -nw . You may have problems with your key bindings at the emacs level or at the terminal level. Do Ch k C-up to check if the C-up is actually associated with pressing the Control and Up keys simultaneously.

2 / The section in which the source code is displayed becomes editable, I do not want this to be so, right?

Go to the window containing the source code using Cx o . You can then make the buffer read-only by pressing Cx Cq .

3 / How to switch between two divided sections?

If you mean “window”, you can change the currently active GDB GUI window using Cx o . Or you can use windmove by adding the following line to your .emacs:

 (windmove-default-keybindings) 

You can then move the point between the windows using S-right S-left S-up and S-down

+7
source

Now when I execute a command, say c1 under gdb, and then want to re-execute this, I think I can access my previous one using the up arrow key. Instead it lifts me up. In emacs x-window, this can be done with Ctrl + up arrow. but not in this case .ctrl + up arrow. but not in this case.

Try Alt-P and Alt-N to execute the cyclic commands that you already inserted. Hope this works for you :) One Alt-P should return the last command you typed. This is not only used in GDB mode, but also in many places in emacs, and it should work in most console configurations, even those in which ctrl-up does not work. For example, if you press Alt-X to write a command (for example, gdb), you can press Alt-P to re-enter the command you put the last time you used Alt-X.

The section in which the source code is displayed becomes editable, I do not want this to be so, right? I don't want this to be so, do I?

Automatically? As far as I know (but I'm not an emacs expert), very few. Emacs has hooks or lisp functions that you can define to call in some cases. For example, there is a hook for C-mode that will be called when c-mode is used (when you open the .c file if you are not familiar with the modes), and you can configure your C-programming settings there (for example, the indent type, which you want to use). Unfortunately, there are not many hooks in GDB mode (the so-called GUD), and none of the interceptors in this mode will work for you. There is a general trick to visiting a file (when it is open), but it is quite common.

Manually, the answer kindly provided by Jerome will work.

Sorry for my pretty bad english.

+1
source

All Articles