Re: about the print command in gdb.



sunil wrote:
Hi,
I am trying to print a variable port using print command , the
port variable is coming as function arguement.See the snippet below.

680 printf("The port number is %d\n",port);
(gdb) p port
$1 = 0
(gdb) n
The port number is 7710
681 while ((stat=listenerSocketFd.Open( port)) != OK &&
triedCount++ < 6 )
(gdb) p port
$2 = 0
(gdb)
The port number is 7710

Why it is showing different value what the actually the
variable is having.But some times it shows the correct value.
Is there any reason,if anybody knows please help me out.

Debuggers are off-topic here. Please post in a gnu/gdb specific or
your OS specific newsgroups.

<OT>
Just a guess: your compiler might have optimized the code. Try
compiling with optimization turned off and then debug.
You can also look into assembly code (you can do that within gdb)
and see how "port" is handled.

.



Relevant Pages

  • [5.1-RELEASE-P10] panics when system loaded
    ... gdb backtrace: ... pci0: <PCI bus> on pcib0 ... <Parallel port bus> on ppc0 ... can't assign resources ...
    (freebsd-hackers)
  • [5.1-RELEASE-P10] panics when system loaded
    ... gdb backtrace: ... pci0: <PCI bus> on pcib0 ... <Parallel port bus> on ppc0 ... can't assign resources ...
    (freebsd-stable)
  • 7.0-CURRENT ppp related panic
    ... GNU gdb 6.1.1 ... Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. ... #8 0xffffffff805c33a1 in trap (frame= ... sio0: type 16550A sio1: configured irq 3 not in bitmap of probed irqs 0 sio1: port may not be enabled ...
    (freebsd-current)
  • kernel panic on 7.0-p6
    ... GNU gdb 6.1.1 [FreeBSD] ... Copyright 2004 Free Software Foundation, ... ppc0: parallel port not found. ...
    (freebsd-stable)
  • RELENG_6_0 core
    ... GNU gdb 6.1.1 ... <Parallel port bus> on ppc0 ... can't assign resources ... WARNING: ...
    (freebsd-hackers)