[gnu.gdb.bug] problems and fixes for xgdb.c in gdb 3.0

glenne%hplsla@HPLABS.HP.COM (Glenn Engel) (01/06/89)

Two problems here.

Problem 1.
==========
xgdb 3.0 blows up with a bus error on startup.  The cause apparently is in
the Xt args passed to XtCreateManagedWidget() in xgdb_create_window.
One of the args is setting the depth value to 1.  My manual says that
this value should never be set by application code and is set automatically
as needed.  Deleting the argument declaration in frameArgs fixed this problem:

*** xgdb.c.orig	Tue Dec 27 17:11:28 1988
--- xgdb.c	Thu Jan  5 22:21:41 1989
***************
*** 440,446
    static Arg frameArgs[]= {
        {XtNwidth, (XtArgVal) 600},
        {XtNheight, (XtArgVal) 700},
-       {XtNdepth, (XtArgVal) 1},
    };
    {
      char *dummy1[2];

--- 440,445 -----
    static Arg frameArgs[]= {
        {XtNwidth, (XtArgVal) 600},
        {XtNheight, (XtArgVal) 700},
    };
    {
      char *dummy1[2];

Problem 2.
==========
xgdb 3.0 gets a bus error when executing a menu pick when xgdb.c is compiled
with gcc.  The apparent culprit seems to be the function lookup_cmd in 
command.c which has a side affect of changing a passed in string.  Since
the command strings in xgdb.c got put into the text segment, a bus error
occurs when an attempt is made to stick a null character on the end.

I fixed this by compiling with -fwritable-strings.  The real fix seems
to be a fix in lookup_cmd so it doesn't modify passed parameters.

Here's a debugger dump:

Bpt 1, lookup_cmd (line=(va_list *) 0xffeff590, list=(struct cmd_list_element *)
 0xa974c, cmdtype=(va_list) 0x2c6 "", allow_unknown=0) (command.c line 465)
465       while (**line == ' ' || **line == '\t')
(top) p *line
$8 = (va_list) 0x31a6c "step"
(top) l
460       int nfound;
461       char ambbuf[100];
462
463       /* Skip leading whitespace.  */
464
465       while (**line == ' ' || **line == '\t')
466         (*line)++;
467
468       /* Clear out trailing whitespace.  */
469
(top) s
470       p = *line + strlen (*line);
(top) s
471       while (p != *line && (p[-1] == ' ' || p[-1] == '\t'))
(top) p p
$9 = (va_list) 0x31a70 ""
(top) p *line
$11 = (va_list) 0x31a6c "step"
(top) s
473       *p = 0;
(top) s

Program received signal 10, bus error
lookup_cmd (line=(va_list *) 0xffeff590, list=(struct cmd_list_element *) 0xa974
c, cmdtype=(va_list) 0x2c6 "", allow_unknown=0) (command.c line 473)
473       *p = 0;
(top) bt
#0  lookup_cmd (line=(va_list *) 0xffeff590, list=(struct cmd_list_element *) 0x
a974c, cmdtype=(va_list) 0x2c6 "", allow_unknown=0) (command.c line 473)
#1  0xb3a in execute_command (p=(char *) 0x31a6c "step", from_tty=0) (main.c lin
e 388)
#2  0x319d6 in do_command (w=(Widget) 0xa4bf4, command=(caddr_t) 0x31a6c "step",
 call_data=(caddr_t) 0x0) (xgdb.c line 335)
#3  0x3cf6e in _XtCallCallbacks ()
#4  0x3d01e in XtCallCallbacks ()
#5  0x336d8 in XtAsciiSinkDestroy ()
#6  0x48e0e in _XtTranslateInitialize ()
#7  0x40162 in XtAddExposureToRegion ()
#8  0x40448 in XtDispatchEvent ()
#9  0x31f20 in xgdb_dispatch (fp=(FILE *) 0x7f1ec) (xgdb.c line 569)
#10 0x31f48 in xgdb_window_hook (infile=(FILE *) 0x7f1ec, prompt=(caddr_t) 0xa92
9c "(gdb) ") (xgdb.c line 586)
#11 0xc5e in command_loop () (main.c line 437)
#12 0xa82 in main (argc=2, argv=(char **) 0xffeffce8, envp=(char **) 0xffeffcf4)
 (main.c line 368)

--
 |  Glenn R. Engel
 |  Hewlett-Packard 
 |  (206) 335-2066
 |  glenne%hplsla@hplabs.hp.com