Printing problems in gdb

S

sunil.vvn

Hi,
I am facing certain problems when I want to view the data
from variables or objcets. If i am trying to view the objects or
characters, sometimes it is showing adresses and some times it is
showing null adress like 0x0 .

Example is given below

297 strncpy( itemData, dataString, dataLen);
(gdb) n
298 return WCO_OK;
(gdb) p itemData
$12 = 0x0
(gdb) ptype itemData
type = char *

But the data is there in those variables. How to avoid
this situation ,if anybody knows or knows any soft book or any
site ,plese mail back to me.

Thanks in Advance
Sunil
 
P

p_cricket_guy

Hi,
I am facing certain problems when I want to view the data
from variables or objcets. If i am trying to view the objects or
characters, sometimes it is showing adresses and some times it is
showing null adress like 0x0 .

Example is given below

297 strncpy( itemData, dataString, dataLen);
(gdb) n
298 return WCO_OK;
(gdb) p itemData
$12 = 0x0
(gdb) ptype itemData
type = char *

But the data is there in those variables. How to avoid
this situation ,if anybody knows or knows any soft book or any
site ,plese mail back to me.

1. Please post to appropriate group. GDB is offtopic here.
2. Google "GDB" and you will get lots of information.
3. itemData could indeed be 0x0. If not, there are lots of
things to consider including how you compiled your program,
how was your gdb configured and what is your operating
system.
 
J

Jens Thoms Toerring

I am facing certain problems when I want to view the data
from variables or objcets. If i am trying to view the objects or
characters, sometimes it is showing adresses and some times it is
showing null adress like 0x0 .
Example is given below
297 strncpy( itemData, dataString, dataLen);
(gdb) n
298 return WCO_OK;
(gdb) p itemData
$12 = 0x0
(gdb) ptype itemData
type = char *
But the data is there in those variables. How to avoid
this situation ,if anybody knows or knows any soft book or any
site ,plese mail back to me.

That's not really a question about C so it's a bit off-topic here.
You perhaps better ask such questions in a newsgroup dedicated to
discussions about the GNU compiler tools like gnu.gcc.help.

<OT>
Did you compile with optimization disabled, i.e. with '-O0' (that's
an uppercase letter O, followed by the number 0)? Optimization can
rearrange code, lead to data stored in CPU registers, even optimizing
out some of the variables etc. which then makes the output of the de-
bugger look rather strange.
</OT>
Regards, Jens
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top