public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* problems with list...
@ 2002-09-11 17:29 Craig Maloney
  2003-03-01 16:57 ` Daniel Jacobowitz
  0 siblings, 1 reply; 2+ messages in thread
From: Craig Maloney @ 2002-09-11 17:29 UTC (permalink / raw)
  To: gdb

Hi all.

I've been having problems using list functions inside of gdb.

-----------------------------------
#include <list>
#include <vector>

using namespace std;

main(){
  list<int> l;
  vector<int> v;
  l.push_back(0);
  l.push_back(1);
  v.push_back(0);
  v.push_back(1);

}
--------------------------------------------

if I try:
"p l.size()"

I get a "Cannot evaluate function -- may be inlined"  even if I compile 
with an -fno-inline.
"ptype l" gives something reasonable which shows "size_t size() const;"

None of the same problems with the vector.

Does anyone have any idea why this doesn't work?

Thanks in advance,
Craig

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: problems with list...
  2002-09-11 17:29 problems with list Craig Maloney
@ 2003-03-01 16:57 ` Daniel Jacobowitz
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Jacobowitz @ 2003-03-01 16:57 UTC (permalink / raw)
  To: Craig Maloney; +Cc: gdb

On Wed, Sep 11, 2002 at 05:29:46PM -0700, Craig Maloney wrote:
> Hi all.
> 
> I've been having problems using list functions inside of gdb.
> 
> -----------------------------------
> #include <list>
> #include <vector>
> 
> using namespace std;
> 
> main(){
>  list<int> l;
>  vector<int> v;
>  l.push_back(0);
>  l.push_back(1);
>  v.push_back(0);
>  v.push_back(1);
> 
> }
> --------------------------------------------
> 
> if I try:
> "p l.size()"
> 
> I get a "Cannot evaluate function -- may be inlined"  even if I compile 
> with an -fno-inline.
> "ptype l" gives something reasonable which shows "size_t size() const;"
> 
> None of the same problems with the vector.
> 
> Does anyone have any idea why this doesn't work?

Craig,

Sorry this reply is late - I missed your message.  You've hit a
fundamental problem of debugging C++ templates.  Because
std::list<int>::size() is never called by the program, it is never
instantiated, and thus it doesn't exist for GDB to call it.

On the other hand, I'll bet that the implementation of v.push_back()
references v.size(); that's logical for a vector.

If you include an explicit call to l.size() in the program somewhere,
then GDB calls the method properly.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-03-01 16:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-11 17:29 problems with list Craig Maloney
2003-03-01 16:57 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).