gdb: Fix build failure in xml-tdesc.c without expat.

Message ID 1455271799-20446-1-git-send-email-koriakin@0x04.net
State New, archived
Headers

Commit Message

Marcin Kościelnicki Feb. 12, 2016, 10:09 a.m. UTC
  Introduced by 18d3cec54e1b4fce278dba436484846f8048d7d6.

gdb/ChangeLog:

	* xml-tdesc.c (target_fetch_description_xml): Warn and return NULL
	when built without expat.
---
How about that?

 gdb/ChangeLog   |  5 +++++
 gdb/xml-tdesc.c | 13 +++++++++++++
 2 files changed, 18 insertions(+)
  

Comments

Pedro Alves Feb. 12, 2016, 10:19 a.m. UTC | #1
On 02/12/2016 10:09 AM, Marcin Kościelnicki wrote:
> Introduced by 18d3cec54e1b4fce278dba436484846f8048d7d6.
> 
> gdb/ChangeLog:
> 
> 	* xml-tdesc.c (target_fetch_description_xml): Warn and return NULL
> 	when built without expat.
> ---
> How about that?

There's a standard CL format for conditionally compiled code:

	* xml-tdesc.c (target_fetch_description_xml) [!HAVE_LIBEXPAT]: Warn
	and return NULL.

OK with that change.

Thanks,
Pedro Alves
  
Marcin Kościelnicki Feb. 12, 2016, 10:21 a.m. UTC | #2
On 12/02/16 11:19, Pedro Alves wrote:
> On 02/12/2016 10:09 AM, Marcin Kościelnicki wrote:
>> Introduced by 18d3cec54e1b4fce278dba436484846f8048d7d6.
>>
>> gdb/ChangeLog:
>>
>> 	* xml-tdesc.c (target_fetch_description_xml): Warn and return NULL
>> 	when built without expat.
>> ---
>> How about that?
>
> There's a standard CL format for conditionally compiled code:
>
> 	* xml-tdesc.c (target_fetch_description_xml) [!HAVE_LIBEXPAT]: Warn
> 	and return NULL.
>
> OK with that change.
>
> Thanks,
> Pedro Alves
>

Thanks, pushed.
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e06fc3c..7e59266 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@ 
+2016-02-12  Marcin Kościelnicki  <koriakin@0x04.net>
+
+	* xml-tdesc.c (target_fetch_description_xml): Return NULL when
+	built without expat.
+
 2016-02-12  Markus Metzger  <markus.t.metzger@intel.com>
 
 	* frame.h (skip_tailcall_frames): Update comment.
diff --git a/gdb/xml-tdesc.c b/gdb/xml-tdesc.c
index 4625b60..b5439e5 100644
--- a/gdb/xml-tdesc.c
+++ b/gdb/xml-tdesc.c
@@ -638,6 +638,18 @@  target_read_description_xml (struct target_ops *ops)
 char *
 target_fetch_description_xml (struct target_ops *ops)
 {
+#if !defined(HAVE_LIBEXPAT)
+  static int have_warned;
+
+  if (!have_warned)
+    {
+      have_warned = 1;
+      warning (_("Can not fetch XML target description; XML support was "
+		 "disabled at compile time"));
+    }
+
+  return NULL;
+#else
   struct target_desc *tdesc;
   char *tdesc_str;
   char *expanded_text;
@@ -659,4 +671,5 @@  target_fetch_description_xml (struct target_ops *ops)
     }
 
   return expanded_text;
+#endif
 }