Bug 4517 - Cannot debug with gdb with message 'Error accessing memory address'
Summary: Cannot debug with gdb with message 'Error accessing memory address'
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: gnu (show other bugs)
Version: 3.0-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1997-09-12 11:20 UTC by yasu
Modified: 1997-09-12 17:47 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yasu 1997-09-12 11:20:01 UTC
Cannot set value to automatic variable when debuggin with gdb.
Setting to an automatic variable cause 
"Error accessing memory address 0x???????: Bad address."
message.

How-To-Repeat: Debugging code below with gdb, I got error message
and could not set value to the variable 'x'.

----------  test.c  ----------
main(){
        int x;
	x = 1;
}
---------- test.c end----------
Above code is complied with:
   % cc -g -o test test.c

Debugged with gdb:
   % gdb ./test
It said:

GDB is free software and you are welcome to 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.
GDB 4.16 (i386-unknown-freebsd), 
Copyright 1996 Free Software Foundation, Inc...
(gdb) b main
Breakpoint 1 at 0x163b: file test.c, line 3.
(gdb) run
Starting program: /a/steffi/export/yasu/./test 

Breakpoint 1, main () at test.c:3
3	    x = 1;
(gdb) n
4	}
(gdb) set x = 100;
Error accessing memory address 0xefbfd48c: Bad address.
(gdb) quit
The program is running.  Quit anyway (and kill it)? (y or n) y
---------------------------------------------------------------
If I define x as static, I can set value to x.
Comment 1 jlemon 1997-09-12 15:16:14 UTC
On Sep 09, 1997 at 03:17:20AM -0700, yasu@mrit.mei.co.jp wrote:
> Breakpoint 1, main () at test.c:3
> 3	    x = 1;
> (gdb) n
> 4	}
> (gdb) set x = 100;
> Error accessing memory address 0xefbfd48c: Bad address.

Try this patch (courtesy of Bruce Evans):
--
Jonathan

------------------------------ cut here ------------------------------
diff -c2 vm_map.c~ vm_map.c
*** vm_map.c~   Mon Sep  1 18:00:38 1997
--- vm_map.c    Wed Sep 10 14:02:48 1997
***************
*** 2288,2292 **** 
                (entry->eflags & MAP_ENTRY_COW) == 0 ||
                (entry->wired_count != 0)) {
!               if ((fault_type & (prot)) != fault_type)
                        RETURN(KERN_PROTECTION_FAILURE); 
        }
--- 2288,2293 ---- 
                (entry->eflags & MAP_ENTRY_COW) == 0 ||
                (entry->wired_count != 0)) {
!               if ((fault_type & prot) !=  
!                   (fault_type & ~VM_PROT_OVERRIDE_WRITE))
                        RETURN(KERN_PROTECTION_FAILURE);
        }
Comment 2 jlemon freebsd_committer freebsd_triage 1997-09-12 17:39:06 UTC
State Changed
From-To: open->closed


Fix applied to vm_map.c, rev 1.90.  Test case works with this patch.