swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Trying gdb under MS Windows


From: Paul Johnson
Subject: Trying gdb under MS Windows
Date: Wed, 16 May 2001 16:28:00 -0500

If anybody uses gdb under windows, would you mind please trapping some
output from a good session so I can see what you do to find what you
need?  I find it very frustrating.

I have a program that works fine under Linux (as far as I can tell,
anyway, no crashes) but my graduate students who use windows have made
it crash for certain parameter settings. (same values don't crash
Linux).  Under gdb ( the new one from swarm ftp on my winNT system) I
cause the crash, but the back trace is only one line: 

Program received signal SIGSEGV, Segmentation fault.
0x401500 in _i_Citizen__scoutLocationX_Y_Discontent_ (self=Cannot access
memory at address 0x1d
) at Citizen.m:200
200               * newDiscontent = [self findExtremeType: safe X: newx Y: 
newy];
(gdb) bt
#0  0x401500 in _i_Citizen__scoutLocationX_Y_Discontent_ (self=Cannot
access memory at address 0x1d
)
    at Citizen.m:200

Why is the backtrace so short?  Oh, well, it does focus my attention on
a few lines.

Now, I'm able to put a break point at Citizen.m:200 and run again, and I
step until it crashes, then I go back again, step more carefully, until
I get to the agent that causes the crash, and I can't see anything "out
of bounds" about it.

print *self

and similar commands show me what I expect.

(gdb) print *newx
$11 = 20
(gdb) print *newy
$12 = 20
(gdb) print *newDiscontent
$13 = 0.5617977528089888
(gdb) print *self
$14 = {isa = 0x40e6e4, zbits = 168679464, movement = 1 '\001', 
  seekLeastProt = 1 '\001', x = 20, y = 20, xlag = 20, ylag = 20, 
  citizenType = 0, age = 0, worldXSize = 40, worldYSize = 40, 
  periodsProtesting = 0, protesting = 1, protestinglag1 = 0, radius = 0, 
  discontentHere = 0.5617977528089888, joinFactor = 0, aRebConst = 0, 
  bRebCoeff = 0, realRebellion = 0, positionGrid = 0xa0f8f80, 
  nhoodProtestValueGrid = 0xa0f79f0}
(gdb) s
objc_msg_lookup (receiver=0xa141ed0, op=0x40c2fc)
    at /src/Swarm/swarm/libobjc/sendmsg.c:143
143     /src/Swarm/swarm/libobjc/sendmsg.c: No such file or directory.
(gdb) s
145     in /src/Swarm/swarm/libobjc/sendmsg.c
(gdb) n
147     in /src/Swarm/swarm/libobjc/sendmsg.c
(gdb) n
0x641ca815      170     in /src/Swarm/swarm/libobjc/sendmsg.c
(gdb) n

Program received signal SIGSEGV, Segmentation fault.
0x401500 in _i_Citizen__scoutLocationX_Y_Discontent_ (self=Cannot access
memory at address 0x1d
) at Citizen.m:200
200               * newDiscontent = [self findExtremeType: safe X: newx Y: 
newy];


I'm pretty sure this is happening because I have misused a local
variable, or a pointer to it, by passing it across methods. But I don't
know how else to return values, except by reference.  Is there something
inherently wrong in a chain like this: 

The agent has position ivars x and y.

-step {
   int newx, newy;
   double newDiscontent;
    //this collects a "candidate" location newx,newy, and notes
conditions there.
   [moved = scoutLocationX: &newx Y: &newy Discontent: &newDiscontent];

   if (moved == YES) { blah blah blah....}
}



-(BOOL) scoutLocationX: (int *) newx Y: (int *) newy Discontent:
(double*) newDiscontent 
{
  BOOL foundNewLocation = NO;
  if (discontentHere >0)
   {
          //go to place with lower discontent than here
          *newDiscontent = [self findExtremeType: safe X: newx Y: newy];
          if (*newDiscontent < discontentHere)
            {
              foundNewLocation = YES;
            }
    }
   return foundNewLocation;
}

and findExtremeType uses those same pointers:
- (double) findExtremeType: (ExtremeType) type X: (int *) px Y: (int *)
py

I thought this was OK because the scope is still in the step method when
scoutLocation and findExtremeType are called.  Maybe not:)

-- 
Paul E. Johnson                       email: address@hidden
Dept. of Political Science            http://lark.cc.ukans.edu/~pauljohn
University of Kansas                  Office: (785) 864-9086
Lawrence, Kansas 66045                FAX: (785) 864-5700

                  ==================================
   Swarm-Support is for discussion of the technical details of the day
   to day usage of Swarm.  For list administration needs (esp.
   [un]subscribing), please send a message to <address@hidden>
   with "help" in the body of the message.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]