[OT - gdb-specific] Re: Print variable with gdb??

From: Anthony Borla (ajborla_at_bigpond.com)
Date: 03/30/05


Date: Wed, 30 Mar 2005 00:01:55 GMT


"JS" <d44sf@44ada.com> wrote in message
news:d2ck1b$kol$1@news.net.uni-c.dk...
> I have:
>
> int p = 5;
>
> when I debug my code I would like to get a print of p's
> value therefore I start gdb and type:
>
> print p
>
> but then I get an error that the variable does not exists!
>
> Hope someone can help!
>

Things to check:

* Compiled with -g switch

* Correct file name [correct case, and extension if any]
   specified e.g. gdb myFile.exe, and file is loaded i.e. the
   preamble display appears

* Symbol file has been loaded i.e. it has not been been
   deleted [should say so on preamble display]

* Set breakpoint at 'main' e.g. after loading file, issue:

       break main

   command

* In 'stepping through' the executable you are currently
   in a context in which 'i' exists i.e. it is in scope

You may wish to access the 'man' page documention ['man gdb'], or the 'help'
command within gdb, or perhaps search for a gdb tutorial, for more
information

I hope this helps.

Anthony Borla



Relevant Pages

  • kgdb cleanups
    ... -platforms with the kgdb option may behave in a similar fashion. ... the thread info command and gdb now seems to ask when needed. ... -#define COMMA, ...
    (Linux-Kernel)
  • [UNIX] Lukemftpd (Tnftpd) Multiple Vulnerabilities May Lead To Remote Code Execution
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... structure tab to indicate if it's acceptable for a command to occur in OOB ... delivering of ABOR and STAT commands in OOB mode. ...
    (Securiteam)
  • Re: Remote Flashing w/ Window Client & OpenOCD
    ... Telnet interface is not as easy as GDB. ... the remote client dumps into the target memory directly. ... is trigger a copy from memory to flash. ... a write command as well as a erase command. ...
    (comp.arch.embedded)
  • Re: [Kgdb-bugreport] [KGDB PATCH][1/7] Add / use kernel/Kconfig.kgdb
    ... Jim Houston wrote: ... >>command to do a better job of displaying the threads. ... >>Gdb would work as it does now if the following set is not done. ... It does require that we implement a new command in the stub, or rather, that we ...
    (Linux-Kernel)
  • NFS locking hangs a process in D state
    ... Recently, I tried to use the visudo command from the sudo port, and the ... GNU gdb 6.1.1 ... There is absolutely no warranty for GDB. ... something significant (network failures, machines rebooting) happening ...
    (comp.unix.bsd.freebsd.misc)