Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch/testcase] fix gdb.base/relocate.c
@ 2003-07-08  2:53 Kei Sakamoto
  2003-07-08  2:58 ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Kei Sakamoto @ 2003-07-08  2:53 UTC (permalink / raw)
  To: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 1013 bytes --]

The attached patch fixes gdb.base/relocate.c.

"relocate.exp: get address of function_bar" fails with m32r-elf-gdb
as the following:

print &function_bar
$6 = (int (*)(void)) 0xc <global_bar>
(gdb) FAIL: gdb.base/relocate.exp: get address of function_bar (unknown output)

Both function_bar and global_bar have the same address, 0xc.
Though they belong to different sections, gdb considers they
are the same and prints global_bar's data instead of
function_bar's.

The same error happens with i386 if line 4 and 5 of relocate.c
are modified as the following:

short global_foo = 3;
short global_bar = 4;

I guess this is not gdb's bug but a feature and the testcase
should be modified. So I made a patch file.

The attached patch inserts a definition of a dummy array so that
global_bar and function_bar should not have the same address.

Kei

2003-07-08    Kei Sakamoto  <sakamoto.kei@renesas.com>

 * gdb.base/relocate.c : Add a dummy array to make global_bar
        and function_bar have different addresses.

[-- Attachment #2: relocate.c.patch --]
[-- Type: application/octet-stream, Size: 351 bytes --]

--- insight-20030703.orig/src/gdb/testsuite/gdb.base/relocate.c	Fri Apr  5 11:45:48 2002
+++ insight-20030703/src/gdb/testsuite/gdb.base/relocate.c	Mon Jul  7 16:56:47 2003
@@ -1,6 +1,8 @@
 static int static_foo = 1;
 static int static_bar = 2;
 
+int dummy[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
 int global_foo = 3;
 int global_bar = 4;
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch/testcase] fix gdb.base/relocate.c
  2003-07-08  2:53 [patch/testcase] fix gdb.base/relocate.c Kei Sakamoto
@ 2003-07-08  2:58 ` Daniel Jacobowitz
  2003-07-24 18:47   ` Daniel Jacobowitz
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2003-07-08  2:58 UTC (permalink / raw)
  To: Kei Sakamoto; +Cc: gdb-patches

On Tue, Jul 08, 2003 at 11:56:07AM +0900, Kei Sakamoto wrote:
> The attached patch fixes gdb.base/relocate.c.
> 
> "relocate.exp: get address of function_bar" fails with m32r-elf-gdb
> as the following:
> 
> print &function_bar
> $6 = (int (*)(void)) 0xc <global_bar>
> (gdb) FAIL: gdb.base/relocate.exp: get address of function_bar (unknown output)
> 
> Both function_bar and global_bar have the same address, 0xc.
> Though they belong to different sections, gdb considers they
> are the same and prints global_bar's data instead of
> function_bar's.
> 
> The same error happens with i386 if line 4 and 5 of relocate.c
> are modified as the following:
> 
> short global_foo = 3;
> short global_bar = 4;
> 
> I guess this is not gdb's bug but a feature and the testcase
> should be modified. So I made a patch file.
> 
> The attached patch inserts a definition of a dummy array so that
> global_bar and function_bar should not have the same address.
> 
> Kei
> 
> 2003-07-08    Kei Sakamoto  <sakamoto.kei@renesas.com>
> 
>  * gdb.base/relocate.c : Add a dummy array to make global_bar
>         and function_bar have different addresses.

Ugh, this is OK, since the test can only reliably specify an offset for
.text.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [patch/testcase] fix gdb.base/relocate.c
  2003-07-08  2:58 ` Daniel Jacobowitz
@ 2003-07-24 18:47   ` Daniel Jacobowitz
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2003-07-24 18:47 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kei Sakamoto

On Mon, Jul 07, 2003 at 10:58:30PM -0400, Daniel Jacobowitz wrote:
> On Tue, Jul 08, 2003 at 11:56:07AM +0900, Kei Sakamoto wrote:
> > 2003-07-08    Kei Sakamoto  <sakamoto.kei@renesas.com>
> > 
> >  * gdb.base/relocate.c : Add a dummy array to make global_bar
> >         and function_bar have different addresses.
> 
> Ugh, this is OK, since the test can only reliably specify an offset for
> .text.

I've checked this in, with updated commentary.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

2003-07-24  Daniel Jacobowitz  <drow@mvista.com>

	From Kei Sakamoto <sakamoto.kei@renesas.com>:
	* gdb.base/relocate.c (dummy): New padding array.

Index: gdb.base/relocate.c
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/relocate.c,v
retrieving revision 1.1
diff -u -p -r1.1 relocate.c
--- gdb.base/relocate.c	5 Apr 2002 02:45:48 -0000	1.1
+++ gdb.base/relocate.c	24 Jul 2003 18:44:36 -0000
@@ -1,6 +1,10 @@
 static int static_foo = 1;
 static int static_bar = 2;
 
+/* This padding is just for the benefit of the test harness.  It
+   causes the globals to have different addresses than the functions.  */
+int dummy[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
 int global_foo = 3;
 int global_bar = 4;
 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-07-24 18:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-08  2:53 [patch/testcase] fix gdb.base/relocate.c Kei Sakamoto
2003-07-08  2:58 ` Daniel Jacobowitz
2003-07-24 18:47   ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox