* GDBserver patch for x86 LynxOS-178 @ 2018-05-10 15:16 Joel Brobecker 2018-05-10 15:38 ` [RFA/gdbserver] x86 LynxOS-178: Adjust floating-point context structure Joel Brobecker 0 siblings, 1 reply; 4+ messages in thread From: Joel Brobecker @ 2018-05-10 15:16 UTC (permalink / raw) To: gdb-patches Hello, As I hinted before, I have not been able to build GDBserver since we switched over to C++, because I don't have a C++ compiler for that target (I am not giving up yet, though). So, if you are wondering why I am still submitting a GDBserver patch for that target, it's because I have been working on x86 LynxOS-178 with GDBserver 7.10, and I think this one is a straightforward cherry-pick, and will be useful if we manage to port G++ and the libstdc++ to this target. In the meantime, the patch was tested on x86-lynx18elf, with a baseline based on GDB 7.10. One element I did not explore was the idea of perhaps having a specific target description xml for this platform, so as to not show the registers that are not available on LynxOS-178. In my opinion, it's only a nice-to-have, so I left it for some other time. I'd like to finish the work on GDBserver for Windows, for instance. Thanks, -- Joel ^ permalink raw reply [flat|nested] 4+ messages in thread
* [RFA/gdbserver] x86 LynxOS-178: Adjust floating-point context structure 2018-05-10 15:16 GDBserver patch for x86 LynxOS-178 Joel Brobecker @ 2018-05-10 15:38 ` Joel Brobecker 2018-05-10 16:47 ` Simon Marchi 0 siblings, 1 reply; 4+ messages in thread From: Joel Brobecker @ 2018-05-10 15:38 UTC (permalink / raw) To: gdb-patches The floating point context structure on x86 LynxOS-178 is not the same as on LynxOS 5.x. As a consequence, trying to print the return value of a function returning a float, for instance, yields incorrect results. This patch fixes the issue by providing an updated definition for LynxOS-178 (the reason why we cannot access the actual definition provided by the system still remains true). gdb/gdbserver/ChangeLog: * lynx-i386-low.c (LYNXOS_178): New macro. (usr_fcontext_t) <LYNXOS_178>: Provide a definition that matches the layout on LynxOS-178. (lynx_i386_fill_fpregset, lynx_i386_store_fpregset): Do not handle floating point registers that are not supported by LynxOS-178. OK to push to master? -- Joel --- gdb/gdbserver/lynx-i386-low.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/gdb/gdbserver/lynx-i386-low.c b/gdb/gdbserver/lynx-i386-low.c index c7b4fe4..25551db 100644 --- a/gdb/gdbserver/lynx-i386-low.c +++ b/gdb/gdbserver/lynx-i386-low.c @@ -24,7 +24,15 @@ /* The following two typedefs are defined in a .h file which is not in the standard include path (/sys/include/family/x86/ucontext.h), - so we just duplicate them here. */ + so we just duplicate them here. + + Unfortunately for us, the definition of this structure differs between + LynxOS 5.x and LynxOS 178. Rather than duplicate the code, we use + different definitions depending on the target. */ + +#ifdef VMOS_DEV +#define LYNXOS_178 +#endif /* General register context */ typedef struct usr_econtext { @@ -51,6 +59,28 @@ typedef struct usr_econtext { uint32_t uec_gs; } usr_econtext_t; +#if defined(LYNXOS_178) + +/* Floating point register context */ +typedef struct usr_fcontext { + uint32_t ufc_control; + uint32_t ufc_status; + uint32_t ufc_tag; + uint8_t *ufc_inst_off; + uint32_t ufc_inst_sel; + uint8_t *ufc_data_off; + uint32_t ufc_data_sel; + struct ufp387_real { + uint16_t umant4; + uint16_t umant3; + uint16_t umant2; + uint16_t umant1; + uint16_t us_and_e; + } ufc_reg[8]; +} usr_fcontext_t; + +#else /* This is LynxOS 5.x. */ + /* Floating point and SIMD register context */ typedef struct usr_fcontext { uint16_t ufc_control; @@ -86,6 +116,8 @@ typedef struct usr_fcontext { char ureserved[16][14]; } usr_fcontext_t; +#endif + /* The index of various registers inside the regcache. */ enum lynx_i386_gdb_regnum @@ -218,6 +250,7 @@ lynx_i386_fill_fpregset (struct regcache *regcache, char *buf) buf + offsetof (usr_fcontext_t, ufc_data_sel)); collect_register (regcache, I386_FOOFF_REGNUM, buf + offsetof (usr_fcontext_t, ufc_data_off)); +#if !defined(LYNXOS_178) collect_16bit_register (regcache, I386_FOP_REGNUM, buf + offsetof (usr_fcontext_t, ufc_opcode)); @@ -228,6 +261,7 @@ lynx_i386_fill_fpregset (struct regcache *regcache, char *buf) + i * sizeof (struct uxmm_register)); collect_register (regcache, I386_MXCSR_REGNUM, buf + offsetof (usr_fcontext_t, usse_mxcsr)); +#endif } /* This is the supply counterpart for collect_16bit_register: @@ -276,6 +310,7 @@ lynx_i386_store_fpregset (struct regcache *regcache, const char *buf) buf + offsetof (usr_fcontext_t, ufc_data_sel)); supply_register (regcache, I386_FOOFF_REGNUM, buf + offsetof (usr_fcontext_t, ufc_data_off)); +#if !defined(LYNXOS_178) supply_16bit_register (regcache, I386_FOP_REGNUM, buf + offsetof (usr_fcontext_t, ufc_opcode)); @@ -286,6 +321,7 @@ lynx_i386_store_fpregset (struct regcache *regcache, const char *buf) + i * sizeof (struct uxmm_register)); supply_register (regcache, I386_MXCSR_REGNUM, buf + offsetof (usr_fcontext_t, usse_mxcsr)); +#endif } /* Implements the lynx_target_ops.arch_setup routine. */ -- 2.1.4 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA/gdbserver] x86 LynxOS-178: Adjust floating-point context structure 2018-05-10 15:38 ` [RFA/gdbserver] x86 LynxOS-178: Adjust floating-point context structure Joel Brobecker @ 2018-05-10 16:47 ` Simon Marchi 2018-05-10 18:34 ` Joel Brobecker 0 siblings, 1 reply; 4+ messages in thread From: Simon Marchi @ 2018-05-10 16:47 UTC (permalink / raw) To: Joel Brobecker; +Cc: gdb-patches On 2018-05-10 11:05, Joel Brobecker wrote: > The floating point context structure on x86 LynxOS-178 is not > the same as on LynxOS 5.x. As a consequence, trying to print > the return value of a function returning a float, for instance, > yields incorrect results. > > This patch fixes the issue by providing an updated definition > for LynxOS-178 (the reason why we cannot access the actual definition > provided by the system still remains true). > > gdb/gdbserver/ChangeLog: > > * lynx-i386-low.c (LYNXOS_178): New macro. > (usr_fcontext_t) <LYNXOS_178>: Provide a definition that > matches > the layout on LynxOS-178. This syntax (with < >) is usually meant to denote fields (as if you were referring to field LYNXOS_178 in structure usr_fcontext_t). To denote an #ifdef context (which is what I understand you want to do), I usually see this syntax: [LYNXOS_178] (usr_fcontext_t): ... For example: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/ChangeLog-2017;h=aaadf142a4641ecd3feb26bc1dfa83dcc19e713c;hb=HEAD#l13806 > (lynx_i386_fill_fpregset, lynx_i386_store_fpregset): Do not > handle floating point registers that are not supported by > LynxOS-178. > > OK to push to master? Otherwise, it looks good to me. Simon ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFA/gdbserver] x86 LynxOS-178: Adjust floating-point context structure 2018-05-10 16:47 ` Simon Marchi @ 2018-05-10 18:34 ` Joel Brobecker 0 siblings, 0 replies; 4+ messages in thread From: Joel Brobecker @ 2018-05-10 18:34 UTC (permalink / raw) To: Simon Marchi; +Cc: gdb-patches [-- Attachment #1: Type: text/plain, Size: 1409 bytes --] > > gdb/gdbserver/ChangeLog: > > > > * lynx-i386-low.c (LYNXOS_178): New macro. > > (usr_fcontext_t) <LYNXOS_178>: Provide a definition that matches > > the layout on LynxOS-178. > > This syntax (with < >) is usually meant to denote fields (as if you were > referring to field LYNXOS_178 in structure usr_fcontext_t). To denote an > #ifdef context (which is what I understand you want to do), I usually see > this syntax: > > [LYNXOS_178] (usr_fcontext_t): ... > > For example: > > https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=gdb/ChangeLog-2017;h=aaadf142a4641ecd3feb26bc1dfa83dcc19e713c;hb=HEAD#l13806 Grumpf. I keep getting confused over this. Of course, you are right, and this is explained in the GCS. > > > (lynx_i386_fill_fpregset, lynx_i386_store_fpregset): Do not > > handle floating point registers that are not supported by > > LynxOS-178. > > > > OK to push to master? > > Otherwise, it looks good to me. Thanks. Attached is the patch I ended up pushing to master. gdb/gdbserver/ChangeLog: * lynx-i386-low.c (LYNXOS_178): New macro. [LYNXOS_178] (usr_fcontext_t): Provide a definition that matches the layout on LynxOS-178. (lynx_i386_fill_fpregset, lynx_i386_store_fpregset): Do not handle floating point registers that are not supported by LynxOS-178. -- Joel [-- Attachment #2: 0001-x86-LynxOS-178-Adjust-floating-point-context-structu.patch --] [-- Type: text/x-diff, Size: 5098 bytes --] From 55271bf969c2c09b98aecd97b36170fbf76c3fc4 Mon Sep 17 00:00:00 2001 From: Joel Brobecker <brobecker@adacore.com> Date: Thu, 10 May 2018 12:01:39 -0500 Subject: [PATCH] x86 LynxOS-178: Adjust floating-point context structure The floating point context structure on x86 LynxOS-178 is not the same as on LynxOS 5.x. As a consequence, trying to print the return value of a function returning a float, for instance, yields incorrect results. This patch fixes the issue by providing an updated definition for LynxOS-178 (the reason why we cannot access the actual definition provided by the system still remains true). gdb/gdbserver/ChangeLog: * lynx-i386-low.c (LYNXOS_178): New macro. [LYNXOS_178] (usr_fcontext_t): Provide a definition that matches the layout on LynxOS-178. (lynx_i386_fill_fpregset, lynx_i386_store_fpregset): Do not handle floating point registers that are not supported by LynxOS-178. --- gdb/gdbserver/ChangeLog | 9 +++++++++ gdb/gdbserver/lynx-i386-low.c | 38 +++++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index 36915cf..5e7ea10 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,12 @@ +2018-05-10 Joel Brobecker <brobecker@adacore.com> + + * lynx-i386-low.c (LYNXOS_178): New macro. + [LYNXOS_178] (usr_fcontext_t): Provide a definition that matches + the layout on LynxOS-178. + (lynx_i386_fill_fpregset, lynx_i386_store_fpregset): Do not + handle floating point registers that are not supported by + LynxOS-178. + 2018-05-10 Tom Tromey <tom@tromey.com> * configure: Rebuild. diff --git a/gdb/gdbserver/lynx-i386-low.c b/gdb/gdbserver/lynx-i386-low.c index 37c0dc9..a8817b4 100644 --- a/gdb/gdbserver/lynx-i386-low.c +++ b/gdb/gdbserver/lynx-i386-low.c @@ -25,7 +25,15 @@ /* The following two typedefs are defined in a .h file which is not in the standard include path (/sys/include/family/x86/ucontext.h), - so we just duplicate them here. */ + so we just duplicate them here. + + Unfortunately for us, the definition of this structure differs between + LynxOS 5.x and LynxOS 178. Rather than duplicate the code, we use + different definitions depending on the target. */ + +#ifdef VMOS_DEV +#define LYNXOS_178 +#endif /* General register context */ typedef struct usr_econtext { @@ -52,6 +60,28 @@ typedef struct usr_econtext { uint32_t uec_gs; } usr_econtext_t; +#if defined(LYNXOS_178) + +/* Floating point register context */ +typedef struct usr_fcontext { + uint32_t ufc_control; + uint32_t ufc_status; + uint32_t ufc_tag; + uint8_t *ufc_inst_off; + uint32_t ufc_inst_sel; + uint8_t *ufc_data_off; + uint32_t ufc_data_sel; + struct ufp387_real { + uint16_t umant4; + uint16_t umant3; + uint16_t umant2; + uint16_t umant1; + uint16_t us_and_e; + } ufc_reg[8]; +} usr_fcontext_t; + +#else /* This is LynxOS 5.x. */ + /* Floating point and SIMD register context */ typedef struct usr_fcontext { uint16_t ufc_control; @@ -87,6 +117,8 @@ typedef struct usr_fcontext { char ureserved[16][14]; } usr_fcontext_t; +#endif + /* The index of various registers inside the regcache. */ enum lynx_i386_gdb_regnum @@ -219,6 +251,7 @@ lynx_i386_fill_fpregset (struct regcache *regcache, char *buf) buf + offsetof (usr_fcontext_t, ufc_data_sel)); collect_register (regcache, I386_FOOFF_REGNUM, buf + offsetof (usr_fcontext_t, ufc_data_off)); +#if !defined(LYNXOS_178) collect_16bit_register (regcache, I386_FOP_REGNUM, buf + offsetof (usr_fcontext_t, ufc_opcode)); @@ -229,6 +262,7 @@ lynx_i386_fill_fpregset (struct regcache *regcache, char *buf) + i * sizeof (struct uxmm_register)); collect_register (regcache, I386_MXCSR_REGNUM, buf + offsetof (usr_fcontext_t, usse_mxcsr)); +#endif } /* This is the supply counterpart for collect_16bit_register: @@ -277,6 +311,7 @@ lynx_i386_store_fpregset (struct regcache *regcache, const char *buf) buf + offsetof (usr_fcontext_t, ufc_data_sel)); supply_register (regcache, I386_FOOFF_REGNUM, buf + offsetof (usr_fcontext_t, ufc_data_off)); +#if !defined(LYNXOS_178) supply_16bit_register (regcache, I386_FOP_REGNUM, buf + offsetof (usr_fcontext_t, ufc_opcode)); @@ -287,6 +322,7 @@ lynx_i386_store_fpregset (struct regcache *regcache, const char *buf) + i * sizeof (struct uxmm_register)); supply_register (regcache, I386_MXCSR_REGNUM, buf + offsetof (usr_fcontext_t, usse_mxcsr)); +#endif } /* Implements the lynx_target_ops.arch_setup routine. */ -- 2.1.4 ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-05-10 17:04 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-05-10 15:16 GDBserver patch for x86 LynxOS-178 Joel Brobecker 2018-05-10 15:38 ` [RFA/gdbserver] x86 LynxOS-178: Adjust floating-point context structure Joel Brobecker 2018-05-10 16:47 ` Simon Marchi 2018-05-10 18:34 ` Joel Brobecker
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox