Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Emacs-Gdb

0 views
Skip to first unread message

Martin Guerrero

unread,
Jul 11, 1996, 3:00:00 AM7/11/96
to

Hi fellow cs240a students. Anyway, I might as well share with you a
useful tip regarding debugging.

Some of you are probably dealing with gdb. As you know, a very useful
command in gdb is "list" where you can see where you are in the code. But
sometimes, you may wish you had a better debugger, where you can
see more of the code and follow the code more easily as you step and
next.

Well, there is another option you can use -- an option where you can
see where you are in the code without having to type "list" all the time.
The debugger follows you along as you "step" and "next".

This can be achieved by using GDB in conjunction with emacs. Emacs
will be split into two screens -- the top one will contain the regular
GDB interactive session, while the bottom, you'll see something like this:

===========================================
int main(int argc, char **argv)
{
=>gMachine = new HardWare();

NACHOS_main(argc, argv);

delete gMachine;
===========================================

Yes! That is a pointer to where you are in the code! When you do a
"next" in the interactive GDB window, you will then see:

===========================================
int main(int argc, char **argv)
{
gMachine = new HardWare();

=>NACHOS_main(argc, argv);

delete gMachine;
===========================================

Try it out!

How do you use it? Well, try this for example:

1) bring up emacs
2) M-x gdb
3) The bottom line of emacs will ask you:
Run gdb (like this): gdb
Type in any argument you want. In this case "nachos"
4) You will see ONE window with the GDB interactive session.
5) break main
6) Now get ready for this:
run -prob2

So what should you see now? You should see TWO windows, the top
was your GDB session, while the bottom is your source code! Whenever
you run a next or a step, it should follow along even if your source code
is in a different file.

Some useful commands in this mode:
----------------------------------
Ctrl-X o ==> Toggles between top screen and bottom screen
This means you can browse your code or
other files during a GDB session.
Ctrl-X <space> ==> Puts a breakpoint in the source file!

Anyway, I believe that should be enough to get you started.
I hope this note will encourage other people to share useful things they've
found, or perhaps tips which will help people.

Regards,
Martin


0 new messages