Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: raynebc on March 05, 2015, 12:12:06 am

Title: structure has no component named c_str
Post by: raynebc on March 05, 2015, 12:12:06 am
I ran into some strange debugger behavior when tracing through my program, when I added an element of an array of structures to the watches, it displayed "structure has no component named c_str" instead of a list of member variables and their values.  I can't tell why this is, when I added an element of a different array of different structures (with similar members) it displayed that structure's contents normally.  Is this a problem with GDB?  With Code::Blocks?  With my programming?

If it makes any difference, the layout of the structure is as follows:
Code
struct bf_string
{
unsigned long long keyid;
unsigned long offset;
char *string;
char encountered;
};

Thanks in advance.
Title: Re: structure has no component named c_str
Post by: oBFusCATed on March 05, 2015, 12:25:28 am
Can you post a minimal sample that can be used to reproduce the problem?
Do you have watch scripts enabled in the debugger's settings?
What version of CB are you using?
Title: Re: structure has no component named c_str
Post by: raynebc on March 05, 2015, 01:28:40 am
I'm afraid I didn't put together a minimal sample, since I couldn't even get it to behave the same for both structure types.  I reproduced this behavior on both the 9-16-14 and 1-17-15 nightly C::B releases.  "Enable watch script" was enabled, but when I disable it and debug my program again, the watches display correctly, so I guess it's a problem with that feature?  The tooltip mentions not to use it with a Python-enabled GDB, but I don't know how to tell if I have such a version of GDB installed.  GDB's help output gives the following:
GNU gdb (GDB) 7.5
...
This GDB was configured as "i686-pc-mingw32".

This GDB version is kind of old, but I'd rather not risk breaking something that's otherwise working just fine if I can avoid it.
Title: Re: structure has no component named c_str
Post by: oBFusCATed on March 05, 2015, 01:29:55 am
Search for gdb python pretty printers.
Title: Re: structure has no component named c_str
Post by: raynebc on March 05, 2015, 01:52:02 am
Is this a problem with MinGW's GDB instead of Code::Blocks then?  I honestly don't know why it would have problems displaying standard data types in a structure.  I also don't know what data type it was having problems with, so I wouldn't know where to begin as far as writing my own printer.  I know this GDB can print long long integer values because it displayed the other structure without problem.  In the end, I'm not customizing GDB in any way so I probably don't lose anything by turning off this feature.  Thank you for the tip.
Title: Re: structure has no component named c_str
Post by: oBFusCATed on March 05, 2015, 09:17:15 am
If you disable "watch scripts" it will just works, but you'll see the raw values (struct members of std::string for example).
And watch scripts are know to fail sometimes.