public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* DWARF2 Debugging Information
@ 2003-01-02 21:33 Show-Chung Chu
  0 siblings, 0 replies; only message in thread
From: Show-Chung Chu @ 2003-01-02 21:33 UTC (permalink / raw)
  To: gcc-help

[-- Attachment #1: Type: text/plain, Size: 1204 bytes --]





Hi,

I am trying to test C++ static class variable,  inherited class, and
DWARF2 debugging information. I made a very simple/short programs for
testing purpose.

My compiler version is 3.0.4, and thread model is vxworks.

I had two classes, one is base class named "parent", and the other one is
derived from the base class named "Son".

I followed the VxWorks manual to do all the necessary work to invoke the
constructor of the static variables, and it worked just as  I expected.

The problem I had was if the base class was invoked from the main(), the
constructor of the base  class will run, but it sounded that  the local
variable did not provided the DW_AT_location debugging information, so the
variable never got right updated. (This is happened in parent.c, the local
variable is "i")

All the source file, header file, dump output file, and the ELF DWARF2
image are attached below.

(See attached file: testdwarf2.gcc)(See attached file: son.h)(See attached
file: parent.h)

(See attached file: test2.c)(See attached file: parent.c)(See attached
file: son.c)(See attached file: test.c)(See attached file: test1.c)(See
attached file: __testdwarf2.gcccd.c)

Thank for your help.

S. C. Chu

[-- Attachment #2: testdwarf2.gcc --]
[-- Type: application/octet-stream, Size: 25902 bytes --]

[-- Attachment #3: son.h --]
[-- Type: application/octet-stream, Size: 213 bytes --]

extern int __gxx_personality_v0;
#include "stdio.h"
#include "parent.h"

class Son: public parent
{
  public:
  int yrInSchool;
  //Son(char *, int, int);
  Son(int yrInSchool, parent * p = NULL);
};


[-- Attachment #4: parent.h --]
[-- Type: application/octet-stream, Size: 230 bytes --]

extern int __gxx_personality_v0;
//#ifndef __PARENT
//#define __PARENT
class parent {
 protected:
    char   name[100];
    int age;
 public:
    parent(char [], int);
    //~parent()  { delete [] name;}
};

//#endif

[-- Attachment #5: test2.c --]
[-- Type: application/octet-stream, Size: 305 bytes --]

#include "son.h"
//static Son boy3("John      ", 13, 49);
static Son boy3(49);

static void test_s(parent *&p)
{
   //int i;
   //Son boy("Jone Doe  ", 100, 49);
   //i = boy2.yrInSchool;
   p = &boy3;
}


void test2()
{
  parent * p;
  int  i;

  test_s(p);
  i = boy3.yrInSchool;
}

[-- Attachment #6: parent.c --]
[-- Type: application/octet-stream, Size: 191 bytes --]


#include "parent.h"

parent::parent(char * N, int A) : age(A)
{
  int i;
  for (i = 0; i < 100; i++)
       name[i] = 0;

  for (i = 0; i < 10; i++)
       name[i] = *(N+i);
}


[-- Attachment #7: son.c --]
[-- Type: application/octet-stream, Size: 188 bytes --]

#include "son.h"

//Son::Son(char * N, int A, int Y) :parent(N, A), yrInSchool(Y)
//{
//}

Son::Son(int Y, parent * p) :
      parent("Tom       ", 80),
      yrInSchool(Y)
{
}

[-- Attachment #8: test.c --]
[-- Type: application/octet-stream, Size: 296 bytes --]

#include <string.h>
int __gxx_personality_v0;

#include "parent.h"
void test1();
void test2();

typedef void (*VFP) (void);
extern VFP  __ctors[];
int  main()
{

  VFP *vp = __ctors;
  while (*vp)
      (*vp++)();

  parent adult("Chu       ", 100);
  test1();
  test2();
}


[-- Attachment #9: test1.c --]
[-- Type: application/octet-stream, Size: 305 bytes --]

#include "son.h"
//static Son boy2("Tom       ", 31, 12);
static Son boy2(12);

static void test_s(parent *&p)
{
   //int i;
   //Son boy("Jone Doe  ", 100, 49);
   //i = boy2.yrInSchool;
   p = &boy2;
}


void test1()
{
  parent * p;
  int  i;

  test_s(p);
  i = boy2.yrInSchool;
}

[-- Attachment #10: __testdwarf2.gcccd.c --]
[-- Type: application/octet-stream, Size: 419 bytes --]

	/* _GLOBAL__I__Z5test1v		00010164 */
	/* _GLOBAL__I__Z5test2v		0001048c */

typedef void (*VOIDFUNCPTR) ();
extern VOIDFUNCPTR _ctors[];
VOIDFUNCPTR _ctors[] =
    {
    0
    };
VOIDFUNCPTR __ctors[] =
    {
    (VOIDFUNCPTR)0x00010164,
    (VOIDFUNCPTR)0x0001048c,
    0
    };
extern VOIDFUNCPTR _dtors[];
VOIDFUNCPTR _dtors[] =
    {
    0
    };
VOIDFUNCPTR __dtors[] =
    {
    0
    };

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-01-02 21:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-02 21:33 DWARF2 Debugging Information Show-Chung Chu

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).