On 11/13/2014 12:18 AM, Sergio Durigan Junior wrote:
> --- a/gdb/breakpoint.c
> +++ b/gdb/breakpoint.c
> @@ -8607,10 +8607,11 @@ print_it_catch_syscall (bpstat bs)
> ptid_t ptid;
> struct target_waitstatus last;
> struct syscall s;
> + struct gdbarch *gdbarch = target_gdbarch ();
I think this would better be bs->bp_location_at->gdbarch .
> @@ -8653,6 +8654,7 @@ print_one_catch_syscall (struct breakpoint *b,
> struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
> struct value_print_options opts;
> struct ui_out *uiout = current_uiout;
> + struct gdbarch *gdbarch = target_gdbarch ();
Here, we can use b->loc->gdbarch.
Later, to handle the case "catch syscall open" with multiple
inferiors of different archs, I think we'll end up with a
location for each inferior, or for each arch, and we'll iterate
over locations here. For now, I think we can assume there's only
one location.
Similarly for other places.
> @@ -15343,7 +15348,7 @@ static VEC (char_ptr) *
> catch_syscall_completer (struct cmd_list_element *cmd,
> const char *text, const char *word)
> {
> - const char **list = get_syscall_names ();
> + const char **list = get_syscall_names (target_gdbarch ());
> VEC (char_ptr) *retlist
> = (list == NULL) ? NULL : complete_on_enum (list, word, word);
This one is handling user input, so should be "get_current_arch ()":
/* Return "current" architecture. If the target is running, this is
the architecture of the selected frame. Otherwise, the "current"
architecture defaults to the target architecture.
This function should normally be called solely by the command
interpreter routines to determine the architecture to execute a
command in. */
struct gdbarch *
get_current_arch (void)
Thanks,
Pedro Alves
On Friday, November 14 2014, Pedro Alves wrote:
> On 11/13/2014 12:18 AM, Sergio Durigan Junior wrote:
>> --- a/gdb/breakpoint.c
>> +++ b/gdb/breakpoint.c
>> @@ -8607,10 +8607,11 @@ print_it_catch_syscall (bpstat bs)
>> ptid_t ptid;
>> struct target_waitstatus last;
>> struct syscall s;
>> + struct gdbarch *gdbarch = target_gdbarch ();
>
> I think this would better be bs->bp_location_at->gdbarch .
>
>> @@ -8653,6 +8654,7 @@ print_one_catch_syscall (struct breakpoint *b,
>> struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
>> struct value_print_options opts;
>> struct ui_out *uiout = current_uiout;
>> + struct gdbarch *gdbarch = target_gdbarch ();
>
> Here, we can use b->loc->gdbarch.
>
> Later, to handle the case "catch syscall open" with multiple
> inferiors of different archs, I think we'll end up with a
> location for each inferior, or for each arch, and we'll iterate
> over locations here. For now, I think we can assume there's only
> one location.
Hm, thanks for this insight. I was already wondering the best way to
deal with this problem. I will give it a try later.
> Similarly for other places.
>
>> @@ -15343,7 +15348,7 @@ static VEC (char_ptr) *
>> catch_syscall_completer (struct cmd_list_element *cmd,
>> const char *text, const char *word)
>> {
>> - const char **list = get_syscall_names ();
>> + const char **list = get_syscall_names (target_gdbarch ());
>> VEC (char_ptr) *retlist
>> = (list == NULL) ? NULL : complete_on_enum (list, word, word);
>
> This one is handling user input, so should be "get_current_arch ()":
>
> /* Return "current" architecture. If the target is running, this is
> the architecture of the selected frame. Otherwise, the "current"
> architecture defaults to the target architecture.
>
> This function should normally be called solely by the command
> interpreter routines to determine the architecture to execute a
> command in. */
> struct gdbarch *
> get_current_arch (void)
Thanks for the review. I fixed all the issues. I will concentrate on
the testcase now in order to get this patch in.
@@ -1663,7 +1663,7 @@ amd64_linux_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch)
tdep->register_reggroup_p = amd64_linux_register_reggroup_p;
/* Functions for 'catch syscall'. */
- set_xml_syscall_file_name (XML_SYSCALL_FILENAME_AMD64);
+ set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_AMD64);
set_gdbarch_get_syscall_number (gdbarch,
amd64_linux_get_syscall_number);
@@ -1468,7 +1468,7 @@ arm_linux_init_abi (struct gdbarch_info info,
tdep->syscall_next_pc = arm_linux_syscall_next_pc;
/* `catch syscall' */
- set_xml_syscall_file_name ("syscalls/arm-linux.xml");
+ set_xml_syscall_file_name (gdbarch, "syscalls/arm-linux.xml");
set_gdbarch_get_syscall_number (gdbarch, arm_linux_get_syscall_number);
/* Syscall record. */
@@ -157,7 +157,7 @@ bfin_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
tramp_frame_prepend_unwinder (gdbarch, &bfin_linux_sigframe);
/* Functions for 'catch syscall'. */
- set_xml_syscall_file_name ("syscalls/bfin-linux.xml");
+ set_xml_syscall_file_name (gdbarch, "syscalls/bfin-linux.xml");
set_gdbarch_get_syscall_number (gdbarch,
bfin_linux_get_syscall_number);
}
@@ -8607,10 +8607,11 @@ print_it_catch_syscall (bpstat bs)
ptid_t ptid;
struct target_waitstatus last;
struct syscall s;
+ struct gdbarch *gdbarch = target_gdbarch ();
get_last_target_status (&ptid, &last);
- get_syscall_by_number (last.value.syscall_number, &s);
+ get_syscall_by_number (gdbarch, last.value.syscall_number, &s);
annotate_catchpoint (b->number);
@@ -8653,6 +8654,7 @@ print_one_catch_syscall (struct breakpoint *b,
struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
struct value_print_options opts;
struct ui_out *uiout = current_uiout;
+ struct gdbarch *gdbarch = target_gdbarch ();
get_user_print_options (&opts);
/* Field 4, the address, is omitted (which makes the columns not
@@ -8679,7 +8681,7 @@ print_one_catch_syscall (struct breakpoint *b,
{
char *x = text;
struct syscall s;
- get_syscall_by_number (iter, &s);
+ get_syscall_by_number (gdbarch, iter, &s);
if (s.name != NULL)
text = xstrprintf ("%s%s, ", text, s.name);
@@ -8710,6 +8712,7 @@ static void
print_mention_catch_syscall (struct breakpoint *b)
{
struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
+ struct gdbarch *gdbarch = target_gdbarch ();
if (c->syscalls_to_be_caught)
{
@@ -8725,7 +8728,7 @@ print_mention_catch_syscall (struct breakpoint *b)
i++)
{
struct syscall s;
- get_syscall_by_number (iter, &s);
+ get_syscall_by_number (gdbarch, iter, &s);
if (s.name)
printf_filtered (" '%s' [%d]", s.name, s.number);
@@ -8746,6 +8749,7 @@ static void
print_recreate_catch_syscall (struct breakpoint *b, struct ui_file *fp)
{
struct syscall_catchpoint *c = (struct syscall_catchpoint *) b;
+ struct gdbarch *gdbarch = target_gdbarch ();
fprintf_unfiltered (fp, "catch syscall");
@@ -8759,7 +8763,7 @@ print_recreate_catch_syscall (struct breakpoint *b, struct ui_file *fp)
{
struct syscall s;
- get_syscall_by_number (iter, &s);
+ get_syscall_by_number (gdbarch, iter, &s);
if (s.name)
fprintf_unfiltered (fp, " %s", s.name);
else
@@ -12035,6 +12039,7 @@ catch_syscall_split_args (char *arg)
{
VEC(int) *result = NULL;
struct cleanup *cleanup = make_cleanup (VEC_cleanup (int), &result);
+ struct gdbarch *gdbarch = target_gdbarch ();
while (*arg != '\0')
{
@@ -12054,12 +12059,12 @@ catch_syscall_split_args (char *arg)
/* Check if the user provided a syscall name or a number. */
syscall_number = (int) strtol (cur_name, &endptr, 0);
if (*endptr == '\0')
- get_syscall_by_number (syscall_number, &s);
+ get_syscall_by_number (gdbarch, syscall_number, &s);
else
{
/* We have a name. Let's check if it's valid and convert it
to a number. */
- get_syscall_by_name (cur_name, &s);
+ get_syscall_by_name (gdbarch, cur_name, &s);
if (s.number == UNKNOWN_SYSCALL)
/* Here we have to issue an error instead of a warning,
@@ -12100,7 +12105,7 @@ this architecture yet."));
to get the syscall XML file loaded or, most important,
to display a warning to the user if there's no XML file
for his/her architecture. */
- get_syscall_by_number (0, &s);
+ get_syscall_by_number (gdbarch, 0, &s);
/* The allowed syntax is:
catch syscall
@@ -15343,7 +15348,7 @@ static VEC (char_ptr) *
catch_syscall_completer (struct cmd_list_element *cmd,
const char *text, const char *word)
{
- const char **list = get_syscall_names ();
+ const char **list = get_syscall_names (target_gdbarch ());
VEC (char_ptr) *retlist
= (list == NULL) ? NULL : complete_on_enum (list, word, word);
@@ -994,7 +994,7 @@ i386_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
displaced_step_at_entry_point);
/* Functions for 'catch syscall'. */
- set_xml_syscall_file_name (XML_SYSCALL_FILENAME_I386);
+ set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_I386);
set_gdbarch_get_syscall_number (gdbarch,
i386_linux_get_syscall_number);
@@ -1558,7 +1558,7 @@ mips_linux_init_abi (struct gdbarch_info info,
(gdbarch, svr4_ilp32_fetch_link_map_offsets);
tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_sigframe);
tramp_frame_prepend_unwinder (gdbarch, &mips_linux_o32_rt_sigframe);
- set_xml_syscall_file_name ("syscalls/mips-o32-linux.xml");
+ set_xml_syscall_file_name (gdbarch, "syscalls/mips-o32-linux.xml");
break;
case MIPS_ABI_N32:
set_gdbarch_get_longjmp_target (gdbarch,
@@ -1572,7 +1572,7 @@ mips_linux_init_abi (struct gdbarch_info info,
does not distinguish between quiet and signalling NaNs). */
set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n32_rt_sigframe);
- set_xml_syscall_file_name ("syscalls/mips-n32-linux.xml");
+ set_xml_syscall_file_name (gdbarch, "syscalls/mips-n32-linux.xml");
break;
case MIPS_ABI_N64:
set_gdbarch_get_longjmp_target (gdbarch,
@@ -1586,7 +1586,7 @@ mips_linux_init_abi (struct gdbarch_info info,
does not distinguish between quiet and signalling NaNs). */
set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
tramp_frame_prepend_unwinder (gdbarch, &mips_linux_n64_rt_sigframe);
- set_xml_syscall_file_name ("syscalls/mips-n64-linux.xml");
+ set_xml_syscall_file_name (gdbarch, "syscalls/mips-n64-linux.xml");
break;
default:
break;
@@ -1294,7 +1294,7 @@ ppc_linux_init_abi (struct gdbarch_info info,
(gdbarch, svr4_ilp32_fetch_link_map_offsets);
/* Setting the correct XML syscall filename. */
- set_xml_syscall_file_name (XML_SYSCALL_FILENAME_PPC);
+ set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_PPC);
/* Trampolines. */
tramp_frame_prepend_unwinder (gdbarch,
@@ -1346,7 +1346,7 @@ ppc_linux_init_abi (struct gdbarch_info info,
(gdbarch, svr4_lp64_fetch_link_map_offsets);
/* Setting the correct XML syscall filename. */
- set_xml_syscall_file_name (XML_SYSCALL_FILENAME_PPC64);
+ set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_PPC64);
/* Trampolines. */
tramp_frame_prepend_unwinder (gdbarch,
@@ -3107,7 +3107,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
set_solib_svr4_fetch_link_map_offsets
(gdbarch, svr4_ilp32_fetch_link_map_offsets);
- set_xml_syscall_file_name (XML_SYSCALL_FILENAME_S390);
+ set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_S390);
break;
case ABI_LINUX_ZSERIES:
@@ -3122,7 +3122,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
s390_address_class_type_flags_to_name);
set_gdbarch_address_class_name_to_type_flags (gdbarch,
s390_address_class_name_to_type_flags);
- set_xml_syscall_file_name (XML_SYSCALL_FILENAME_S390);
+ set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_S390);
break;
}
@@ -455,7 +455,7 @@ sparc32_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_write_pc (gdbarch, sparc_linux_write_pc);
/* Functions for 'catch syscall'. */
- set_xml_syscall_file_name (XML_SYSCALL_FILENAME_SPARC32);
+ set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_SPARC32);
set_gdbarch_get_syscall_number (gdbarch,
sparc32_linux_get_syscall_number);
@@ -336,7 +336,7 @@ sparc64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_write_pc (gdbarch, sparc64_linux_write_pc);
/* Functions for 'catch syscall'. */
- set_xml_syscall_file_name (XML_SYSCALL_FILENAME_SPARC64);
+ set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_SPARC64);
set_gdbarch_get_syscall_number (gdbarch,
sparc64_linux_get_syscall_number);
}