This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[pushed] Add STRINGIFY to gdb/common/preprocessor.h
- From: Pedro Alves <palves at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 22 Jun 2017 11:16:20 +0100
- Subject: [pushed] Add STRINGIFY to gdb/common/preprocessor.h
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 4C5EE6602
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4C5EE6602
I went ahead and pushed this in. I think it's fairly obvious.
We have several copies of this common idiom under gdb/ currently.
This commit moves them / factors them out to gdb/common/preprocessor.h.
gdb/ChangeLog:
2017-06-22 Pedro Alves <palves@redhat.com>
* common/agent.h: Include "common/preprocessor.h".
(STRINGIZE_1, STRINGIZE): Delete.
(IPA_SYM): Use STRINGIFY instead.
* common/preprocessor.h (STRINGIFY_1, STRINGIFY): New.
* compile/compile-c-support.c: Include "common/preprocessor.h".
(STR, STRINGIFY): Delete.
* ia64-libunwind-tdep.c: Include "common/preprocessor.h".
(STRINGIFY2, STRINGIFY): Delete.
---
gdb/common/agent.h | 6 +++---
gdb/common/preprocessor.h | 4 ++++
gdb/compile/compile-c-support.c | 4 +---
gdb/ia64-libunwind-tdep.c | 3 +--
4 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/gdb/common/agent.h b/gdb/common/agent.h
index 66f57ad..f24f482 100644
--- a/gdb/common/agent.h
+++ b/gdb/common/agent.h
@@ -20,16 +20,16 @@
#ifndef COMMON_AGENT_H
#define COMMON_AGENT_H
+#include "common/preprocessor.h"
+
int agent_run_command (int pid, const char *cmd, int len);
int agent_look_up_symbols (void *);
-#define STRINGIZE_1(STR) #STR
-#define STRINGIZE(STR) STRINGIZE_1(STR)
#define IPA_SYM_EXPORTED_NAME(SYM) gdb_agent_ ## SYM
#define IPA_SYM(SYM) \
{ \
- STRINGIZE (IPA_SYM_EXPORTED_NAME (SYM)), \
+ STRINGIFY (IPA_SYM_EXPORTED_NAME (SYM)), \
offsetof (struct ipa_sym_addresses, addr_ ## SYM) \
}
diff --git a/gdb/common/preprocessor.h b/gdb/common/preprocessor.h
index 6877344..3543a90 100644
--- a/gdb/common/preprocessor.h
+++ b/gdb/common/preprocessor.h
@@ -24,6 +24,10 @@
#define CONCAT_1(a, b) a ## b
#define CONCAT(a, b) CONCAT_1 (a, b)
+/* Stringification. */
+#define STRINGIFY_1(x) #x
+#define STRINGIFY(x) STRINGIFY_1 (x)
+
/* Escape parens out. Useful if you need to pass an argument that
includes commas to another macro. */
#define ESC(...) __VA_ARGS__
diff --git a/gdb/compile/compile-c-support.c b/gdb/compile/compile-c-support.c
index 2614570..3bec28c 100644
--- a/gdb/compile/compile-c-support.c
+++ b/gdb/compile/compile-c-support.c
@@ -26,6 +26,7 @@
#include "macroscope.h"
#include "regcache.h"
#include "common/function-view.h"
+#include "common/preprocessor.h"
/* See compile-internal.h. */
@@ -65,9 +66,6 @@ c_get_range_decl_name (const struct dynamic_prop *prop)
-#define STR(x) #x
-#define STRINGIFY(x) STR(x)
-
/* Helper function for c_get_compile_context. Open the GCC front-end
shared library and return the symbol specified by the current
GCC_C_FE_CONTEXT. */
diff --git a/gdb/ia64-libunwind-tdep.c b/gdb/ia64-libunwind-tdep.c
index 4b716c4..025c870 100644
--- a/gdb/ia64-libunwind-tdep.c
+++ b/gdb/ia64-libunwind-tdep.c
@@ -36,6 +36,7 @@
#include "ia64-libunwind-tdep.h"
#include "complaints.h"
+#include "common/preprocessor.h"
/* IA-64 is the only target that currently uses ia64-libunwind-tdep.
Note how UNW_TARGET, UNW_OBJ, etc. are compile time constants below.
@@ -99,8 +100,6 @@ struct libunwind_frame_cache
/* We need to qualify the function names with a platform-specific prefix
to match the names used by the libunwind library. The UNW_OBJ macro is
provided by the libunwind.h header file. */
-#define STRINGIFY2(name) #name
-#define STRINGIFY(name) STRINGIFY2(name)
#ifndef LIBUNWIND_SO
/* Use the stable ABI major version number. `libunwind-ia64.so' is a link time
--
2.5.5