🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Joe Wells Thu, 17 Dec 1992 00:13
problems debugging structs passed as parameters with GDB 4.6
#567
Author: Joe Wells
Date: Thu, 17 Dec 1992 00:13
56 lines
1828 bytes
I am having problems debugging structs passed as parameters with GDB 4.6.
I am using a Sun 4/280 running SunOS 4.1.1.  I am compiling my code with
GCC 2.2.2.  The main thing is that GDB shows the wrong values for the
struct contents, but there are other anomalies, such as segmentation
faults when I call functions in the program being debugged that take
structs as arguments.  Enclosed below is some trivial test code that
triggers the problem.

Is this a known problem?  I've looked in both the GDB and GCC source
distributions to see if it is documented.  Is there a workaround?  Is this
an incompatibility with GCC 2.2.2?  Help!

If you reply to this message, please send a copy to my address by e-mail.

-- 
Desperately yours,

Joe Wells <jbw@cs.bu.edu>
Member of the League for Programming Freedom --- send e-mail for details
----------------------------------------------------------------------
typedef struct {unsigned char _[8];} ID;
struct foo {
  long a;
  long b;
};

bar (struct foo y)
{
  printf ("%ld,%ld\n", y.a,y.b);
}

baz (ID w)
{
  int i;
  for (i = 0; i < 8; i++)
    printf ("%c\n", w._[i]);
}

main ()
{
  struct foo x;
  ID z;
  x.a = 1;
  x.b = 2;
  z._[0]='a';
  z._[1]='b';
  z._[2]='c';
  z._[3]='d';
  z._[4]='e';
  z._[5]='f';
  z._[6]='g';
  z._[7]='h';
  bar (x);
  baz (z);
}
----------------------------------------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads