Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Some GDB peculiarities

This thread is locked; no one can reply to it. rss feed Print
Some GDB peculiarities
weapon_S
Member #7,859
October 2006
avatar

Care to help me out? Thanks in advance.
I compiled with -gstabs+. I have a std::list, but when I I try call mylist.size(), gdb says: cannot resolve methode "list::size()" to any overloaded instance.
Also my code checks for errno being set. Somewhere it turns into 34 (ERANGE), but I can't access the errno variable. (No symbol "errno" in current context). I've tried *__errno_location.

Thomas Fjellstrom
Member #476
June 2000
avatar

as for errno, try including errno.h or for c++, cerrno. its a libc thing. not sure about the std::list thing. but have you actually included std::list's header?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

weapon_S
Member #7,859
October 2006
avatar

Ok, I tried including <cerrno>, but it still gives the same message. Thus I just dropped some johnny = &errno in. And now it appears it is becoming ERANGE inside a call to rotated_sprite. :-/ I've also tried to switch to the upmost frame.
The std::list is tracing fine. I can step into the functions and everything. I'm however incapable of calling the function.

So time to install and link to a debug version of allegro, I guess...

ReyBrujo
Moderator
January 2001
avatar

Try to compile with -ggdb3 instead. I am not sure you can call templates themselves, since they don't exist, they just turn into compile code (it is not as if you are calling a function).

As for the errno number, just check the code to see which numbers you are passing to the function :P

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Thomas Fjellstrom
Member #476
June 2000
avatar

ReyBrujo said:

Try to compile with -ggdb3 instead. I am not sure you can call templates themselves, since they don't exist, they just turn into compile code (it is not as if you are calling a function).

He's calling the size method on a std::list variable he has going. It should be working, I'm not sure why it isn't.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

ReyBrujo
Moderator
January 2001
avatar

As far as I know, size() is inlined, so you can't call it.

(Edited:

#include <list>

int main() {
    std::list<int>i;

    i.push_back(1);
    i.push_back(2);
    i.push_back(3);

    return 0;
}

gives

reybrujo@ansalon:~$ gdb test
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i486-linux-gnu"...
(gdb) b main 
Breakpoint 1 at 0x8048607: file test.cc, line 4.
(gdb) r
Starting program: /home/reybrujo/test 

Breakpoint 1, main () at test.cc:4
4	    std::list<int>i;
(gdb) n
6	    i.push_back(1);
(gdb) 
7	    i.push_back(2);
(gdb) p i.size
Cannot take address of method size.
(gdb) p i.size()
Cannot evaluate function -- may be inlined
(gdb) 

I remember having wondered once why I couldn't access template members)

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

Thomas Fjellstrom
Member #476
June 2000
avatar

Oh.. Doh. I totally misread the problem. Again. Yeah, thats the reason its not working.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

weapon_S
Member #7,859
October 2006
avatar

My current gcc version supports -ggdb3, but my gdb version barfs on it.

ReyBrujo said:

just check the code to see which numbers you are passing to the function

I did :P
Couldn't I override the inline, by defining a function pointer? The problem is, I haven't got the foggiest about the signature... Time for the STL refernce.

Thomas Fjellstrom
Member #476
June 2000
avatar

weapon_S said:

Couldn't I override the inline, by defining a function pointer?

You can recompile your code to not do ANY inlining. Otherwise no you can't override it in gdb as its basically copy+paste'ed into the surrounding code. There is no function once it's been inlined.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Go to: