• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Révision7042632bf7976d29889ba89fe4867654c5f38e2d (tree)
l'heure2018-01-23 21:37:43
AuteurPhilipp Rudo <prudo@linu...>
CommiterAndreas Arnez

Message de Log

s390: Hook s390 into OSABI mechanism

Do what the title says and distinguish between 31- and 64-bit systems.
The goal is to init the OSABI as late as possible in gdbarch_init so the
OSABI has the chance to overwrite the defaults.

There are two pitfalls to be aware of:

First, the dwarf2 unwinder must be appended before the OSABI is
initialized. Otherwise the OS could add a default unwinder which always
takes control before the dwarf unwinder even gets a chance.

Second, tdesc_use_registers has to be handled with extra care. It sets
several gdbarch hooks, especially gdbarch_register_name, which has to be
overwritten again after the call. Furthermore it deletes the tdesc_data
without checking. Therefore there must not be a call to
tdesc_data_cleanup afterwards or GDB will crash with a double free.

gdb/ChangeLog:

* s390-linux-tdep.c (osabi.h): New include.
(s390_linux_init_abi_31, s390_linux_init_abi_64)
(s390_linux_init_abi_any): New functions.
(s390_gdbarch_init, _initialize_s390_tdep): Adjust.

Change Summary

Modification

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
11 2018-01-23 Philipp Rudo <prudo@linux.vnet.ibm.com>
22
3+ * s390-linux-tdep.c (osabi.h): New include.
4+ (s390_linux_init_abi_31, s390_linux_init_abi_64)
5+ (s390_linux_init_abi_any): New functions.
6+ (s390_gdbarch_init, _initialize_s390_tdep): Adjust.
7+
8+2018-01-23 Philipp Rudo <prudo@linux.vnet.ibm.com>
9+
310 * s390-linux-tdep.c (s390_gdbarch_init): Use gdb_assert for
411 tdesc_has_registers check
512
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -30,6 +30,7 @@
3030 #include "gdbcore.h"
3131 #include "gdbcmd.h"
3232 #include "objfiles.h"
33+#include "osabi.h"
3334 #include "regcache.h"
3435 #include "trad-frame.h"
3536 #include "frame-base.h"
@@ -8017,32 +8018,107 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
80178018 struct tdesc_arch_data *tdesc_data = tdesc_data_alloc ();
80188019 info.tdesc_data = tdesc_data;
80198020
8020- /* Default ABI and register size. */
8021+ set_gdbarch_believe_pcc_promotion (gdbarch, 0);
8022+ set_gdbarch_char_signed (gdbarch, 0);
8023+
8024+ /* S/390 GNU/Linux uses either 64-bit or 128-bit long doubles.
8025+ We can safely let them default to 128-bit, since the debug info
8026+ will give the size of type actually used in each case. */
8027+ set_gdbarch_long_double_bit (gdbarch, 128);
8028+ set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
8029+
8030+ /* Amount PC must be decremented by after a breakpoint. This is
8031+ often the number of bytes returned by gdbarch_breakpoint_from_pc but not
8032+ always. */
8033+ set_gdbarch_decr_pc_after_break (gdbarch, 2);
8034+ /* Stack grows downward. */
8035+ set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
8036+ set_gdbarch_breakpoint_kind_from_pc (gdbarch, s390_breakpoint::kind_from_pc);
8037+ set_gdbarch_sw_breakpoint_from_kind (gdbarch, s390_breakpoint::bp_from_kind);
8038+ set_gdbarch_software_single_step (gdbarch, s390_software_single_step);
8039+ set_gdbarch_displaced_step_hw_singlestep (gdbarch, s390_displaced_step_hw_singlestep);
8040+ set_gdbarch_skip_prologue (gdbarch, s390_skip_prologue);
8041+ set_gdbarch_stack_frame_destroyed_p (gdbarch, s390_stack_frame_destroyed_p);
8042+
8043+ set_gdbarch_num_regs (gdbarch, S390_NUM_REGS);
8044+ set_gdbarch_sp_regnum (gdbarch, S390_SP_REGNUM);
8045+ set_gdbarch_fp0_regnum (gdbarch, S390_F0_REGNUM);
8046+ set_gdbarch_stab_reg_to_regnum (gdbarch, s390_dwarf_reg_to_regnum);
8047+ set_gdbarch_dwarf2_reg_to_regnum (gdbarch, s390_dwarf_reg_to_regnum);
8048+ set_gdbarch_value_from_register (gdbarch, s390_value_from_register);
8049+ set_gdbarch_guess_tracepoint_registers (gdbarch, s390_guess_tracepoint_registers);
8050+ set_gdbarch_pseudo_register_read (gdbarch, s390_pseudo_register_read);
8051+ set_gdbarch_pseudo_register_write (gdbarch, s390_pseudo_register_write);
8052+ set_tdesc_pseudo_register_name (gdbarch, s390_pseudo_register_name);
8053+ set_tdesc_pseudo_register_type (gdbarch, s390_pseudo_register_type);
8054+ set_tdesc_pseudo_register_reggroup_p (gdbarch,
8055+ s390_pseudo_register_reggroup_p);
8056+ set_gdbarch_ax_pseudo_register_collect (gdbarch,
8057+ s390_ax_pseudo_register_collect);
8058+ set_gdbarch_ax_pseudo_register_push_stack
8059+ (gdbarch, s390_ax_pseudo_register_push_stack);
8060+ set_gdbarch_gen_return_address (gdbarch, s390_gen_return_address);
8061+
8062+ /* Inferior function calls. */
8063+ set_gdbarch_push_dummy_call (gdbarch, s390_push_dummy_call);
8064+ set_gdbarch_dummy_id (gdbarch, s390_dummy_id);
8065+ set_gdbarch_frame_align (gdbarch, s390_frame_align);
8066+ set_gdbarch_return_value (gdbarch, s390_return_value);
8067+
8068+ /* Frame handling. */
8069+ dwarf2_frame_set_init_reg (gdbarch, s390_dwarf2_frame_init_reg);
8070+ dwarf2_frame_set_adjust_regnum (gdbarch, s390_adjust_frame_regnum);
8071+ dwarf2_append_unwinders (gdbarch);
8072+ set_gdbarch_unwind_pc (gdbarch, s390_unwind_pc);
8073+ set_gdbarch_unwind_sp (gdbarch, s390_unwind_sp);
8074+
8075+ /* Displaced stepping. */
8076+ set_gdbarch_displaced_step_copy_insn (gdbarch,
8077+ s390_displaced_step_copy_insn);
8078+ set_gdbarch_displaced_step_fixup (gdbarch, s390_displaced_step_fixup);
8079+ set_gdbarch_displaced_step_location (gdbarch, linux_displaced_step_location);
8080+ set_gdbarch_max_insn_length (gdbarch, S390_MAX_INSTR_SIZE);
8081+
80218082 switch (info.bfd_arch_info->mach)
80228083 {
80238084 case bfd_mach_s390_31:
8024- tdep->abi = ABI_LINUX_S390;
8085+ set_gdbarch_addr_bits_remove (gdbarch, s390_addr_bits_remove);
80258086 break;
80268087
80278088 case bfd_mach_s390_64:
8028- tdep->abi = ABI_LINUX_ZSERIES;
8089+ set_gdbarch_long_bit (gdbarch, 64);
8090+ set_gdbarch_long_long_bit (gdbarch, 64);
8091+ set_gdbarch_ptr_bit (gdbarch, 64);
8092+ set_gdbarch_address_class_type_flags (gdbarch,
8093+ s390_address_class_type_flags);
8094+ set_gdbarch_address_class_type_flags_to_name (gdbarch,
8095+ s390_address_class_type_flags_to_name);
8096+ set_gdbarch_address_class_name_to_type_flags (gdbarch,
8097+ s390_address_class_name_to_type_flags);
80298098 break;
8030-
8031- default:
8032- xfree (tdep);
8033- gdbarch_free (gdbarch);
8034- return NULL;
80358099 }
80368100
8037- /* Use default target description if none provided by the target. */
8038- if (!tdesc_has_registers (tdesc))
8039- {
8040- if (tdep->abi == ABI_LINUX_S390)
8041- tdesc = tdesc_s390_linux32;
8042- else
8043- tdesc = tdesc_s390x_linux64;
8044- }
8045- tdep->tdesc = tdesc;
8101+ /* SystemTap functions. */
8102+ set_gdbarch_stap_register_prefixes (gdbarch, stap_register_prefixes);
8103+ set_gdbarch_stap_register_indirection_prefixes (gdbarch,
8104+ stap_register_indirection_prefixes);
8105+ set_gdbarch_stap_register_indirection_suffixes (gdbarch,
8106+ stap_register_indirection_suffixes);
8107+
8108+ set_gdbarch_disassembler_options (gdbarch, &s390_disassembler_options);
8109+ set_gdbarch_valid_disassembler_options (gdbarch,
8110+ disassembler_options_s390 ());
8111+
8112+ /* Process record-replay */
8113+ set_gdbarch_process_record (gdbarch, s390_process_record);
8114+
8115+ /* Miscellaneous. */
8116+ set_gdbarch_stap_is_single_operand (gdbarch, s390_stap_is_single_operand);
8117+ set_gdbarch_gcc_target_options (gdbarch, s390_gcc_target_options);
8118+ set_gdbarch_gnu_triplet_regexp (gdbarch, s390_gnu_triplet_regexp);
8119+
8120+ /* Initialize the OSABI. */
8121+ gdbarch_init_osabi (info, gdbarch);
80468122
80478123 /* Check any target description for validity. */
80488124 gdb_assert (tdesc_has_registers (tdep->tdesc));
@@ -8085,51 +8161,6 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
80858161 return arches->gdbarch;
80868162 }
80878163
8088- set_gdbarch_believe_pcc_promotion (gdbarch, 0);
8089- set_gdbarch_char_signed (gdbarch, 0);
8090-
8091- /* S/390 GNU/Linux uses either 64-bit or 128-bit long doubles.
8092- We can safely let them default to 128-bit, since the debug info
8093- will give the size of type actually used in each case. */
8094- set_gdbarch_long_double_bit (gdbarch, 128);
8095- set_gdbarch_long_double_format (gdbarch, floatformats_ia64_quad);
8096-
8097- /* Amount PC must be decremented by after a breakpoint. This is
8098- often the number of bytes returned by gdbarch_breakpoint_from_pc but not
8099- always. */
8100- set_gdbarch_decr_pc_after_break (gdbarch, 2);
8101- /* Stack grows downward. */
8102- set_gdbarch_inner_than (gdbarch, core_addr_lessthan);
8103- set_gdbarch_breakpoint_kind_from_pc (gdbarch, s390_breakpoint::kind_from_pc);
8104- set_gdbarch_sw_breakpoint_from_kind (gdbarch, s390_breakpoint::bp_from_kind);
8105- set_gdbarch_software_single_step (gdbarch, s390_software_single_step);
8106- set_gdbarch_displaced_step_hw_singlestep (gdbarch, s390_displaced_step_hw_singlestep);
8107- set_gdbarch_skip_prologue (gdbarch, s390_skip_prologue);
8108- set_gdbarch_stack_frame_destroyed_p (gdbarch, s390_stack_frame_destroyed_p);
8109-
8110- set_gdbarch_num_regs (gdbarch, S390_NUM_REGS);
8111- set_gdbarch_sp_regnum (gdbarch, S390_SP_REGNUM);
8112- set_gdbarch_fp0_regnum (gdbarch, S390_F0_REGNUM);
8113- set_gdbarch_stab_reg_to_regnum (gdbarch, s390_dwarf_reg_to_regnum);
8114- set_gdbarch_dwarf2_reg_to_regnum (gdbarch, s390_dwarf_reg_to_regnum);
8115- set_gdbarch_value_from_register (gdbarch, s390_value_from_register);
8116- set_gdbarch_core_read_description (gdbarch, s390_core_read_description);
8117- set_gdbarch_iterate_over_regset_sections (gdbarch,
8118- s390_iterate_over_regset_sections);
8119- set_gdbarch_cannot_store_register (gdbarch, s390_cannot_store_register);
8120- set_gdbarch_write_pc (gdbarch, s390_write_pc);
8121- set_gdbarch_guess_tracepoint_registers (gdbarch, s390_guess_tracepoint_registers);
8122- set_gdbarch_pseudo_register_read (gdbarch, s390_pseudo_register_read);
8123- set_gdbarch_pseudo_register_write (gdbarch, s390_pseudo_register_write);
8124- set_tdesc_pseudo_register_name (gdbarch, s390_pseudo_register_name);
8125- set_tdesc_pseudo_register_type (gdbarch, s390_pseudo_register_type);
8126- set_tdesc_pseudo_register_reggroup_p (gdbarch,
8127- s390_pseudo_register_reggroup_p);
8128- set_gdbarch_ax_pseudo_register_collect (gdbarch,
8129- s390_ax_pseudo_register_collect);
8130- set_gdbarch_ax_pseudo_register_push_stack
8131- (gdbarch, s390_ax_pseudo_register_push_stack);
8132- set_gdbarch_gen_return_address (gdbarch, s390_gen_return_address);
81338164 tdesc_use_registers (gdbarch, tdep->tdesc, tdesc_data);
81348165 set_gdbarch_register_name (gdbarch, s390_register_name);
81358166
@@ -8151,93 +8182,83 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
81518182 set_gdbarch_pc_regnum (gdbarch, tdep->pc_regnum);
81528183 set_gdbarch_num_pseudo_regs (gdbarch, last_pseudo_reg - first_pseudo_reg);
81538184
8154- /* Inferior function calls. */
8155- set_gdbarch_push_dummy_call (gdbarch, s390_push_dummy_call);
8156- set_gdbarch_dummy_id (gdbarch, s390_dummy_id);
8157- set_gdbarch_frame_align (gdbarch, s390_frame_align);
8158- set_gdbarch_return_value (gdbarch, s390_return_value);
8159-
8160- /* Syscall handling. */
8161- set_gdbarch_get_syscall_number (gdbarch, s390_linux_get_syscall_number);
8162-
8163- /* Frame handling. */
8164- dwarf2_frame_set_init_reg (gdbarch, s390_dwarf2_frame_init_reg);
8165- dwarf2_frame_set_adjust_regnum (gdbarch, s390_adjust_frame_regnum);
8166- dwarf2_append_unwinders (gdbarch);
81678185 frame_base_append_sniffer (gdbarch, dwarf2_frame_base_sniffer);
81688186 frame_unwind_append_unwinder (gdbarch, &s390_stub_frame_unwind);
8169- frame_unwind_append_unwinder (gdbarch, &s390_sigtramp_frame_unwind);
81708187 frame_unwind_append_unwinder (gdbarch, &s390_frame_unwind);
81718188 frame_base_set_default (gdbarch, &s390_frame_base);
8172- set_gdbarch_unwind_pc (gdbarch, s390_unwind_pc);
8173- set_gdbarch_unwind_sp (gdbarch, s390_unwind_sp);
81748189
8175- /* Displaced stepping. */
8176- set_gdbarch_displaced_step_copy_insn (gdbarch,
8177- s390_displaced_step_copy_insn);
8178- set_gdbarch_displaced_step_fixup (gdbarch, s390_displaced_step_fixup);
8179- set_gdbarch_displaced_step_location (gdbarch, linux_displaced_step_location);
8180- set_gdbarch_max_insn_length (gdbarch, S390_MAX_INSTR_SIZE);
8190+ return gdbarch;
8191+}
81818192
8182- /* Note that GNU/Linux is the only OS supported on this
8183- platform. */
8184- linux_init_abi (info, gdbarch);
8193+/* Initialize OSABI common for GNU/Linux on 31- and 64-bit systems. */
81858194
8186- switch (tdep->abi)
8187- {
8188- case ABI_LINUX_S390:
8189- set_gdbarch_addr_bits_remove (gdbarch, s390_addr_bits_remove);
8190- set_solib_svr4_fetch_link_map_offsets
8191- (gdbarch, svr4_ilp32_fetch_link_map_offsets);
8195+static void
8196+s390_linux_init_abi_any (struct gdbarch_info info, struct gdbarch *gdbarch)
8197+{
8198+ linux_init_abi (info, gdbarch);
81928199
8193- set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_S390);
8194- break;
8200+ /* Register handling. */
8201+ set_gdbarch_core_read_description (gdbarch, s390_core_read_description);
8202+ set_gdbarch_iterate_over_regset_sections (gdbarch,
8203+ s390_iterate_over_regset_sections);
8204+ set_gdbarch_write_pc (gdbarch, s390_write_pc);
8205+ set_gdbarch_cannot_store_register (gdbarch, s390_cannot_store_register);
81958206
8196- case ABI_LINUX_ZSERIES:
8197- set_gdbarch_long_bit (gdbarch, 64);
8198- set_gdbarch_long_long_bit (gdbarch, 64);
8199- set_gdbarch_ptr_bit (gdbarch, 64);
8200- set_solib_svr4_fetch_link_map_offsets
8201- (gdbarch, svr4_lp64_fetch_link_map_offsets);
8202- set_gdbarch_address_class_type_flags (gdbarch,
8203- s390_address_class_type_flags);
8204- set_gdbarch_address_class_type_flags_to_name (gdbarch,
8205- s390_address_class_type_flags_to_name);
8206- set_gdbarch_address_class_name_to_type_flags (gdbarch,
8207- s390_address_class_name_to_type_flags);
8208- set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_S390X);
8209- break;
8210- }
8207+ /* Syscall handling. */
8208+ set_gdbarch_get_syscall_number (gdbarch, s390_linux_get_syscall_number);
82118209
8210+ /* Frame handling. */
8211+ frame_unwind_append_unwinder (gdbarch, &s390_sigtramp_frame_unwind);
82128212 set_gdbarch_skip_trampoline_code (gdbarch, find_solib_trampoline_target);
82138213
82148214 /* Enable TLS support. */
82158215 set_gdbarch_fetch_tls_load_module_address (gdbarch,
82168216 svr4_fetch_objfile_link_map);
82178217
8218- /* SystemTap functions. */
8219- set_gdbarch_stap_register_prefixes (gdbarch, stap_register_prefixes);
8220- set_gdbarch_stap_register_indirection_prefixes (gdbarch,
8221- stap_register_indirection_prefixes);
8222- set_gdbarch_stap_register_indirection_suffixes (gdbarch,
8223- stap_register_indirection_suffixes);
8224- set_gdbarch_stap_is_single_operand (gdbarch, s390_stap_is_single_operand);
8225- set_gdbarch_gcc_target_options (gdbarch, s390_gcc_target_options);
8226- set_gdbarch_gnu_triplet_regexp (gdbarch, s390_gnu_triplet_regexp);
8227-
82288218 /* Support reverse debugging. */
8229-
8230- set_gdbarch_process_record (gdbarch, s390_process_record);
82318219 set_gdbarch_process_record_signal (gdbarch, s390_linux_record_signal);
8232-
82338220 s390_init_linux_record_tdep (&s390_linux_record_tdep, ABI_LINUX_S390);
82348221 s390_init_linux_record_tdep (&s390x_linux_record_tdep, ABI_LINUX_ZSERIES);
8222+}
82358223
8236- set_gdbarch_disassembler_options (gdbarch, &s390_disassembler_options);
8237- set_gdbarch_valid_disassembler_options (gdbarch,
8238- disassembler_options_s390 ());
8224+/* Initialize OSABI for GNU/Linux on 31-bit systems. */
82398225
8240- return gdbarch;
8226+static void
8227+s390_linux_init_abi_31 (struct gdbarch_info info, struct gdbarch *gdbarch)
8228+{
8229+ const struct target_desc *tdesc = info.target_desc;
8230+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
8231+
8232+ tdep->abi = ABI_LINUX_S390;
8233+ if (!tdesc_has_registers (tdesc))
8234+ tdesc = tdesc_s390_linux32;
8235+ tdep->tdesc = tdesc;
8236+
8237+ s390_linux_init_abi_any (info, gdbarch);
8238+
8239+ set_solib_svr4_fetch_link_map_offsets (gdbarch,
8240+ svr4_ilp32_fetch_link_map_offsets);
8241+ set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_S390);
8242+}
8243+
8244+/* Initialize OSABI for GNU/Linux on 64-bit systems. */
8245+
8246+static void
8247+s390_linux_init_abi_64 (struct gdbarch_info info, struct gdbarch *gdbarch)
8248+{
8249+ const struct target_desc *tdesc = info.target_desc;
8250+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
8251+
8252+ tdep->abi = ABI_LINUX_ZSERIES;
8253+ if (!tdesc_has_registers (tdesc))
8254+ tdesc = tdesc_s390x_linux64;
8255+ tdep->tdesc = tdesc;
8256+
8257+ s390_linux_init_abi_any (info, gdbarch);
8258+
8259+ set_solib_svr4_fetch_link_map_offsets (gdbarch,
8260+ svr4_lp64_fetch_link_map_offsets);
8261+ set_xml_syscall_file_name (gdbarch, XML_SYSCALL_FILENAME_S390X);
82418262 }
82428263
82438264 void
@@ -8246,6 +8267,12 @@ _initialize_s390_tdep (void)
82468267 /* Hook us into the gdbarch mechanism. */
82478268 register_gdbarch_init (bfd_arch_s390, s390_gdbarch_init);
82488269
8270+ /* Hook us into the OSABI mechanism. */
8271+ gdbarch_register_osabi (bfd_arch_s390, bfd_mach_s390_31, GDB_OSABI_LINUX,
8272+ s390_linux_init_abi_31);
8273+ gdbarch_register_osabi (bfd_arch_s390, bfd_mach_s390_64, GDB_OSABI_LINUX,
8274+ s390_linux_init_abi_64);
8275+
82498276 /* Initialize the GNU/Linux target descriptions. */
82508277 initialize_tdesc_s390_linux32 ();
82518278 initialize_tdesc_s390_linux32v1 ();