Subject: Re: GDB problem
From: [email-masked] (Stuart Williams)

8 Jul 1997 08:21:32 -0700
Approved: [email-masked]
Distribution: cygnus
Message-ID: <[email-masked]>
References: <[email-masked]>
Reply-To: [email-masked]
Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="------------5AAB448694FE76ACD5311E42"
X-Mailer: Mozilla 4.0b5 [en] (Win95; I)
Original-To: Geoffrey Noer <[email-masked]>
Original-Cc: "J.R. Dean" <[email-masked]>, [email-masked]
X-Priority: 3 (Normal)
Original-Sender: [email-masked]

This is a multi-part message in MIME format.
--------------5AAB448694FE76ACD5311E42
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

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
> [email-masked]
> -
> For help on using this list (especially unsubscribing), send a message to
> "[email-masked]" with one line of text: "help".

----------
From:   Stuart Williams[SMTP:[email-masked]]
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.
--------------5AAB448694FE76ACD5311E42
Content-Type: text/plain; charset=us-ascii; name="infcmd.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="infcmd.diff"

*** 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? "))

--------------5AAB448694FE76ACD5311E42
Content-Type: application/x-unknown-content-type-c_auto_file; name="gdbtk.c"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="gdbtk.c"

--------------5AAB448694FE76ACD5311E42
Content-Type: text/plain; charset=us-ascii; name="gdbtk.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="gdbtk.diff"

*** 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 ----

--------------5AAB448694FE76ACD5311E42
Content-Type: application/x-unknown-content-type-c_auto_file; name="infcmd.c"
Content-Transfer-Encoding: base64
Content-Disposition: inline; filename="infcmd.c"

--------------5AAB448694FE76ACD5311E42
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Stuart Williams
Content-Disposition: attachment; filename="vcard.vcf"

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: [email-masked]
tel;work:       +44 1179 228285
tel;fax:        +44 1179 229286
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
end:            vcard

--------------5AAB448694FE76ACD5311E42--

-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".