473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

about the print command in gdb.

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.

Regards
Sunil

Dec 19 '06 #1
1 1588
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.

Dec 19 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

54
by: Brandon J. Van Every | last post by:
I'm realizing I didn't frame my question well. What's ***TOTALLY COMPELLING*** about Ruby over Python? What makes you jump up in your chair and scream "Wow! Ruby has *that*? That is SO...
6
by: Doug Mitchell | last post by:
Dear Group, My son who is in grade 7 has *just* started going through the book "Python for the Absolute Beginner" by Michael Dawson. He and I have no programming experience. He is beginning this...
6
by: Robin Siebler | last post by:
I have a bunch of command line tests that I need to automate. I've run into too many bugs with the default Win2k command shell, so I need to either purchase 4NT or handle the logic and output...
1
by: Xin Wang | last post by:
Some c++ guru said c++ is hard to learn but easy to use. Is python easy for both aspect? I found lot's of confused in coding. #code from Tkinter import * def on_click(m): print m def...
15
by: Thelma Lubkin | last post by:
formA determines some_where and some_value and issues docmd.close ,Me docmd.openform "formB", , ,some_where, , ,some_value formB receives the correct some_where and some_value After...
9
by: allenjo5 | last post by:
Here's a code snippet: i = 0 while (i < 20): i = i + 1 (shellIn, shellOut) = os.popen4("/bin/sh -c ':'") # for testing, the spawned shell does nothing print 'next' # for line in shellOut:...
3
by: Ara Kooser | last post by:
Hello all, I hope I am posting this correctly. I am running Python 2.4.2 on Slackware 11.0 using IDLE. I am in the process of learning python so I am writing a text adventure game using...
6
by: happy | last post by:
you can take a look for this web sites http://www.imanway.com/vb/forumdisplay.php?f=90 http://www.geocities.com/islamone_l/index.htm or read this ...
6
tdw
by: tdw | last post by:
the View Orders form in my Access database has a Print button on it. It has other buttons too, like Edit etc. These buttons used to be at the bottom of the form laid out horizontally, but this was...
10
by: Prisoner at War | last post by:
Hi, your friendly neighborhood n00b here, just wondering why on earth the Py3K folks want to mess with a simple thing like the "print" "command" (is that what it's called, a command?), turning it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.