* gdbserver build broken on amd64-linux
@ 2004-10-20 5:32 Joel Brobecker
2004-10-20 14:26 ` Daniel Jacobowitz
0 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2004-10-20 5:32 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1249 bytes --]
The compiler fails to find a couple of macros:
> gcc -c -Wall -g -O2 -I. -I. -I./../regformats -I./../../include -I../../bfd -I./../../bfd linux-x86-64-low.c
> linux-x86-64-low.c: In function 'ps_get_thread_area':
> linux-x86-64-low.c:70: error: 'ARCH_GET_FS' undeclared (first use in this function)
> linux-x86-64-low.c:70: error: (Each undeclared identifier is reported only once
> linux-x86-64-low.c:70: error: for each function it appears in.)
> linux-x86-64-low.c:74: error: 'ARCH_GET_GS' undeclared (first use in this function)
I found the definitions in asm-x86_64/prctl.h. So I #included that file,
and the build succeeded. Looking at the name, I wasn't too enthusiastic
about it, as it didn't look too standard, so I looked around, and saw
that this file is included from asm/prctl.h. So I changed the #include
to that file instead, and got the builds again.
2004-10-19 Joel Brobecker <brobecker@gnat.com>
* linux-x86-64-low.c: Include asm/prctl.h.
I hope this is the right fix, but at the same time, I can't help but
wonder how it did work before... Let me know if this is OK to apply
or if it is the wrong fix (I am hoping that the location of these
macros is not dependent on the Linux distribution).
Thanks,
--
Joel
[-- Attachment #2: linux-x86-64-low.c.diff --]
[-- Type: text/plain, Size: 537 bytes --]
Index: linux-x86-64-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-x86-64-low.c,v
retrieving revision 1.8
diff -u -p -r1.8 linux-x86-64-low.c
--- linux-x86-64-low.c 16 Oct 2004 17:42:00 -0000 1.8
+++ linux-x86-64-low.c 20 Oct 2004 05:27:24 -0000
@@ -41,6 +41,7 @@
#include <sys/reg.h>
#include <sys/procfs.h>
#include <sys/ptrace.h>
+#include <asm/prctl.h>
/* This definition comes from prctl.h, but some kernels may not have it. */
#ifndef PTRACE_ARCH_PRCTL
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: gdbserver build broken on amd64-linux
2004-10-20 5:32 gdbserver build broken on amd64-linux Joel Brobecker
@ 2004-10-20 14:26 ` Daniel Jacobowitz
2004-10-20 15:24 ` Joel Brobecker
0 siblings, 1 reply; 13+ messages in thread
From: Daniel Jacobowitz @ 2004-10-20 14:26 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
On Tue, Oct 19, 2004 at 10:32:16PM -0700, Joel Brobecker wrote:
> The compiler fails to find a couple of macros:
>
> > gcc -c -Wall -g -O2 -I. -I. -I./../regformats -I./../../include -I../../bfd -I./../../bfd linux-x86-64-low.c
> > linux-x86-64-low.c: In function 'ps_get_thread_area':
> > linux-x86-64-low.c:70: error: 'ARCH_GET_FS' undeclared (first use in this function)
> > linux-x86-64-low.c:70: error: (Each undeclared identifier is reported only once
> > linux-x86-64-low.c:70: error: for each function it appears in.)
> > linux-x86-64-low.c:74: error: 'ARCH_GET_GS' undeclared (first use in this function)
>
> I found the definitions in asm-x86_64/prctl.h. So I #included that file,
> and the build succeeded. Looking at the name, I wasn't too enthusiastic
> about it, as it didn't look too standard, so I looked around, and saw
> that this file is included from asm/prctl.h. So I changed the #include
> to that file instead, and got the builds again.
>
> 2004-10-19 Joel Brobecker <brobecker@gnat.com>
>
> * linux-x86-64-low.c: Include asm/prctl.h.
>
> I hope this is the right fix, but at the same time, I can't help but
> wonder how it did work before... Let me know if this is OK to apply
> or if it is the wrong fix (I am hoping that the location of these
> macros is not dependent on the Linux distribution).
How about ths instead?
#ifndef ARCH_GET_FS
#define ARCH_SET_GS 0x1001
#define ARCH_SET_FS 0x1002
#define ARCH_GET_FS 0x1003
#define ARCH_GET_GS 0x1004
#endif
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: gdbserver build broken on amd64-linux
2004-10-20 14:26 ` Daniel Jacobowitz
@ 2004-10-20 15:24 ` Joel Brobecker
2004-10-20 15:47 ` Mark Kettenis
0 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2004-10-20 15:24 UTC (permalink / raw)
To: gdb-patches
> How about ths instead?
>
> #ifndef ARCH_GET_FS
> #define ARCH_SET_GS 0x1001
> #define ARCH_SET_FS 0x1002
> #define ARCH_GET_FS 0x1003
> #define ARCH_GET_GS 0x1004
> #endif
Yes, that should work too. I'm curious as to why these macros are not
defined for me, or said differently how it is that they are defined for
others (assuming others can build this code on amd64-linux unmodified).
--
Joel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: gdbserver build broken on amd64-linux
2004-10-20 15:24 ` Joel Brobecker
@ 2004-10-20 15:47 ` Mark Kettenis
2004-10-20 15:53 ` Daniel Jacobowitz
0 siblings, 1 reply; 13+ messages in thread
From: Mark Kettenis @ 2004-10-20 15:47 UTC (permalink / raw)
To: brobecker; +Cc: gdb-patches
Date: Wed, 20 Oct 2004 08:24:41 -0700
From: Joel Brobecker <brobecker@gnat.com>
> How about ths instead?
>
> #ifndef ARCH_GET_FS
> #define ARCH_SET_GS 0x1001
> #define ARCH_SET_FS 0x1002
> #define ARCH_GET_FS 0x1003
> #define ARCH_GET_GS 0x1004
> #endif
That's better, since it's dangerous to include kernel headers
directly.
Yes, that should work too. I'm curious as to why these macros are not
defined for me, or said differently how it is that they are defined for
others (assuming others can build this code on amd64-linux unmodified).
It all depends on the combination of installed kernel headers and
glibc headers whether it'll work or not. There are broken
combinations out there, even on i386. It's inherent to the way
GNU/Linux is developped since there is no real attempt to keep kernel
and libc in sync. Learn to live with or <plug> switch to a free
operating system with decent release management </plug>.
Cheers,
Mark
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: gdbserver build broken on amd64-linux
2004-10-20 15:47 ` Mark Kettenis
@ 2004-10-20 15:53 ` Daniel Jacobowitz
2004-10-21 4:15 ` Joel Brobecker
0 siblings, 1 reply; 13+ messages in thread
From: Daniel Jacobowitz @ 2004-10-20 15:53 UTC (permalink / raw)
To: Mark Kettenis; +Cc: brobecker, gdb-patches
On Wed, Oct 20, 2004 at 05:47:08PM +0200, Mark Kettenis wrote:
> Date: Wed, 20 Oct 2004 08:24:41 -0700
> From: Joel Brobecker <brobecker@gnat.com>
>
> > How about ths instead?
> >
> > #ifndef ARCH_GET_FS
> > #define ARCH_SET_GS 0x1001
> > #define ARCH_SET_FS 0x1002
> > #define ARCH_GET_FS 0x1003
> > #define ARCH_GET_GS 0x1004
> > #endif
>
> That's better, since it's dangerous to include kernel headers
> directly.
>
> Yes, that should work too. I'm curious as to why these macros are not
> defined for me, or said differently how it is that they are defined for
> others (assuming others can build this code on amd64-linux unmodified).
>
> It all depends on the combination of installed kernel headers and
> glibc headers whether it'll work or not. There are broken
> combinations out there, even on i386. It's inherent to the way
> GNU/Linux is developped since there is no real attempt to keep kernel
> and libc in sync. Learn to live with or <plug> switch to a free
> operating system with decent release management </plug>.
While your accusation is generally valid, in this case Joel hit the
salient point:
(assuming others can build this code on amd64-linux unmodified)
Since I wrote that code before I got an amd64-linux machine (long time
ago), and didn't test it on one before I checked it in, it's my own
stupid fault. I assumed that <linux/prctl.h> would include
<asm/prctl.h>, whch does not seem to be the case.
Joel, could you test the #ifndef version and check it in?
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: gdbserver build broken on amd64-linux
2004-10-20 15:53 ` Daniel Jacobowitz
@ 2004-10-21 4:15 ` Joel Brobecker
2004-10-21 4:38 ` Joel Brobecker
2004-10-21 13:49 ` Daniel Jacobowitz
0 siblings, 2 replies; 13+ messages in thread
From: Joel Brobecker @ 2004-10-21 4:15 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 945 bytes --]
> Joel, could you test the #ifndef version and check it in?
I verified that the attached patch allows gdbserver to build,
and I also double-checked the values with the ones I have in
my prctl.h file. But I've never used gdbserver before, and when
I tried it, I had a failure:
(gdb) target remote localhost:2345
Remote debugging using localhost:2345
Couldn't establish connection to remote target
Remote register badly formatted: T0506:0000000000000000;07:c0f1ffbf7f000000;10:2
06f55952a000000;
here: 0000000;07:c0f1ffbf7f000000;10:206f55952a000000;
Not sure why there seems to be discrepancy in the protocol...
In any case, I checked in this patch, since it can only be correct.
2004-10-20 Joel Brobecker <brobecker@gnat.com>
* linux-x86-64-low.c (ARCH_SET_GS): Add definition if missing.
(ARCH_SET_FS): Likewise.
(ARCH_GET_FS): Likewise.
(ARCH_GET_GS): Likewise.
Thanks,
--
Joel
[-- Attachment #2: linux-x86-64-low.c.diff --]
[-- Type: text/plain, Size: 736 bytes --]
Index: linux-x86-64-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/linux-x86-64-low.c,v
retrieving revision 1.8
diff -u -p -r1.8 linux-x86-64-low.c
--- linux-x86-64-low.c 16 Oct 2004 17:42:00 -0000 1.8
+++ linux-x86-64-low.c 21 Oct 2004 04:05:38 -0000
@@ -47,6 +47,15 @@
#define PTRACE_ARCH_PRCTL 30
#endif
+/* The following definitions come from prctl.h, but may be absent
+ for certain configurations. */
+#ifndef ARCH_GET_FS
+#define ARCH_SET_GS 0x1001
+#define ARCH_SET_FS 0x1002
+#define ARCH_GET_FS 0x1003
+#define ARCH_GET_GS 0x1004
+#endif
+
static int x86_64_regmap[] = {
RAX * 8, RBX * 8, RCX * 8, RDX * 8,
RSI * 8, RDI * 8, RBP * 8, RSP * 8,
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: gdbserver build broken on amd64-linux
2004-10-21 4:15 ` Joel Brobecker
@ 2004-10-21 4:38 ` Joel Brobecker
2004-10-21 13:48 ` Daniel Jacobowitz
2004-10-21 13:49 ` Daniel Jacobowitz
1 sibling, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2004-10-21 4:38 UTC (permalink / raw)
To: gdb-patches
> 2004-10-20 Joel Brobecker <brobecker@gnat.com>
>
> * linux-x86-64-low.c (ARCH_SET_GS): Add definition if missing.
> (ARCH_SET_FS): Likewise.
> (ARCH_GET_FS): Likewise.
> (ARCH_GET_GS): Likewise.
BTW: Do we want this change in the branch as well?
--
Joel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: gdbserver build broken on amd64-linux
2004-10-21 4:38 ` Joel Brobecker
@ 2004-10-21 13:48 ` Daniel Jacobowitz
2004-10-21 17:27 ` Joel Brobecker
0 siblings, 1 reply; 13+ messages in thread
From: Daniel Jacobowitz @ 2004-10-21 13:48 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
On Wed, Oct 20, 2004 at 09:38:27PM -0700, Joel Brobecker wrote:
> > 2004-10-20 Joel Brobecker <brobecker@gnat.com>
> >
> > * linux-x86-64-low.c (ARCH_SET_GS): Add definition if missing.
> > (ARCH_SET_FS): Likewise.
> > (ARCH_GET_FS): Likewise.
> > (ARCH_GET_GS): Likewise.
>
> BTW: Do we want this change in the branch as well?
Yes, please; otherwise gdbserver won't build. Next to figure out why
it does not work.
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: gdbserver build broken on amd64-linux
2004-10-21 4:15 ` Joel Brobecker
2004-10-21 4:38 ` Joel Brobecker
@ 2004-10-21 13:49 ` Daniel Jacobowitz
2004-10-21 17:33 ` Joel Brobecker
1 sibling, 1 reply; 13+ messages in thread
From: Daniel Jacobowitz @ 2004-10-21 13:49 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
On Wed, Oct 20, 2004 at 09:15:13PM -0700, Joel Brobecker wrote:
> > Joel, could you test the #ifndef version and check it in?
>
> I verified that the attached patch allows gdbserver to build,
> and I also double-checked the values with the ones I have in
> my prctl.h file. But I've never used gdbserver before, and when
> I tried it, I had a failure:
>
> (gdb) target remote localhost:2345
> Remote debugging using localhost:2345
> Couldn't establish connection to remote target
> Remote register badly formatted: T0506:0000000000000000;07:c0f1ffbf7f000000;10:2
> 06f55952a000000;
> here: 0000000;07:c0f1ffbf7f000000;10:206f55952a000000;
>
> Not sure why there seems to be discrepancy in the protocol...
The host GDB is configured for amd64 rather than i386, right? And
you've loaded a 64-bit binary using "file"? That error means GDB
expected a 32-bit register.
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: gdbserver build broken on amd64-linux
2004-10-21 13:48 ` Daniel Jacobowitz
@ 2004-10-21 17:27 ` Joel Brobecker
0 siblings, 0 replies; 13+ messages in thread
From: Joel Brobecker @ 2004-10-21 17:27 UTC (permalink / raw)
To: gdb-patches
> > > 2004-10-20 Joel Brobecker <brobecker@gnat.com>
> > >
> > > * linux-x86-64-low.c (ARCH_SET_GS): Add definition if missing.
> > > (ARCH_SET_FS): Likewise.
> > > (ARCH_GET_FS): Likewise.
> > > (ARCH_GET_GS): Likewise.
> >
> > BTW: Do we want this change in the branch as well?
>
> Yes, please; otherwise gdbserver won't build. Next to figure out why
> it does not work.
Ok, checked in the branch as well.
--
Joel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: gdbserver build broken on amd64-linux
2004-10-21 13:49 ` Daniel Jacobowitz
@ 2004-10-21 17:33 ` Joel Brobecker
2004-10-21 17:36 ` Daniel Jacobowitz
0 siblings, 1 reply; 13+ messages in thread
From: Joel Brobecker @ 2004-10-21 17:33 UTC (permalink / raw)
To: gdb-patches
> > I tried it, I had a failure:
> >
> > (gdb) target remote localhost:2345
> > Remote debugging using localhost:2345
> > Couldn't establish connection to remote target
> > Remote register badly formatted: T0506:0000000000000000;07:c0f1ffbf7f000000;10:2
> > 06f55952a000000;
> > here: 0000000;07:c0f1ffbf7f000000;10:206f55952a000000;
> >
> > Not sure why there seems to be discrepancy in the protocol...
>
> The host GDB is configured for amd64 rather than i386, right? And
> you've loaded a 64-bit binary using "file"? That error means GDB
> expected a 32-bit register.
Both the host gdb and gdbserver come from the same build on the same
machine. So you're right, GDB was configured for amd64. But I don't
understand the reference to i386. Do you mean gdbserver on amd64 only
supports i386 binaries?
--
Joel
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: gdbserver build broken on amd64-linux
2004-10-21 17:33 ` Joel Brobecker
@ 2004-10-21 17:36 ` Daniel Jacobowitz
2004-10-21 18:09 ` Joel Brobecker
0 siblings, 1 reply; 13+ messages in thread
From: Daniel Jacobowitz @ 2004-10-21 17:36 UTC (permalink / raw)
To: Joel Brobecker; +Cc: gdb-patches
On Thu, Oct 21, 2004 at 10:33:36AM -0700, Joel Brobecker wrote:
> > > I tried it, I had a failure:
> > >
> > > (gdb) target remote localhost:2345
> > > Remote debugging using localhost:2345
> > > Couldn't establish connection to remote target
> > > Remote register badly formatted: T0506:0000000000000000;07:c0f1ffbf7f000000;10:2
> > > 06f55952a000000;
> > > here: 0000000;07:c0f1ffbf7f000000;10:206f55952a000000;
> > >
> > > Not sure why there seems to be discrepancy in the protocol...
> >
> > The host GDB is configured for amd64 rather than i386, right? And
> > you've loaded a 64-bit binary using "file"? That error means GDB
> > expected a 32-bit register.
>
> Both the host gdb and gdbserver come from the same build on the same
> machine. So you're right, GDB was configured for amd64. But I don't
> understand the reference to i386. Do you mean gdbserver on amd64 only
> supports i386 binaries?
Bad phrasing: I was just verifying that it was amd64 rather than i386,
as a possible source of error. You'll have to work out why your host
GDB expects only a 32-bit number.
--
Daniel Jacobowitz
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: gdbserver build broken on amd64-linux
2004-10-21 17:36 ` Daniel Jacobowitz
@ 2004-10-21 18:09 ` Joel Brobecker
0 siblings, 0 replies; 13+ messages in thread
From: Joel Brobecker @ 2004-10-21 18:09 UTC (permalink / raw)
To: gdb-patches
> Bad phrasing: I was just verifying that it was amd64 rather than i386,
> as a possible source of error. You'll have to work out why your host
> GDB expects only a 32-bit number.
Ah, I understand now. If it's not important to you, I'll pass on that
one. If it is, then I'll have a look.
--
Joel
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2004-10-21 18:09 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-10-20 5:32 gdbserver build broken on amd64-linux Joel Brobecker
2004-10-20 14:26 ` Daniel Jacobowitz
2004-10-20 15:24 ` Joel Brobecker
2004-10-20 15:47 ` Mark Kettenis
2004-10-20 15:53 ` Daniel Jacobowitz
2004-10-21 4:15 ` Joel Brobecker
2004-10-21 4:38 ` Joel Brobecker
2004-10-21 13:48 ` Daniel Jacobowitz
2004-10-21 17:27 ` Joel Brobecker
2004-10-21 13:49 ` Daniel Jacobowitz
2004-10-21 17:33 ` Joel Brobecker
2004-10-21 17:36 ` Daniel Jacobowitz
2004-10-21 18:09 ` Joel Brobecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox