This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: GDB problem


I have tracked down a few problems that cause GDB to bail out,
some related to memory allocation/deallocation. I have (re-)build
i386-cygwin32-gdb.exe and m68000-coff-gdb.exe with these patches applied
which has greatly improved their stability. 

I hope they help.

Regards

Stuart Williams
HP Labs, Bristol

I sent a the patches that we applied to Geof a little while back,
but

Geoffrey Noer wrote:
> 
> J.R. Dean wrote:
> >
> > >My main problem with the gdb in beta 18 is the crash on exit
> > >problem.  I hope it will be fixed in future releases...
> >
> > Oh, so it *is* a bug?  Whoops.
> >
> > Well, so much for debugging with gdb.
> 
> My consistent problem is quitting the tcl/tk gdb (I believe the problem
> is actually in tcl/tk rather than in gdb).  That said, I find the b18 gdb
> to be fairly usable so you may not need to completely abandon using it
> because of this problem.
> 
> --
> Geoffrey Noer
> noer@cygnus.com
> -
> For help on using this list (especially unsubscribing), send a message to
> "gnu-win32-request@cygnus.com" with one line of text: "help".

----------
From:   Stuart Williams[SMTP:skw@hplb.hpl.hp.com]
Sent:   02 June 1997 15:51
To:     'Geoffrey Noer'
Subject:        GDB Problems/Fixs

Geof,

I've been building GNU Win32 to cross develop on 68k from a Win32
platform.
I was pleased to see that GDB has been ported to support the Tk/Tcl UI
under
Win32. We had enormous problems trying to build and use the windows
based 
gdb in the mswin subdirectory. Functionally at least, the Tk/Tcl based
GDB is
a big improvement. 

To get things working properly I had to patch a couple of files. In
gdbtk.c some
of the Tcl_ function calls return dynamically allocated structures that
are then
subsequently free'ed. Unfortunately the allocation happens within the
Tk/Tcl
DLL while the freeing does not. For example, things go bang (well
abort())
at the free in 'gdbtk_query' when it frees 'command'. Try it... if you
do something
that throws a query, gdb.exe (the one in the binary distribution) exits
without 
warning. 'free' calls 'mfree' which in turn checks for magic value
before and after
the allocated memory region. However, they're not there because the
allocation
was done within a call to 'Tcl_Merge'.

I've fixed this by '#ifdef WINNT' around the Tcl_Alloc and Tcl_Free
definitions (I have
no idea how the Tk/Tcl DLL is expected to call them) and #ifdef'd around
the 'free'
calls to substitute Tcl_Free which now resolves through libtcl7.6.a to
the DLL.
Result... no bang.

Later hit a second problem (don't recall the symptom now) that turned
out to be
a SEGV due to chasing a null pointer in 'infcmd.c'. I suspect there are
more of
these to find!

Attached are my gdbtk.c and infcmd.c and corresponding diff files. I
still have an
intermitent and annoying SEGV that occurs when GDB exits under win 95. I
haven't
tracked it down yet, but the report is:

        GDB caused an invalid page fault in
        module CW3215.DLL at 0137:005e3f66.
        Registers:
        EAX=0280fffc CS=0137 EIP=005e3f66 EFLGS=00010203
        EBX=0492fc08 SS=013f ESP=0492fbfc EBP=0492fc28
        ECX=00000001 DS=013f ESI=00000000 FS=3bef
        EDX=00000020 ES=013f EDI=0060002c GS=0000
        Bytes at CS:EIP:
        8b 00 89 43 1c 64 67 a1 00 00 89 03 64 67 89 1e 

Looks like it happens between the 'exit() call and the end of the
program.

Anyway, I hope that you can use these fixes next time around.

Regards

Stuart Williams
HP Labs, Bristol, UK.
*** infcmd.c	Tue May 20 19:00:08 1997
--- infcmd.c.orig	Tue May 20 18:59:04 1997
***************
*** 443,450 ****
  	}
      }
    fixup_symbol_section (sfn, 0);
!   if (sfn!=NULL &&
!       section_is_overlay (SYMBOL_BFD_SECTION (sfn)) && 
        !section_is_mapped (SYMBOL_BFD_SECTION (sfn)))
      {
        if (!query ("WARNING!!!  Destination is in unmapped overlay!  Jump anyway? "))
--- 443,449 ----
  	}
      }
    fixup_symbol_section (sfn, 0);
!   if (section_is_overlay (SYMBOL_BFD_SECTION (sfn)) && 
        !section_is_mapped (SYMBOL_BFD_SECTION (sfn)))
      {
        if (!query ("WARNING!!!  Destination is in unmapped overlay!  Jump anyway? "))

gdbtk.c

*** gdbtk.c	Mon May 19 19:34:53 1997
--- gdbtk.c.orig	Mon May 19 19:22:58 1997
***************
*** 129,135 ****
  
  static char *Gdbtk_Library;
  
- #ifndef WINNT
  /* Supply malloc calls for tcl/tk.  */
  
  char *
--- 129,134 ----
***************
*** 154,161 ****
    free (ptr);
  }
  
- #endif
- 
  static void
  null_routine(arg)
       int arg;
--- 153,158 ----
***************
*** 227,239 ****
    merge[1] = buf;
    command = Tcl_Merge (2, merge);
    Tcl_Eval (interp, command);
- 
- #ifndef WINNT
    free (command);
- #else
-   Tcl_Free (command);
- #endif
- 
  
    val = atol (interp->result);
    return val;
--- 224,230 ----
***************
*** 265,275 ****
    merge[1] = buf;
    command = Tcl_Merge (2, merge);
    Tcl_Eval (interp, command);
- #ifndef WINNT
    free (command);
- #else
-   Tcl_Free (command);
- #endif
  }
  
  static char *
--- 256,262 ----
***************
*** 284,296 ****
    merge[1] = prompt;
    command = Tcl_Merge (2, merge);
    result = Tcl_Eval (interp, command);
- 
- #ifndef WINNT
    free (command);
- #else
-   Tcl_Free (command);
- #endif
- 
    if (result == TCL_OK)
      {
        return (strdup (interp -> result));
--- 271,277 ----

infcmd.c

begin:          vcard
fn:             Stuart Williams
n:              Williams;Stuart
org:            Hewlett-Packard Laboratories
adr:            Hewlett-Packard Laboratories;;Filton Road, ;Stoke Gifford,;Bristol;BS12 6QZ;UK
email;internet: skw@hplb.hpl.hp.com
tel;work:       +44 1179 228285
tel;fax:        +44 1179 229286
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
end:            vcard


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]