🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gdb.bug
Article #864

structure return/passing

#864
From: Thomas M. Breuel
Date: Mon, 26 Feb 1990 21:18
51 lines
2213 bytes
Does GDB handle structure return/passing correctly when used
interactively? I have a feeling it doesn't... consider the following
transcript:

Script started on Mon Feb 26 16:10:03 1990
lem$ gdb
Reading symbol data from /tmp_mnt/home/vi/tmb/index/index...done.
Reading in symbols for index.c...done.
Breakpoint 1 at 0x3434: file index.c, line 170.

Bpt 1, main () (index.c line 170)
170             generate_models();
(gdb) p rotatev(makev(1.0,0.0),3.14159)

Program received signal 11, Segmentation fault
0x25f0 in rotatev (p={x = 1, y = 0}, a=3.14159) (./geo.h line 23)
23              q.x=p.x*c-p.y*s;
Cannot continue previously requested operation.
Unable to restore previously selected frame.
(gdb) l rotatev
15              return atan2(p.y,p.x); 
16      }
17      
18      vec rotatev(p,a) 
19      vec p; float a;
20      {
21              float s=sin(a),c=cos(a);
22              vec q;
23              q.x=p.x*c-p.y*s;
24              q.y=p.x*s+p.y*c;
(gdb) l makev
1       typedef struct _vec { float x,y; } vec;
2       
3       vec makev(x,y) float x,y; { vec p; p.x=x; p.y=y; return p; }
4       vec addv(p,q) vec p,q; { p.x+=q.x; p.y+=q.y; return p; }
5       vec subv(p,q) vec p,q; { p.x-=q.x; p.y-=q.y; return p; }
6       float normv(p) vec p; { double sqrt(); return sqrt(p.x*p.x+p.y*p.y); }
7       float distancev(p,q) vec p,q; { return normv(subv(p,q)); }
(gdb) p normv(makev(1.0,0.0))

Program received signal 11, Segmentation fault
normv (p={x = 1, y = 0}) (./geo.h line 6)
6       float normv(p) vec p; { double sqrt(); return sqrt(p.x*p.x+p.y*p.y); }
Cannot continue previously requested operation.
Unable to restore previously selected frame.
(gdb) q
The program is running.  Quit anyway? (y or n) y
lem$ 
script done on Mon Feb 26 16:12:30 1990

(This is in GDB 3.5)
Technical Details
Message-ID: <9002262118.AA03600@lem>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!AI.MIT.EDU!tmb

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!AI.MIT.EDU!tmb
From: tmb@AI.MIT.EDU (Thomas M. Breuel)
Newsgroups: gnu.gdb.bug
Subject: structure return/passing
Message-ID: <9002262118.AA03600@lem>
Date: 26 Feb 90 21:18:57 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 51