[09/25] Use target_desc fields expedite_regs and xmltarget ifndef IN_PROCESS_AGENT

Message ID 1497256916-4958-10-git-send-email-yao.qi@linaro.org
State New, archived
Headers

Commit Message

Yao Qi June 12, 2017, 8:41 a.m. UTC
  struct target_desc is used by both GDBserver and IPA, but fields expedite_regs
and xmltarget are only used in GDBserver, so this patch wraps these two fields
by ifndef IN_PROCESS_AGENT.  This patch also changes regformats/regdat.sh to
generate .c files in this way too.

gdb/gdbserver:

2017-06-06  Yao Qi  <yao.qi@linaro.org>

	* tdesc.h (struct target_desc) [IN_PROCESS_AGENT] <expedite_regs>:
	Remove.
	[IN_PROCESS_AGENT] <xmltarget>: Likewise.

gdb:

2017-06-06  Yao Qi  <yao.qi@linaro.org>

	* regformats/regdat.sh: Generate code with "ifndef IN_PROCESS_AGENT".
---
 gdb/gdbserver/tdesc.h    | 2 ++
 gdb/regformats/regdat.sh | 3 +++
 2 files changed, 5 insertions(+)
  

Comments

Pedro Alves June 28, 2017, 4:15 p.m. UTC | #1
On 06/12/2017 09:41 AM, Yao Qi wrote:
> struct target_desc is used by both GDBserver and IPA, but fields expedite_regs
> and xmltarget are only used in GDBserver, so this patch wraps these two fields
> by ifndef IN_PROCESS_AGENT.  This patch also changes regformats/regdat.sh to
> generate .c files in this way too.

OK.

Thanks,
Pedro Alves
  
Pedro Alves June 28, 2017, 5:42 p.m. UTC | #2
On 06/28/2017 05:15 PM, Pedro Alves wrote:
> On 06/12/2017 09:41 AM, Yao Qi wrote:
>> struct target_desc is used by both GDBserver and IPA, but fields expedite_regs
>> and xmltarget are only used in GDBserver, so this patch wraps these two fields
>> by ifndef IN_PROCESS_AGENT.  This patch also changes regformats/regdat.sh to
>> generate .c files in this way too.
> 
> OK.

Actually, I tried building the series at some intermediate patch,
and noticed that the build was broken.  This is the first patch
that breaks it:

...
amd64-linux.c: In function ‘void init_registers_amd64_linux()’:
amd64-linux.c:103:11: error: ‘struct target_desc’ has no member named
‘expedite_regs’
   result->expedite_regs = expedite_regs_amd64_linux;
           ^
amd64-linux.c:104:11: error: ‘struct target_desc’ has no member named
‘xmltarget’
   result->xmltarget = xmltarget_amd64_linux;
           ^
...

Thanks,
Pedro Alves
  
Pedro Alves June 28, 2017, 5:45 p.m. UTC | #3
On 06/28/2017 06:42 PM, Pedro Alves wrote:
> On 06/28/2017 05:15 PM, Pedro Alves wrote:
>> On 06/12/2017 09:41 AM, Yao Qi wrote:
>>> struct target_desc is used by both GDBserver and IPA, but fields expedite_regs
>>> and xmltarget are only used in GDBserver, so this patch wraps these two fields
>>> by ifndef IN_PROCESS_AGENT.  This patch also changes regformats/regdat.sh to
>>> generate .c files in this way too.
>>
>> OK.
> 
> Actually, I tried building the series at some intermediate patch,
> and noticed that the build was broken.  This is the first patch
> that breaks it:
> 
> ...
> amd64-linux.c: In function ‘void init_registers_amd64_linux()’:
> amd64-linux.c:103:11: error: ‘struct target_desc’ has no member named
> ‘expedite_regs’
>    result->expedite_regs = expedite_regs_amd64_linux;
>            ^
> amd64-linux.c:104:11: error: ‘struct target_desc’ has no member named
> ‘xmltarget’
>    result->xmltarget = xmltarget_amd64_linux;
>            ^
> ...


Hmm, turns out that I need to remove the generated .c files
manually.  "make clean" didn't remove them.  Now that they're
gone, gdbserver builds cleanly.

Thanks,
Pedro Alves
  
Yao Qi June 29, 2017, 11:45 a.m. UTC | #4
Pedro Alves <palves@redhat.com> writes:

> On 06/12/2017 09:41 AM, Yao Qi wrote:
>> struct target_desc is used by both GDBserver and IPA, but fields expedite_regs
>> and xmltarget are only used in GDBserver, so this patch wraps these two fields
>> by ifndef IN_PROCESS_AGENT.  This patch also changes regformats/regdat.sh to
>> generate .c files in this way too.
>
> OK.

I cherry-pick it to master, and rebuilt GDBserver.  Push it in.
  

Patch

diff --git a/gdb/gdbserver/tdesc.h b/gdb/gdbserver/tdesc.h
index ada879d..0341278 100644
--- a/gdb/gdbserver/tdesc.h
+++ b/gdb/gdbserver/tdesc.h
@@ -36,6 +36,7 @@  struct target_desc
   /* The register cache size, in bytes.  */
   int registers_size;
 
+#ifndef IN_PROCESS_AGENT
   /* An array of register names.  These are the "expedite" registers:
      registers whose values are sent along with stop replies.  */
   const char **expedite_regs;
@@ -45,6 +46,7 @@  struct target_desc
      verbatim XML code (prefixed with a '@') or else the name of the
      actual XML file to be used in place of "target.xml".  */
   const char *xmltarget;
+#endif
 };
 
 /* Copy target description SRC to DEST.  */
diff --git a/gdb/regformats/regdat.sh b/gdb/regformats/regdat.sh
index 4c73352..651f703 100755
--- a/gdb/regformats/regdat.sh
+++ b/gdb/regformats/regdat.sh
@@ -179,8 +179,11 @@  init_registers_${name} (void)
 
   result->reg_defs = regs_${name};
   result->num_registers = sizeof (regs_${name}) / sizeof (regs_${name}[0]);
+
+#ifndef IN_PROCESS_AGENT
   result->expedite_regs = expedite_regs_${name};
   result->xmltarget = xmltarget_${name};
+#endif
 
   init_target_desc (result);