David Douthitt wrote:
> 
> Matt Schalit wrote:
> 
> > Ok.  Now I'll run the program again, and
> > then step through the functions in send_ping()
> > with a while loop.  The numbers are the line
> > numbers in gatping.c.
> >
> > ----------------------------------------------------------------
> > (gdb) run
> > Starting program: /tmp/gatping
> > warning: Unable to find dynamic linker breakpoint function.
> > warning: GDB will be unable to debug shared library initializers
> > warning: and track explicitly loaded dynamic code.
> >
> > Breakpoint 1, send_ping (s=5, h=0x804a958) at gatping.c:161
> > Source file is more recent than executable.
> > 161             /* gettimeofday ( &h->last_send_time, &tz )     ; */
> > (gdb) while 1
> >  > step
> >  > end
> 
> > 179                     printf ( "Problem with ping - returned %d\n",n )  ;
> > 182
> > 185
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x17f0c4 in   ()
> > Single stepping until exit from function __libc_free,
> > which has no line number information.
> >
> > Program terminated with signal SIGSEGV, Segmentation fault.
> > The program no longer exists.
> > The program is not being run.
> > (gdb)
> > ----------------------------------------------------------------------------
> >
> > So I'm figuring something with the printf(), because there
> > ain't no printf'ing going on that I see.
> 
> However, you didn't mention lines 182 and 185; for these lines I get:
> 
> 182             if ( n < 0 || n != ping_pkt_size )
> 185             free ( buffer ) ;




No, I didn't include those because gdb did not output
those lines.  Notice that my gdb warns:
  warning: Unable to find dynamic linker breakpoint function.
  warning: GDB will be unable to debug shared library initializers
  warning: and track explicitly loaded dynamic code.



There's also something wrong with the coordination
of my gatping and my gatping.c.

There's something wrong with elvis, when I open gatping.c
At line 177 and 178, all hell breaks loose.  It's the damned
oddest thing I've ever seen.

  e3 can display gatping.c correctly
  vi on UnixWare 7 displays gatping.c correctly.
  gatping.c is 312 lines long.
  line 177 is --->      sizeof ( struct sockaddr_in ) ) ;
  line 178 is --->      if ( n < 0 || n != ping_pkt_size )
  elvis may or may not agree with the numbering.
  elivs may shift the lines by one.
  elivs has SERIOUS problems understanding line 178.
  If one uses the 'l' key to move the cursor to the right
     along the line 178, the cursor jumps and does not move
     accross all the characters!
  If one deletes the first tab character at the beginnning of
     line 178, a duplicate of line 177 appears in it's place.
  gdb also prints out the wrong

I'm going nuts here.  This is Oxygen-090601, with elvis 1.4-1.





> Here's a debugging session:

On what operating system?


 
> Script started on Wed Oct 31 09:53:02 2001
> # gdb ./gatping
> GNU gdb 19991004
> Copyright 1998 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you
> are
> welcome to change it and/or distribute copies of it under certain
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for
> details.
> This GDB was configured as "i386-redhat-linux"...
> (gdb) break send_ping
> Breakpoint 1 at 0x8048878: file gatping.c, line 161.
> (gdb) r
> Starting program:
> /pub/oxygen/src/net/gatping/EchoWare_0.46/gatping_0.2/./gatping
> 
> Breakpoint 1, send_ping (s=5, h=0x804ac58) at gatping.c:161
> 161             buffer = ( char * ) malloc ( ( size_t ) ping_pkt_size )


I don't get these line numbers in any editor :)
161 is not the buffer statement.  It's  comment.
        /* gettimeofday ( &h->last_send_time, &tz )     ; */



You're source code must be different or something.
None of you line numbers match mine on any OS in any editor.




 ;
> (gdb) n
> 162             memset ( buffer, 0, ping_pkt_size * sizeof ( char ) )
> ;
> (gdb) p buffer
> $1 = 0x804a398 "P\235\020@P\235\020@\020"
> (gdb) n
> 166             icp->icmp_type = ICMP_ECHO      ;
> (gdb) p buffer
> $2 = 0x804a398 ""
> (gdb) n
> 167             icp->icmp_code = 0              ;
> (gdb) n
> 168             icp->icmp_cksum = 0             ;
> (gdb) n
> 169             icp->icmp_seq = 1               ;
> (gdb) n
> 170             icp->icmp_id = ident            ;
> (gdb) n
> 173             gettimeofday (&pdp->ping_ts, &tz )      ;
> (gdb) n
> 174             pdp->ping_count = 1             ;
> (gdb) n
> 175             icp->icmp_cksum = ( in_cksum ( ( u_short * ) icp,
> ping_pkt_size ) ) ;
> (gdb) n
> 179             n = sendto ( mysock , buffer, ping_pkt_size, 0,
> (gdb) p buffer
> $3 = 0x804a398 "\b"
> (gdb) n
> 182             if ( n < 0 || n != ping_pkt_size )
> (gdb) p n
> $4 = 8
> (gdb) p ping_pkt_size
> $5 = 8
> (gdb) n
> 185             free ( buffer ) ;
> (gdb) p buffer
> $6 = 0x804a398 "\b"
> (gdb) n
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x400750c4 in chunk_free (ar_ptr=0x40109d40, p=0x804a390) at
> malloc.c:3100
> 3100    malloc.c: No such file or directory.
> (gdb) quit
> The program is running.  Exit anyway? (y or n) y
> # exit
> 
> Script done on Wed Oct 31 09:54:22 2001
> 
> Looks to me like the call to free(3) is failing, but I can't see why.
> Buffer is char * and is allocated up above, and doesn't seem to be
> free'd elsewhere.



Ok.  I don't think I can help much.  I don't have the right 
gatping.c apparently.  I just used the one Scott sent.
Matt

_______________________________________________
Leaf-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/leaf-devel

Reply via email to