]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-6.5-bz181390-memory-address-width.patch
- obsolete file
[packages/gdb.git] / gdb-6.5-bz181390-memory-address-width.patch
1 https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=181390
2
3 2006-09-28  Jan Kratochvil  <jan.kratochvil@redhat.com>
4
5         * gdb/utils.c (paddress): Disable cutting of the printed addresses
6         to the target's address bit size; user wants to see everything.
7         * gdb/value.c (value_as_address1): Original `value_as_address'.
8         (value_as_address): New `value_as_address' wrapper - cut memory address
9         to the target's address bit size, bugreport by John Reiser.
10
11 2008-03-02  Jan Kratochvil  <jan.kratochvil@redhat.com>
12
13         Port to GDB-6.8pre.
14         New testcase `gdb.arch/amd64-i386-address.exp'.
15
16 Index: gdb-6.7.50.20080227/gdb/utils.c
17 ===================================================================
18 --- gdb-6.7.50.20080227.orig/gdb/utils.c        2008-03-02 14:28:44.000000000 +0100
19 +++ gdb-6.7.50.20080227/gdb/utils.c     2008-03-02 14:35:09.000000000 +0100
20 @@ -2540,6 +2540,14 @@ paddr_nz (CORE_ADDR addr)
21  const char *
22  paddress (CORE_ADDR addr)
23  {
24 +  /* Do not cut the address as the user should see all the information
25 +     available.  Otherwise 64-bit gdb debugging 32-bit inferior would
26 +     report for `x/x 0xffffffffffffce70' error
27 +     `Cannot access memory at 0xffffce70' while the error occured just
28 +     because of the higher order bits 0xffffffff00000000 there.
29 +     This specific error no longer occurs as the address is now cut
30 +     during execution by `value_as_address'.  */
31 +#if 0
32    /* Truncate address to the size of a target address, avoiding shifts
33       larger or equal than the width of a CORE_ADDR.  The local
34       variable ADDR_BIT stops the compiler reporting a shift overflow
35 @@ -2553,6 +2561,8 @@ paddress (CORE_ADDR addr)
36  
37    if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
38      addr &= ((CORE_ADDR) 1 << addr_bit) - 1;
39 +#endif
40 +
41    return hex_string (addr);
42  }
43  
44 Index: gdb-6.7.50.20080227/gdb/value.c
45 ===================================================================
46 --- gdb-6.7.50.20080227.orig/gdb/value.c        2008-01-18 18:07:40.000000000 +0100
47 +++ gdb-6.7.50.20080227/gdb/value.c     2008-03-02 14:36:38.000000000 +0100
48 @@ -983,11 +983,9 @@ value_as_double (struct value *val)
49    return foo;
50  }
51  
52 -/* Extract a value as a C pointer. Does not deallocate the value.  
53 -   Note that val's type may not actually be a pointer; value_as_long
54 -   handles all the cases.  */
55 -CORE_ADDR
56 -value_as_address (struct value *val)
57 +/* See `value_as_address' below - core of value to C pointer extraction.  */
58 +static CORE_ADDR
59 +value_as_address1 (struct value *val)
60  {
61    /* Assume a CORE_ADDR can fit in a LONGEST (for now).  Not sure
62       whether we want this to be true eventually.  */
63 @@ -1087,6 +1085,34 @@ value_as_address (struct value *val)
64    return unpack_long (value_type (val), value_contents (val));
65  #endif
66  }
67 +
68 +/* Extract a value as a C pointer. Does not deallocate the value.  
69 +   Note that val's type may not actually be a pointer; value_as_long
70 +   handles all the cases.  */
71 +CORE_ADDR
72 +value_as_address (struct value *val)
73 +{
74 +  CORE_ADDR addr;
75 +  int addr_bit;
76 +
77 +  addr = value_as_address1 (val);
78 +
79 +  /* Truncate address to the size of a target address, avoiding shifts
80 +     larger or equal than the width of a CORE_ADDR.  The local
81 +     variable ADDR_BIT stops the compiler reporting a shift overflow
82 +     when it won't occur. */
83 +  /* NOTE: This assumes that the significant address information is
84 +     kept in the least significant bits of ADDR - the upper bits were
85 +     either zero or sign extended.  Should ADDRESS_TO_POINTER() or
86 +     some ADDRESS_TO_PRINTABLE() be used to do the conversion?  */
87 +
88 +  addr_bit = gdbarch_addr_bit (current_gdbarch);
89 +
90 +  if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT))
91 +    addr &= ((CORE_ADDR) 1 << addr_bit) - 1;
92 +
93 +  return addr;
94 +}
95  \f
96  /* Unpack raw data (copied from debugee, target byte order) at VALADDR
97     as a long, or as a double, assuming the raw data is described
98 --- /dev/null   2008-03-01 10:30:54.797374318 +0100
99 +++ gdb-6.7.50.20080227/gdb/testsuite/gdb.arch/amd64-i386-address.S     2008-03-02 12:47:06.000000000 +0100
100 @@ -0,0 +1,32 @@
101 +/* Copyright 2008 Free Software Foundation, Inc.
102 +
103 +   This program is free software; you can redistribute it and/or modify
104 +   it under the terms of the GNU General Public License as published by
105 +   the Free Software Foundation; either version 3 of the License, or
106 +   (at your option) any later version.
107 +
108 +   This program is distributed in the hope that it will be useful,
109 +   but WITHOUT ANY WARRANTY; without even the implied warranty of
110 +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
111 +   GNU General Public License for more details.
112 +
113 +   You should have received a copy of the GNU General Public License
114 +   along with this program.  If not, see <http://www.gnu.org/licenses/>.
115 +
116 +   Please email any bugs, comments, and/or additions to this file to:
117 +   bug-gdb@gnu.org
118 +
119 +   This file is part of the gdb testsuite.
120 +
121 +   Test UNsigned extension of the 32-bit inferior address on a 64-bit host.
122 +   This file is based on the work by John Reiser.
123 +   This file was created by Jan Kratochvil <jan.kratochvil@redhat.com>.
124 +   https://bugzilla.redhat.com/show_bug.cgi?id=181390  */
125 +
126 +_start:        .globl  _start
127 +       nop
128 +       int3
129 +       movl    %esp,%ebx
130 +       int3    # examining memory from $ebx fails, from $esp succeeds
131 +       nop
132 +       nop
133 --- /dev/null   2008-03-01 10:30:54.797374318 +0100
134 +++ gdb-6.7.50.20080227/gdb/testsuite/gdb.arch/amd64-i386-address.exp   2008-03-02 12:57:11.000000000 +0100
135 @@ -0,0 +1,62 @@
136 +# Copyright 2008 Free Software Foundation, Inc.
137 +
138 +# This program is free software; you can redistribute it and/or modify
139 +# it under the terms of the GNU General Public License as published by
140 +# the Free Software Foundation; either version 3 of the License, or
141 +# (at your option) any later version.
142 +#
143 +# This program is distributed in the hope that it will be useful,
144 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
145 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
146 +# GNU General Public License for more details.
147 +#
148 +# You should have received a copy of the GNU General Public License
149 +# along with this program.  If not, see <http://www.gnu.org/licenses/>.
150 +
151 +# Please email any bugs, comments, and/or additions to this file to:
152 +# bug-gdb@gnu.org
153 +
154 +# This file is part of the gdb testsuite.
155 +
156 +# Test UNsigned extension of the 32-bit inferior address on a 64-bit host.
157 +# This file is based on the work by John Reiser.
158 +# This file was created by Jan Kratochvil <jan.kratochvil@redhat.com>.
159 +# https://bugzilla.redhat.com/show_bug.cgi?id=181390
160 +
161 +if {![istarget "x86_64-*-*"]} then {
162 +    verbose "Skipping amd64->i386 adress test."
163 +    return
164 +}
165 +
166 +set testfile "amd64-i386-address"
167 +set srcfile ${testfile}.S
168 +set binfile ${objdir}/${subdir}/${testfile}
169 +
170 +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug "additional_flags=-m32 -nostdlib"]] != "" } {
171 +    untested amd64-i386-address.exp
172 +    return -1
173 +}
174 +
175 +# Get things started.
176 +
177 +gdb_exit
178 +gdb_start
179 +gdb_reinitialize_dir $srcdir/$subdir
180 +gdb_load ${binfile}
181 +
182 +gdb_run_cmd
183 +
184 +set test "trap stop"
185 +gdb_test_multiple "" $test {
186 +    -re "Program received signal SIGTRAP,.*_start .*$gdb_prompt $" {
187 +       pass $test
188 +    }
189 +}
190 +
191 +gdb_test "stepi" ".*_start .*int3.*"
192 +
193 +gdb_test "x/x \$esp" "0x\[0-9a-f\]*:\t0x0*1"
194 +
195 +# Failure case would be:
196 +#      0xff8d7f00:     Cannot access memory at address 0xff8d7f00
197 +gdb_test "x/x \$ebx" "0x\[0-9a-f\]*:\t0x0*1"
This page took 0.039667 seconds and 3 git commands to generate.