aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbarch.c
diff options
context:
space:
mode:
authorSergio Durigan Junior <sergiodj@redhat.com>2013-12-19 18:53:40 -0200
committerSergio Durigan Junior <sergiodj@redhat.com>2013-12-19 18:53:40 -0200
commit05c0465e16a5e2db92f8975aebf2bb5aacb1c542 (patch)
tree2c42959c2f998b32a36beab6af3bdd7a73744a0c /gdb/gdbarch.c
parent9ef5d938819dff73d7640a2654b07df64670d7f9 (diff)
downloadgdb-05c0465e16a5e2db92f8975aebf2bb5aacb1c542.zip
gdb-05c0465e16a5e2db92f8975aebf2bb5aacb1c542.tar.gz
gdb-05c0465e16a5e2db92f8975aebf2bb5aacb1c542.tar.bz2
Extend SystemTap SDT probe argument parser
This patch extends the current generic parser for SystemTap SDT probe arguments. It can be almost considered a cleanup, but the main point of it is actually to allow the generic parser to accept multiple prefixes and suffixes for the its operands (i.e., integers, register names, and register indirection). I have chosen to implement this as a list of const strings, and declare this list as "static" inside each target's method used to initialize gdbarch. This patch is actually a preparation for an upcoming patch for ARM, which implements the support for multiple integer prefixes (as defined by ARM's asm spec). And AArch64 will also need this, for the same reason. This patch was regtested on all architectures that it touches (i.e., i386, x86_64, ARM, PPC/PPC64, s390x and IA-64). No regressions were found. 2013-12-19 Sergio Durigan Junior <sergiodj@redhat.com> * amd64-tdep.c (amd64_init_abi): Declare SystemTap SDT probe argument prefixes and suffixes. Initialize gdbarch with them. * arm-linux-tdep.c (arm_linux_init_abi): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (stap_integer_prefix, stap_integer_suffix) (stap_register_prefix, stap_register_suffix) (stap_register_indirection_prefix) (stap_register_indirection_suffix): Declare as "const char *const *" instead of "const char *". Adjust printing function. Rename all of the variables to the plural. (pstring_list): New function. * i386-tdep.c (i386_elf_init_abi): Declare SystemTap SDT probe argument prefixes and suffixes. Initialize gdbarch with them. * ia64-linux-tdep.c (ia64_linux_init_abi): Likewise. * ppc-linux-tdep.c (ppc_linux_init_abi): Likewise. * s390-linux-tdep.c (s390_gdbarch_init): Likewise. * stap-probe.c (stap_is_generic_prefix): New function. (stap_is_register_prefix): Likewise. (stap_is_register_indirection_prefix): Likewise. (stap_is_integer_prefix): Likewise. (stap_generic_check_suffix): Likewise. (stap_check_integer_suffix): Likewise. (stap_check_register_suffix): Likewise. (stap_check_register_indirection_suffix): Likewise. (stap_parse_register_operand): Remove unecessary declarations for variables holding prefix and suffix information. Use the new functions listed above for checking for prefixes and suffixes. (stap_parse_single_operand): Likewise.
Diffstat (limited to 'gdb/gdbarch.c')
-rw-r--r--gdb/gdbarch.c185
1 files changed, 107 insertions, 78 deletions
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index fb3595f..f0881b6 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -86,6 +86,35 @@ pstring (const char *string)
return string;
}
+/* Helper function to print a list of strings, represented as "const
+ char *const *". The list is printed comma-separated. */
+
+static char *
+pstring_list (const char *const *list)
+{
+ static char ret[100];
+ const char *const *p;
+ size_t offset = 0;
+
+ if (list == NULL)
+ return "(null)";
+
+ ret[0] = '\0';
+ for (p = list; *p != NULL && offset < sizeof (ret); ++p)
+ {
+ size_t s = xsnprintf (ret + offset, sizeof (ret) - offset, "%s, ", *p);
+ offset += 2 + s;
+ }
+
+ if (offset > 0)
+ {
+ gdb_assert (offset - 2 < sizeof (ret));
+ ret[offset - 2] = '\0';
+ }
+
+ return ret;
+}
+
/* Maintain the struct gdbarch object. */
@@ -265,12 +294,12 @@ struct gdbarch
gdbarch_get_siginfo_type_ftype *get_siginfo_type;
gdbarch_record_special_symbol_ftype *record_special_symbol;
gdbarch_get_syscall_number_ftype *get_syscall_number;
- const char * stap_integer_prefix;
- const char * stap_integer_suffix;
- const char * stap_register_prefix;
- const char * stap_register_suffix;
- const char * stap_register_indirection_prefix;
- const char * stap_register_indirection_suffix;
+ const char *const * stap_integer_prefixes;
+ const char *const * stap_integer_suffixes;
+ const char *const * stap_register_prefixes;
+ const char *const * stap_register_suffixes;
+ const char *const * stap_register_indirection_prefixes;
+ const char *const * stap_register_indirection_suffixes;
const char * stap_gdb_register_prefix;
const char * stap_gdb_register_suffix;
gdbarch_stap_is_single_operand_ftype *stap_is_single_operand;
@@ -438,12 +467,12 @@ struct gdbarch startup_gdbarch =
0, /* get_siginfo_type */
0, /* record_special_symbol */
0, /* get_syscall_number */
- 0, /* stap_integer_prefix */
- 0, /* stap_integer_suffix */
- 0, /* stap_register_prefix */
- 0, /* stap_register_suffix */
- 0, /* stap_register_indirection_prefix */
- 0, /* stap_register_indirection_suffix */
+ 0, /* stap_integer_prefixes */
+ 0, /* stap_integer_suffixes */
+ 0, /* stap_register_prefixes */
+ 0, /* stap_register_suffixes */
+ 0, /* stap_register_indirection_prefixes */
+ 0, /* stap_register_indirection_suffixes */
0, /* stap_gdb_register_prefix */
0, /* stap_gdb_register_suffix */
0, /* stap_is_single_operand */
@@ -744,12 +773,12 @@ verify_gdbarch (struct gdbarch *gdbarch)
/* Skip verify of get_siginfo_type, has predicate. */
/* Skip verify of record_special_symbol, has predicate. */
/* Skip verify of get_syscall_number, has predicate. */
- /* Skip verify of stap_integer_prefix, invalid_p == 0 */
- /* Skip verify of stap_integer_suffix, invalid_p == 0 */
- /* Skip verify of stap_register_prefix, invalid_p == 0 */
- /* Skip verify of stap_register_suffix, invalid_p == 0 */
- /* Skip verify of stap_register_indirection_prefix, invalid_p == 0 */
- /* Skip verify of stap_register_indirection_suffix, invalid_p == 0 */
+ /* Skip verify of stap_integer_prefixes, invalid_p == 0 */
+ /* Skip verify of stap_integer_suffixes, invalid_p == 0 */
+ /* Skip verify of stap_register_prefixes, invalid_p == 0 */
+ /* Skip verify of stap_register_suffixes, invalid_p == 0 */
+ /* Skip verify of stap_register_indirection_prefixes, invalid_p == 0 */
+ /* Skip verify of stap_register_indirection_suffixes, invalid_p == 0 */
/* Skip verify of stap_gdb_register_prefix, invalid_p == 0 */
/* Skip verify of stap_gdb_register_suffix, invalid_p == 0 */
/* Skip verify of stap_is_single_operand, has predicate. */
@@ -1351,11 +1380,11 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: stap_gdb_register_suffix = %s\n",
pstring (gdbarch->stap_gdb_register_suffix));
fprintf_unfiltered (file,
- "gdbarch_dump: stap_integer_prefix = %s\n",
- pstring (gdbarch->stap_integer_prefix));
+ "gdbarch_dump: stap_integer_prefixes = %s\n",
+ pstring_list (gdbarch->stap_integer_prefixes));
fprintf_unfiltered (file,
- "gdbarch_dump: stap_integer_suffix = %s\n",
- pstring (gdbarch->stap_integer_suffix));
+ "gdbarch_dump: stap_integer_suffixes = %s\n",
+ pstring_list (gdbarch->stap_integer_suffixes));
fprintf_unfiltered (file,
"gdbarch_dump: gdbarch_stap_is_single_operand_p() = %d\n",
gdbarch_stap_is_single_operand_p (gdbarch));
@@ -1369,17 +1398,17 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file)
"gdbarch_dump: stap_parse_special_token = <%s>\n",
host_address_to_string (gdbarch->stap_parse_special_token));
fprintf_unfiltered (file,
- "gdbarch_dump: stap_register_indirection_prefix = %s\n",
- pstring (gdbarch->stap_register_indirection_prefix));
+ "gdbarch_dump: stap_register_indirection_prefixes = %s\n",
+ pstring_list (gdbarch->stap_register_indirection_prefixes));
fprintf_unfiltered (file,
- "gdbarch_dump: stap_register_indirection_suffix = %s\n",
- pstring (gdbarch->stap_register_indirection_suffix));
+ "gdbarch_dump: stap_register_indirection_suffixes = %s\n",
+ pstring_list (gdbarch->stap_register_indirection_suffixes));
fprintf_unfiltered (file,
- "gdbarch_dump: stap_register_prefix = %s\n",
- pstring (gdbarch->stap_register_prefix));
+ "gdbarch_dump: stap_register_prefixes = %s\n",
+ pstring_list (gdbarch->stap_register_prefixes));
fprintf_unfiltered (file,
- "gdbarch_dump: stap_register_suffix = %s\n",
- pstring (gdbarch->stap_register_suffix));
+ "gdbarch_dump: stap_register_suffixes = %s\n",
+ pstring_list (gdbarch->stap_register_suffixes));
fprintf_unfiltered (file,
"gdbarch_dump: gdbarch_static_transform_name_p() = %d\n",
gdbarch_static_transform_name_p (gdbarch));
@@ -4004,106 +4033,106 @@ set_gdbarch_get_syscall_number (struct gdbarch *gdbarch,
gdbarch->get_syscall_number = get_syscall_number;
}
-const char *
-gdbarch_stap_integer_prefix (struct gdbarch *gdbarch)
+const char *const *
+gdbarch_stap_integer_prefixes (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Skip verify of stap_integer_prefix, invalid_p == 0 */
+ /* Skip verify of stap_integer_prefixes, invalid_p == 0 */
if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_integer_prefix called\n");
- return gdbarch->stap_integer_prefix;
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_integer_prefixes called\n");
+ return gdbarch->stap_integer_prefixes;
}
void
-set_gdbarch_stap_integer_prefix (struct gdbarch *gdbarch,
- const char * stap_integer_prefix)
+set_gdbarch_stap_integer_prefixes (struct gdbarch *gdbarch,
+ const char *const * stap_integer_prefixes)
{
- gdbarch->stap_integer_prefix = stap_integer_prefix;
+ gdbarch->stap_integer_prefixes = stap_integer_prefixes;
}
-const char *
-gdbarch_stap_integer_suffix (struct gdbarch *gdbarch)
+const char *const *
+gdbarch_stap_integer_suffixes (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Skip verify of stap_integer_suffix, invalid_p == 0 */
+ /* Skip verify of stap_integer_suffixes, invalid_p == 0 */
if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_integer_suffix called\n");
- return gdbarch->stap_integer_suffix;
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_integer_suffixes called\n");
+ return gdbarch->stap_integer_suffixes;
}
void
-set_gdbarch_stap_integer_suffix (struct gdbarch *gdbarch,
- const char * stap_integer_suffix)
+set_gdbarch_stap_integer_suffixes (struct gdbarch *gdbarch,
+ const char *const * stap_integer_suffixes)
{
- gdbarch->stap_integer_suffix = stap_integer_suffix;
+ gdbarch->stap_integer_suffixes = stap_integer_suffixes;
}
-const char *
-gdbarch_stap_register_prefix (struct gdbarch *gdbarch)
+const char *const *
+gdbarch_stap_register_prefixes (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Skip verify of stap_register_prefix, invalid_p == 0 */
+ /* Skip verify of stap_register_prefixes, invalid_p == 0 */
if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_prefix called\n");
- return gdbarch->stap_register_prefix;
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_prefixes called\n");
+ return gdbarch->stap_register_prefixes;
}
void
-set_gdbarch_stap_register_prefix (struct gdbarch *gdbarch,
- const char * stap_register_prefix)
+set_gdbarch_stap_register_prefixes (struct gdbarch *gdbarch,
+ const char *const * stap_register_prefixes)
{
- gdbarch->stap_register_prefix = stap_register_prefix;
+ gdbarch->stap_register_prefixes = stap_register_prefixes;
}
-const char *
-gdbarch_stap_register_suffix (struct gdbarch *gdbarch)
+const char *const *
+gdbarch_stap_register_suffixes (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Skip verify of stap_register_suffix, invalid_p == 0 */
+ /* Skip verify of stap_register_suffixes, invalid_p == 0 */
if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_suffix called\n");
- return gdbarch->stap_register_suffix;
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_suffixes called\n");
+ return gdbarch->stap_register_suffixes;
}
void
-set_gdbarch_stap_register_suffix (struct gdbarch *gdbarch,
- const char * stap_register_suffix)
+set_gdbarch_stap_register_suffixes (struct gdbarch *gdbarch,
+ const char *const * stap_register_suffixes)
{
- gdbarch->stap_register_suffix = stap_register_suffix;
+ gdbarch->stap_register_suffixes = stap_register_suffixes;
}
-const char *
-gdbarch_stap_register_indirection_prefix (struct gdbarch *gdbarch)
+const char *const *
+gdbarch_stap_register_indirection_prefixes (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Skip verify of stap_register_indirection_prefix, invalid_p == 0 */
+ /* Skip verify of stap_register_indirection_prefixes, invalid_p == 0 */
if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_indirection_prefix called\n");
- return gdbarch->stap_register_indirection_prefix;
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_indirection_prefixes called\n");
+ return gdbarch->stap_register_indirection_prefixes;
}
void
-set_gdbarch_stap_register_indirection_prefix (struct gdbarch *gdbarch,
- const char * stap_register_indirection_prefix)
+set_gdbarch_stap_register_indirection_prefixes (struct gdbarch *gdbarch,
+ const char *const * stap_register_indirection_prefixes)
{
- gdbarch->stap_register_indirection_prefix = stap_register_indirection_prefix;
+ gdbarch->stap_register_indirection_prefixes = stap_register_indirection_prefixes;
}
-const char *
-gdbarch_stap_register_indirection_suffix (struct gdbarch *gdbarch)
+const char *const *
+gdbarch_stap_register_indirection_suffixes (struct gdbarch *gdbarch)
{
gdb_assert (gdbarch != NULL);
- /* Skip verify of stap_register_indirection_suffix, invalid_p == 0 */
+ /* Skip verify of stap_register_indirection_suffixes, invalid_p == 0 */
if (gdbarch_debug >= 2)
- fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_indirection_suffix called\n");
- return gdbarch->stap_register_indirection_suffix;
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_stap_register_indirection_suffixes called\n");
+ return gdbarch->stap_register_indirection_suffixes;
}
void
-set_gdbarch_stap_register_indirection_suffix (struct gdbarch *gdbarch,
- const char * stap_register_indirection_suffix)
+set_gdbarch_stap_register_indirection_suffixes (struct gdbarch *gdbarch,
+ const char *const * stap_register_indirection_suffixes)
{
- gdbarch->stap_register_indirection_suffix = stap_register_indirection_suffix;
+ gdbarch->stap_register_indirection_suffixes = stap_register_indirection_suffixes;
}
const char *