Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » C / C++ IDE (CDT) » Error displaying array in base class
Error displaying array in base class [message #1728972] Fri, 08 April 2016 18:27 Go to next message
Paul DeRocco is currently offline Paul DeRoccoFriend
Messages: 22
Registered: April 2012
Junior Member
Ubuntu 14.04 LTS
Mars 4.5.2
CDT 8.8.1
GCC 4.9.3
GDB 7.7.1

When I try to view the contents of an array contained in a base class, I get something like

Error: Failed to execute MI command:
-var-create - * "&((*(struct foo*)(this)).bar)"
Error message from debugger back end:
-var-create: unable to create variable object


The expression in quotes looks reasonable, so it doesn't look like Eclipse is asking for the wrong thing. Other members can be viewed okay, including arrays in the derived class. Is it possible that there is a mismatch between CDT and GDB? Or between CDT and GCC? Or between GCC and GDB? I built the GCC 4.9.3 compiler myself, but don't know whether GDB came with CDT or Ubuntu.
Re: Error displaying array in base class [message #1728981 is a reply to message #1728972] Fri, 08 April 2016 20:47 Go to previous messageGo to next message
Marc-André Laperle is currently offline Marc-André LaperleFriend
Messages: 256
Registered: July 2009
Senior Member
Do you have a code snippet that you can share? I think it will make it easier to troubleshoot.
Re: Error displaying array in base class [message #1728989 is a reply to message #1728981] Sat, 09 April 2016 01:30 Go to previous messageGo to next message
Paul DeRocco is currently offline Paul DeRoccoFriend
Messages: 22
Registered: April 2012
Junior Member
The problem only seems to happen within virtual functions, perhaps only on "this":

#include <iostream>

// declare base class with scalar, array and virtual function
struct B {
    int         bs;
    char        ba[100];
    virtual int do_something();
};

// define function non-inline
int B::do_something() {
    return bs;
}

// declare derived class with scalar and array
struct D: B {
    int     ds;
    char    da[100];
};

// instantiate a D
D d;

// invoke virtual function
int main() {
    d.do_something();
    return 0;
}


Step into the virtual function, examine "this", open the B branch, and the ba member will show the error.

Why did I include iostream? Because the problem doesn't happen unless I include a C++ header of some sort.

This problem happens for me in 32-bit or 64-bit code.
Re: Error displaying array in base class [message #1729170 is a reply to message #1728989] Mon, 11 April 2016 17:24 Go to previous messageGo to next message
Marc-André Laperle is currently offline Marc-André LaperleFriend
Messages: 256
Registered: July 2009
Senior Member
I can reproduce the issue with GDB 7.7.1 but it works correctly with GDB 7.9.1.

In case you want to compile your own recent version of GDB, there is this nice script in the CDT repo that builds versions of GDB for you:
http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/tree/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/scripts/download-build-gdb.sh

With this, I was able to quickly test 7.7.1, 7.8, 7.9 even though I have 7.10 installed as part of my Ubuntu 15.10.
Re: Error displaying array in base class [message #1729401 is a reply to message #1729170] Wed, 13 April 2016 19:55 Go to previous message
Paul DeRocco is currently offline Paul DeRoccoFriend
Messages: 22
Registered: April 2012
Junior Member
Well, that was painless. Thanks a million.
Previous Topic:standalone debugger with Mac Os
Next Topic:Breakpoints are not set in remote attach launcher configuration
Goto Forum:
  


Current Time: Mon Sep 23 23:54:43 GMT 2024

Powered by FUDForum. Page generated in 0.02952 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top