CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Gdb newbie question about printing strings out and confusion about Word bs (https://www.cfd-online.com/Forums/openfoam-solving/60030-gdb-newbie-question-about-printing-strings-out-confusion-about-word-bs.html)

unoder September 3, 2006 21:17

Hi, I'm currently into file
 
Hi,

I'm currently into fileName.C - line 142:

////////////////////////////////////

// Return the components of the file name as a wordList
wordList fileName::components(const char delimiter) const
{
wordList wrdList(20);

size_type start=0, end=0;
label nWords=0;

while ((end = find(delimiter, start)) != npos)
{
wrdList[nWords++] = substr(start, end-start);

if (nWords == wrdList.size()) <--- THIS is where program execution stopped

////////////////////////////////////


Am I right that a wordlist has something to do with a UList or something?


I have a backtrace like this:

(gdb) bt
#0 Foam::fileName::components (this=0xbfd77774, delimiter=47 '/') at primitives/strings/fileName/fileName.C:142
#1 0xb76184be in argList (this=0xbfd787c8, argc=@0xbfd78a90, argv=@0xbfd78a94) at global/argList/argList.C:96
#2 0x0805bf5a in main (argc=Cannot access memory at address 0x0
) at setRootCase.H:1

Now, I would like to see what's inside the first position of the wordList - it's a substring, so it must be some kind of string, right?:

(gdb) p nWords
$10 = 1
(gdb) p wrdList[0]
$11 = (const Foam::word &) @0x80cdda4: {<foam::string> = {<std::basic_string<char,std::char_traits<char>,st d::allocator<char> >> = {
static npos = 4294967295, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<no>}, <no>},
_M_p = 0xb75015bc ""}}, static debug = 0, static null = {<std::basic_string<char,std::char_traits<char>,st d::allocator<char> >> = {
static npos = 4294967295, _M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<no>}, <no>},
_M_p = 0xb75015bc ""}}, static debug = 0, static null = <same>}}, static debug = 2,
static null = {<foam::string> = {<std::basic_string<char,std::char_traits<char>,st d::allocator<char> >> = {static npos = 4294967295,
_M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<no>}, <no>}, _M_p = 0xb75015bc ""}},
static debug = 0, static null = {<std::basic_string<char,std::char_traits<char>,st d::allocator<char> >> = {static npos = 4294967295,
_M_dataplus = {<std::allocator<char>> = {<__gnu_cxx::new_allocator<char>> = {<no>}, <no>}, _M_p = 0xb75015bc ""}},
static debug = 0, static null = <same>}}, static debug = 2,
static null = <same>}}
(gdb)

I don't understand this output.... The index should be 0, because nWords was just incremented and confirmed to be 1. Any help?


Reason for asking: I noticed that the list of arguments seem to be split up and stored in a wordList... It is *really* bugging me that I can't just type:

(gdb) p wrdList (enter)

... In order to see the individual list of words. Yet, I think it must be possible to access the list of words by pointers or something...

So I guess I have to figure out how to access the string using pointers or something....? Okay, all tips and tricks for using gdb are welcome.



///////////// Another derived question ///////////

I tried where gdb wrote something about "no line number information available" <---> IIRC. That was yesterday, when I think I debugged into something inside ~/OpenFOAM/OpenFOAM-1.3/src/finiteVolume

That was actually a very interesting place to look and find information about the mesh (I assume), etc - so I would really like to be able to debug into that code... Any suggestions for me about where to set my breakpoint to learn about how it reads the mesh-information?

And what the cause of this "no line information"-error? Was I step'ping into some /lib/???.so file or was something not compiled with debug information included?


All times are GMT -4. The time now is 08:32.