• 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évision21f6f5ffc652e116e518fee29ebdc8fbfeeaa734 (tree)
l'heure2018-01-23 21:37:41
AuteurPhilipp Rudo <prudo@linu...>
CommiterAndreas Arnez

Message de Log

s390: Allocate gdbarch & tdep at start of gdbarch_init

Moving the allocation of gdbarch_tdep to the start of s390_gdbarch_init
allows us to use its fields for tracking the different features instead of
using separate variables. To make the code a little nicer move the actual
allocation and initialization to a separate function. Also move the
allocation of gdbarch to keep the two together.

gdb/ChangeLog:

* s390-linux-tdep (s390_abi_kind) <ABI_NONE>: New default field.
(gdbarch_tdep) <have_upper, have_vx>: New fields.
(s390_gdbarch_tdep_alloc): New function.
(s390_gdbarch_init): Allocate tdep at start and use its fields
instead of separate variables.

Change Summary

Modification

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,13 @@
11 2018-01-23 Philipp Rudo <prudo@linux.vnet.ibm.com>
22
3+ * s390-linux-tdep (s390_abi_kind) <ABI_NONE>: New default field.
4+ (gdbarch_tdep) <have_upper, have_vx>: New fields.
5+ (s390_gdbarch_tdep_alloc): New function.
6+ (s390_gdbarch_init): Allocate tdep at start and use its fields
7+ instead of separate variables.
8+
9+2018-01-23 Philipp Rudo <prudo@linux.vnet.ibm.com>
10+
311 * s390-linux-tdep.c (s390_gdbarch_init): Remove duplicate checks
412 when looking for cached gdbarch and add comment for remaining.
513
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -85,6 +85,7 @@ static char *s390_disassembler_options;
8585
8686 enum s390_abi_kind
8787 {
88+ ABI_NONE,
8889 ABI_LINUX_S390,
8990 ABI_LINUX_ZSERIES
9091 };
@@ -111,9 +112,11 @@ struct gdbarch_tdep
111112 int cc_regnum;
112113 int v0_full_regnum;
113114
115+ bool have_upper;
114116 int have_linux_v1;
115117 int have_linux_v2;
116118 int have_tdb;
119+ bool have_vx;
117120 bool have_gs;
118121 };
119122
@@ -7804,6 +7807,32 @@ s390_init_linux_record_tdep (struct linux_record_tdep *record_tdep,
78047807 record_tdep->ioctl_FIOQSIZE = 0x545e;
78057808 }
78067809
7810+/* Allocate and initialize new gdbarch_tdep. Caller is responsible to free
7811+ memory after use. */
7812+
7813+static struct gdbarch_tdep *
7814+s390_gdbarch_tdep_alloc ()
7815+{
7816+ struct gdbarch_tdep *tdep = XCNEW (struct gdbarch_tdep);
7817+
7818+ tdep->abi = ABI_NONE;
7819+ tdep->vector_abi = S390_VECTOR_ABI_NONE;
7820+
7821+ tdep->gpr_full_regnum = -1;
7822+ tdep->v0_full_regnum = -1;
7823+ tdep->pc_regnum = -1;
7824+ tdep->cc_regnum = -1;
7825+
7826+ tdep->have_upper = false;
7827+ tdep->have_linux_v1 = 0;
7828+ tdep->have_linux_v2 = 0;
7829+ tdep->have_tdb = 0;
7830+ tdep->have_vx = false;
7831+ tdep->have_gs = false;
7832+
7833+ return tdep;
7834+}
7835+
78077836 /* Set up gdbarch struct. */
78087837
78097838 static struct gdbarch *
@@ -7811,16 +7840,6 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
78117840 {
78127841 const struct target_desc *tdesc = info.target_desc;
78137842 struct tdesc_arch_data *tdesc_data = NULL;
7814- struct gdbarch *gdbarch;
7815- struct gdbarch_tdep *tdep;
7816- enum s390_abi_kind tdep_abi;
7817- enum s390_vector_abi_kind vector_abi;
7818- int have_upper = 0;
7819- int have_linux_v1 = 0;
7820- int have_linux_v2 = 0;
7821- int have_tdb = 0;
7822- int have_vx = 0;
7823- int have_gs = 0;
78247843 int first_pseudo_reg, last_pseudo_reg;
78257844 static const char *const stap_register_prefixes[] = { "%", NULL };
78267845 static const char *const stap_register_indirection_prefixes[] = { "(",
@@ -7828,25 +7847,30 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
78287847 static const char *const stap_register_indirection_suffixes[] = { ")",
78297848 NULL };
78307849
7850+ struct gdbarch_tdep *tdep = s390_gdbarch_tdep_alloc ();
7851+ struct gdbarch *gdbarch = gdbarch_alloc (&info, tdep);
7852+
78317853 /* Default ABI and register size. */
78327854 switch (info.bfd_arch_info->mach)
78337855 {
78347856 case bfd_mach_s390_31:
7835- tdep_abi = ABI_LINUX_S390;
7857+ tdep->abi = ABI_LINUX_S390;
78367858 break;
78377859
78387860 case bfd_mach_s390_64:
7839- tdep_abi = ABI_LINUX_ZSERIES;
7861+ tdep->abi = ABI_LINUX_ZSERIES;
78407862 break;
78417863
78427864 default:
7865+ xfree (tdep);
7866+ gdbarch_free (gdbarch);
78437867 return NULL;
78447868 }
78457869
78467870 /* Use default target description if none provided by the target. */
78477871 if (!tdesc_has_registers (tdesc))
78487872 {
7849- if (tdep_abi == ABI_LINUX_S390)
7873+ if (tdep->abi == ABI_LINUX_S390)
78507874 tdesc = tdesc_s390_linux32;
78517875 else
78527876 tdesc = tdesc_s390x_linux64;
@@ -7899,7 +7923,11 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
78997923
79007924 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.core");
79017925 if (feature == NULL)
7902- return NULL;
7926+ {
7927+ xfree (tdep);
7928+ gdbarch_free (gdbarch);
7929+ return NULL;
7930+ }
79037931
79047932 tdesc_data = tdesc_data_alloc ();
79057933
@@ -7916,7 +7944,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
79167944 }
79177945 else
79187946 {
7919- have_upper = 1;
7947+ tdep->have_upper = true;
79207948
79217949 for (i = 0; i < 16; i++)
79227950 valid_p &= tdesc_numbered_register (feature, tdesc_data,
@@ -7932,6 +7960,8 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
79327960 if (feature == NULL)
79337961 {
79347962 tdesc_data_cleanup (tdesc_data);
7963+ xfree (tdep);
7964+ gdbarch_free (gdbarch);
79357965 return NULL;
79367966 }
79377967
@@ -7945,6 +7975,8 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
79457975 if (feature == NULL)
79467976 {
79477977 tdesc_data_cleanup (tdesc_data);
7978+ xfree (tdep);
7979+ gdbarch_free (gdbarch);
79487980 return NULL;
79497981 }
79507982
@@ -7961,13 +7993,13 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
79617993
79627994 if (tdesc_numbered_register (feature, tdesc_data,
79637995 S390_LAST_BREAK_REGNUM, "last_break"))
7964- have_linux_v1 = 1;
7996+ tdep->have_linux_v1 = 1;
79657997
79667998 if (tdesc_numbered_register (feature, tdesc_data,
79677999 S390_SYSTEM_CALL_REGNUM, "system_call"))
7968- have_linux_v2 = 1;
8000+ tdep->have_linux_v2 = 1;
79698001
7970- if (have_linux_v2 > have_linux_v1)
8002+ if (tdep->have_linux_v2 > tdep->have_linux_v1)
79718003 valid_p = 0;
79728004 }
79738005
@@ -7979,7 +8011,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
79798011 valid_p &= tdesc_numbered_register (feature, tdesc_data,
79808012 S390_TDB_DWORD0_REGNUM + i,
79818013 tdb_regs[i]);
7982- have_tdb = 1;
8014+ tdep->have_tdb = 1;
79838015 }
79848016
79858017 /* Vector registers. */
@@ -7994,7 +8026,7 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
79948026 valid_p &= tdesc_numbered_register (feature, tdesc_data,
79958027 S390_V16_REGNUM + i,
79968028 vxrs_high[i]);
7997- have_vx = 1;
8029+ tdep->have_vx = true;
79988030 }
79998031
80008032 /* Guarded-storage registers. */
@@ -8005,14 +8037,14 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
80058037 valid_p &= tdesc_numbered_register (feature, tdesc_data,
80068038 S390_GSD_REGNUM + i,
80078039 gs_cb[i]);
8008- have_gs = 1;
8040+ tdep->have_gs = true;
80098041 }
80108042
80118043 /* Guarded-storage broadcast control. */
80128044 feature = tdesc_find_feature (tdesc, "org.gnu.gdb.s390.gsbc");
80138045 if (feature)
80148046 {
8015- valid_p &= have_gs;
8047+ valid_p &= tdep->have_gs;
80168048
80178049 for (i = 0; i < 3; i++)
80188050 valid_p &= tdesc_numbered_register (feature, tdesc_data,
@@ -8023,20 +8055,21 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
80238055 if (!valid_p)
80248056 {
80258057 tdesc_data_cleanup (tdesc_data);
8058+ xfree (tdep);
8059+ gdbarch_free (gdbarch);
80268060 return NULL;
80278061 }
80288062 }
80298063
80308064 /* Determine vector ABI. */
8031- vector_abi = S390_VECTOR_ABI_NONE;
80328065 #ifdef HAVE_ELF
8033- if (have_vx
8066+ if (tdep->have_vx
80348067 && info.abfd != NULL
80358068 && info.abfd->format == bfd_object
80368069 && bfd_get_flavour (info.abfd) == bfd_target_elf_flavour
80378070 && bfd_elf_get_obj_attr_int (info.abfd, OBJ_ATTR_GNU,
80388071 Tag_GNU_S390_ABI_Vector) == 2)
8039- vector_abi = S390_VECTOR_ABI_128;
8072+ tdep->vector_abi = S390_VECTOR_ABI_128;
80408073 #endif
80418074
80428075 /* Find a candidate among extant architectures. */
@@ -8044,29 +8077,21 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
80448077 arches != NULL;
80458078 arches = gdbarch_list_lookup_by_info (arches->next, &info))
80468079 {
8047- tdep = gdbarch_tdep (arches->gdbarch);
8048- if (!tdep)
8080+ struct gdbarch_tdep *tmp = gdbarch_tdep (arches->gdbarch);
8081+ if (!tmp)
80498082 continue;
80508083 /* A program can 'choose' not to use the vector registers when they
80518084 are present. Leading to the same tdesc but different tdep and
80528085 thereby a different gdbarch. */
8053- if (tdep->vector_abi != vector_abi)
8086+ if (tmp->vector_abi != tdep->vector_abi)
80548087 continue;
80558088 if (tdesc_data != NULL)
80568089 tdesc_data_cleanup (tdesc_data);
8090+ xfree (tdep);
8091+ gdbarch_free (gdbarch);
80578092 return arches->gdbarch;
80588093 }
80598094
8060- /* Otherwise create a new gdbarch for the specified machine type. */
8061- tdep = XCNEW (struct gdbarch_tdep);
8062- tdep->abi = tdep_abi;
8063- tdep->vector_abi = vector_abi;
8064- tdep->have_linux_v1 = have_linux_v1;
8065- tdep->have_linux_v2 = have_linux_v2;
8066- tdep->have_tdb = have_tdb;
8067- tdep->have_gs = have_gs;
8068- gdbarch = gdbarch_alloc (&info, tdep);
8069-
80708095 set_gdbarch_believe_pcc_promotion (gdbarch, 0);
80718096 set_gdbarch_char_signed (gdbarch, 0);
80728097
@@ -8118,14 +8143,12 @@ s390_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
81188143 /* Assign pseudo register numbers. */
81198144 first_pseudo_reg = gdbarch_num_regs (gdbarch);
81208145 last_pseudo_reg = first_pseudo_reg;
8121- tdep->gpr_full_regnum = -1;
8122- if (have_upper)
8146+ if (tdep->have_upper)
81238147 {
81248148 tdep->gpr_full_regnum = last_pseudo_reg;
81258149 last_pseudo_reg += 16;
81268150 }
8127- tdep->v0_full_regnum = -1;
8128- if (have_vx)
8151+ if (tdep->have_vx)
81298152 {
81308153 tdep->v0_full_regnum = last_pseudo_reg;
81318154 last_pseudo_reg += 16;