Dear gdb maintainer,

Versions of gdb prior to 5.0 delivered a SIGBUS
for an unaligned access.  The shell has this behavior,
too.  However, gdb 5.0 interprets unaligned accesses
as SIGSEGV.  This is a problem when debugging programs
that use SIGBUS.

Here is an example of a program with an unaligned
access running in gdb 4.17 and gdb 5.0:

/mnt3/jlp> gcc -g signal.c
/mnt3/jlp> a.out
Bus Error
/mnt3/jlp> cat signal.c
int main()
{
  union {
    char c[4];
    long *lP;
  } u;

  *u.lP = malloc(5);
  u.c[3]++;

  *u.lP = 42;  
  return 0;
}
/mnt3/jlp> 

/mnt3/jlp> /usr/local/bin/gdb-4.17 a.out
GNU gdb 4.17
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 "sparc-sun-solaris2.6"...
(gdb) b main
Breakpoint 1 at 0x10564: file signal.c, line 10.
(gdb) r
Starting program: /mnt3/jlp/a.out 
in gdb.  .cshrc was not sourced

Breakpoint 1, main () at signal.c:10
10        *u.lP = malloc(4);
(gdb) n
11        u.c[3]++;
(gdb) 
13        *u.lP = 42;  
(gdb) 

Program terminated with signal SIGBUS, Bus error.
The program no longer exists.
(gdb) quit
/mnt3/jlp> gdb a.out
GNU gdb 5.0 (UI_OUT)
Copyright 2000 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 "sparc-sun-solaris2.7"...
(gdb) b main
Breakpoint 1 at 0x10564: file signal.c, line 10.
(gdb) r
Starting program: /mnt3/jlp/a.out 
in gdb.  .cshrc was not sourced

Breakpoint 1, main () at signal.c:10
10        *u.lP = malloc(4);
(gdb) n
11        u.c[3]++;
(gdb) 
13        *u.lP = 42;  
(gdb) 

Program received signal SIGSEGV, Segmentation fault.
0x00010590 in main () at signal.c:13
13        *u.lP = 42;  
(gdb) quit
The program is running.  Exit anyway? (y or n) y
/mnt3/jlp> 

Reply via email to