Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] gdbserver x86 on win32: call init_target_desc
@ 2017-09-20  7:25 Simon Marchi
  2017-09-20 11:40 ` Pedro Alves
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Marchi @ 2017-09-20  7:25 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

When trying to run gdbserver compiled for x86 win32 under wine, I get:

  $ wine ./gdbserver/gdbserver.exe --once :1234 ./test
  /home/emaisin/src/binutils-gdb/gdb/gdbserver/regcache.c:177: A problem internal to GDBserver has been detected.
  regcache* new_register_cache(const target_desc*): Assertion `tdesc->registers_size != 0' failed.

It seems like on that platform, init_target_desc is never called, so
registers_size is never computed.

My first thought was to call init_target_desc somewhere in win32-low.c,
but it turns out that when using win32 on arm, the target description is
already initialized by the generated code.  My second thought was to
call it in {i386,amd64}_create_target_description, but those functions
are shared with GDB, and init_target_desc is gdbserver-specific.  So I
ended up with the simplest fix, calling it in i386_arch_setup.

Now I hit some other problem:

  $ wine ./gdbserver/gdbserver.exe --once :1234 ./test
  Killing process(es): 39
  No program to debug
  Exiting

but still, I think fixing the tdesc issue this is a step forward.

gdb/gdbserver/ChangeLog:

	* win32-i386-low.c (i386_arch_setup): Call init_target_desc.
---
 gdb/gdbserver/win32-i386-low.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c
index 4361d82..03d6e17 100644
--- a/gdb/gdbserver/win32-i386-low.c
+++ b/gdb/gdbserver/win32-i386-low.c
@@ -23,6 +23,7 @@
 #include "arch/amd64.h"
 #endif
 #include "arch/i386.h"
+#include "tdesc.h"
 
 #ifndef CONTEXT_EXTENDED_REGISTERS
 #define CONTEXT_EXTENDED_REGISTERS 0
@@ -443,12 +444,18 @@ static const unsigned char i386_win32_breakpoint = 0xcc;
 static void
 i386_arch_setup (void)
 {
+  struct target_desc *tdesc;
+
 #ifdef __x86_64__
-  win32_tdesc = amd64_create_target_description (X86_XSTATE_SSE_MASK, false,
+  tdesc = amd64_create_target_description (X86_XSTATE_SSE_MASK, false,
 						 false);
 #else
-  win32_tdesc = i386_create_target_description (X86_XSTATE_SSE_MASK, false);
+  tdesc = i386_create_target_description (X86_XSTATE_SSE_MASK, false);
 #endif
+
+  init_target_desc (tdesc);
+
+  win32_tdesc = tdesc;
 }
 
 struct win32_target_ops the_low_target = {
-- 
2.7.4


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

* Re: [PATCH] gdbserver x86 on win32: call init_target_desc
  2017-09-20  7:25 [PATCH] gdbserver x86 on win32: call init_target_desc Simon Marchi
@ 2017-09-20 11:40 ` Pedro Alves
  2017-09-20 22:08   ` Yao Qi
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Alves @ 2017-09-20 11:40 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches

On 09/20/2017 08:25 AM, Simon Marchi wrote:
> When trying to run gdbserver compiled for x86 win32 under wine, I get:
> 
>   $ wine ./gdbserver/gdbserver.exe --once :1234 ./test
>   /home/emaisin/src/binutils-gdb/gdb/gdbserver/regcache.c:177: A problem internal to GDBserver has been detected.
>   regcache* new_register_cache(const target_desc*): Assertion `tdesc->registers_size != 0' failed.
> 
> It seems like on that platform, init_target_desc is never called, so
> registers_size is never computed.
> 
> My first thought was to call init_target_desc somewhere in win32-low.c,
> but it turns out that when using win32 on arm, the target description is
> already initialized by the generated code.  My second thought was to
> call it in {i386,amd64}_create_target_description, but those functions
> are shared with GDB, and init_target_desc is gdbserver-specific.  So I
> ended up with the simplest fix, calling it in i386_arch_setup.

I assume that lynx-i386-low.c and nto-x86-low.c have the same problem?

 $ grep create_target_description *.c
 linux-x86-tdesc.c:      *tdesc = i386_create_target_description (xcr0, true);
 linux-x86-tdesc.c:      *tdesc = amd64_create_target_description (xcr0, is_x32, true);
 lynx-i386-low.c:  lynx_tdesc = i386_create_target_description (X86_XSTATE_SSE_MASK, false);
 nto-x86-low.c:  nto_tdesc = i386_create_target_description (X86_XSTATE_SSE_MASK, false);
 win32-i386-low.c:  win32_tdesc = amd64_create_target_description (X86_XSTATE_SSE_MASK, false,
 win32-i386-low.c:  win32_tdesc = i386_create_target_description (X86_XSTATE_SSE_MASK, false);

Thanks,
Pedro Alves


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

* Re: [PATCH] gdbserver x86 on win32: call init_target_desc
  2017-09-20 11:40 ` Pedro Alves
@ 2017-09-20 22:08   ` Yao Qi
  2017-09-22 14:51     ` Simon Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Yao Qi @ 2017-09-20 22:08 UTC (permalink / raw)
  To: Pedro Alves; +Cc: Simon Marchi, gdb-patches

On Wed, Sep 20, 2017 at 12:40 PM, Pedro Alves <palves@redhat.com> wrote:
>
> I assume that lynx-i386-low.c and nto-x86-low.c have the same problem?
>

Yes, I think so.  It is caused by my recent target description changes :(.
Simon's fix is right to me, we need to call init_target_desc in
lynx-i386-low.c and nto-x86-low.c.

-- 
Yao (齐尧)


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

* Re: [PATCH] gdbserver x86 on win32: call init_target_desc
  2017-09-20 22:08   ` Yao Qi
@ 2017-09-22 14:51     ` Simon Marchi
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Marchi @ 2017-09-22 14:51 UTC (permalink / raw)
  To: Yao Qi; +Cc: Pedro Alves, Simon Marchi, gdb-patches

On 2017-09-21 00:08, Yao Qi wrote:
> On Wed, Sep 20, 2017 at 12:40 PM, Pedro Alves <palves@redhat.com> 
> wrote:
>> 
>> I assume that lynx-i386-low.c and nto-x86-low.c have the same problem?
>> 
> 
> Yes, I think so.  It is caused by my recent target description changes 
> :(.
> Simon's fix is right to me, we need to call init_target_desc in
> lynx-i386-low.c and nto-x86-low.c.

Thanks, I'll push this patch and look into the other platforms.


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

end of thread, other threads:[~2017-09-22 14:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-20  7:25 [PATCH] gdbserver x86 on win32: call init_target_desc Simon Marchi
2017-09-20 11:40 ` Pedro Alves
2017-09-20 22:08   ` Yao Qi
2017-09-22 14:51     ` Simon Marchi

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