From: Luis Machado Date: Fri, 27 Mar 2020 14:33:55 +0000 (-0300) Subject: [General] gdbarch update to include code_capability_bit, data_capability_bit etc X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3d6b2a0ec3032f35df0026039df0629da5fe3e6;p=thirdparty%2Fbinutils-gdb.git [General] gdbarch update to include code_capability_bit, data_capability_bit etc gdb/ChangeLog: 2020-10-20 Luis Machado * gdb/gdbarch.c: Regenerate. * gdb/gdbarch.h: Regenerate. * gdb/gdbarch.sh (code_capability_bit) (data_capability_bit, capability_bit, dwarf2_capability_size): New methods. * gdb/gdbtypes.c (gdbtypes_post_init): Initialize data address capability to a pointer to intcap_t. --- diff --git a/gdb/gdbarch-components.py b/gdb/gdbarch-components.py index 5feb04d0c09..51670712904 100644 --- a/gdb/gdbarch-components.py +++ b/gdb/gdbarch-components.py @@ -338,6 +338,55 @@ and if Dwarf versions < 4 need to be supported. invalid=True, ) +Value( + comment=""" +For capability-based targets, the capability representation will likely +differ from regular pointers. We can have a code capability and a data +capability. + +code_capability is the size of a capability on the target +""", + type="int", + name="code_capability_bit", + predefault="gdbarch->int_bit", + invalid=False, +) + +Value( + comment=""" +data_capability is the size of a target capability as represented in gdb +""", + type="int", + name="data_capability_bit", + predefault="0", + postdefault="gdbarch_ptr_bit (gdbarch)", + invalid=True +) + +Value( + comment=""" +capability_bit is the size of a target capability as represented in gdb +""", + type="int", + name="capability_bit", + predefault="0", + postdefault="gdbarch_ptr_bit (gdbarch)", + invalid=True +) + +Value( + comment=""" +Note that dwarf2_capability_size only needs to be redefined by a target if the +GCC back-end defines a DWARF2_CAPABILITY_SIZE other than the target pointer +size, and if Dwarf versions < 4 need to be supported. +""", + type="int", + name="dwarf2_capability_size", + predefault="0", + postdefault="gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT", + invalid=True, +) + Value( comment=""" One if `char' acts like `signed char', zero if `unsigned char'. diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h index 1282746d88b..4dd66f58631 100644 --- a/gdb/gdbarch-gen.h +++ b/gdb/gdbarch-gen.h @@ -158,6 +158,32 @@ extern void set_gdbarch_addr_bit (struct gdbarch *gdbarch, int addr_bit); extern int gdbarch_dwarf2_addr_size (struct gdbarch *gdbarch); extern void set_gdbarch_dwarf2_addr_size (struct gdbarch *gdbarch, int dwarf2_addr_size); +/* For capability-based targets, the capability representation will likely + differ from regular pointers. We can have a code capability and a data + capability. + + code_capability is the size of a capability on the target */ + +extern int gdbarch_code_capability_bit (struct gdbarch *gdbarch); +extern void set_gdbarch_code_capability_bit (struct gdbarch *gdbarch, int code_capability_bit); + +/* data_capability is the size of a target capability as represented in gdb */ + +extern int gdbarch_data_capability_bit (struct gdbarch *gdbarch); +extern void set_gdbarch_data_capability_bit (struct gdbarch *gdbarch, int data_capability_bit); + +/* capability_bit is the size of a target capability as represented in gdb */ + +extern int gdbarch_capability_bit (struct gdbarch *gdbarch); +extern void set_gdbarch_capability_bit (struct gdbarch *gdbarch, int capability_bit); + +/* Note that dwarf2_capability_size only needs to be redefined by a target if the + GCC back-end defines a DWARF2_CAPABILITY_SIZE other than the target pointer + size, and if Dwarf versions < 4 need to be supported. */ + +extern int gdbarch_dwarf2_capability_size (struct gdbarch *gdbarch); +extern void set_gdbarch_dwarf2_capability_size (struct gdbarch *gdbarch, int dwarf2_capability_size); + /* One if `char' acts like `signed char', zero if `unsigned char'. */ extern int gdbarch_char_signed (struct gdbarch *gdbarch); diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 732b4314d32..7e44134b461 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -70,6 +70,10 @@ struct gdbarch int ptr_bit; int addr_bit; int dwarf2_addr_size; + int code_capability_bit; + int data_capability_bit; + int capability_bit; + int dwarf2_capability_size; int char_signed; gdbarch_read_pc_ftype *read_pc; gdbarch_write_pc_ftype *write_pc; @@ -294,6 +298,7 @@ gdbarch_alloc (const struct gdbarch_info *info, gdbarch->wchar_signed = -1; gdbarch->floatformat_for_type = default_floatformat_for_type; gdbarch->ptr_bit = gdbarch->int_bit; + gdbarch->code_capability_bit = gdbarch->int_bit; gdbarch->char_signed = -1; gdbarch->virtual_frame_pointer = legacy_virtual_frame_pointer; gdbarch->num_regs = -1; @@ -422,6 +427,13 @@ verify_gdbarch (struct gdbarch *gdbarch) gdbarch->addr_bit = gdbarch_ptr_bit (gdbarch); if (gdbarch->dwarf2_addr_size == 0) gdbarch->dwarf2_addr_size = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT; + /* Skip verify of code_capability_bit, invalid_p == 0 */ + if (gdbarch->data_capability_bit == 0) + gdbarch->data_capability_bit = gdbarch_ptr_bit (gdbarch); + if (gdbarch->capability_bit == 0) + gdbarch->capability_bit = gdbarch_ptr_bit (gdbarch); + if (gdbarch->dwarf2_capability_size == 0) + gdbarch->dwarf2_capability_size = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT; if (gdbarch->char_signed == -1) gdbarch->char_signed = 1; /* Skip verify of read_pc, has predicate. */ @@ -706,6 +718,18 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_filtered (file, "gdbarch_dump: dwarf2_addr_size = %s\n", plongest (gdbarch->dwarf2_addr_size)); + fprintf_filtered (file, + "gdbarch_dump: code_capability_bit = %s\n", + plongest (gdbarch->code_capability_bit)); + fprintf_filtered (file, + "gdbarch_dump: data_capability_bit = %s\n", + plongest (gdbarch->data_capability_bit)); + fprintf_filtered (file, + "gdbarch_dump: capability_bit = %s\n", + plongest (gdbarch->capability_bit)); + fprintf_filtered (file, + "gdbarch_dump: dwarf2_capability_size = %s\n", + plongest (gdbarch->dwarf2_capability_size)); fprintf_filtered (file, "gdbarch_dump: char_signed = %s\n", plongest (gdbarch->char_signed)); @@ -1832,6 +1856,77 @@ set_gdbarch_dwarf2_addr_size (struct gdbarch *gdbarch, gdbarch->dwarf2_addr_size = dwarf2_addr_size; } +int +gdbarch_code_capability_bit (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + /* Skip verify of code_capability_bit, invalid_p == 0 */ + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_code_capability_bit called\n"); + return gdbarch->code_capability_bit; +} + +void +set_gdbarch_code_capability_bit (struct gdbarch *gdbarch, + int code_capability_bit) +{ + gdbarch->code_capability_bit = code_capability_bit; +} + +int +gdbarch_data_capability_bit (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + /* Check variable changed from pre-default. */ + gdb_assert (gdbarch->data_capability_bit != 0); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_data_capability_bit called\n"); + return gdbarch->data_capability_bit; +} + +void +set_gdbarch_data_capability_bit (struct gdbarch *gdbarch, + int data_capability_bit) +{ + gdbarch->data_capability_bit = data_capability_bit; +} + +int +gdbarch_capability_bit (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + /* Check variable changed from pre-default. */ + gdb_assert (gdbarch->capability_bit != 0); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_capability_bit called\n"); + return gdbarch->capability_bit; +} + +void +set_gdbarch_capability_bit (struct gdbarch *gdbarch, + int capability_bit) +{ + gdbarch->capability_bit = capability_bit; +} + +int +gdbarch_dwarf2_capability_size (struct gdbarch *gdbarch) +{ + gdb_assert (gdbarch != NULL); + /* Check variable changed from pre-default. */ + gdb_assert (gdbarch->dwarf2_capability_size != 0); + if (gdbarch_debug >= 2) + fprintf_unfiltered (gdb_stdlog, "gdbarch_dwarf2_capability_size called\n"); + return gdbarch->dwarf2_capability_size; +} + +void +set_gdbarch_dwarf2_capability_size (struct gdbarch *gdbarch, + int dwarf2_capability_size) +{ + gdbarch->dwarf2_capability_size = dwarf2_capability_size; +} + int gdbarch_char_signed (struct gdbarch *gdbarch) { diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 18b449960ea..83b1c28af46 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -6210,7 +6210,7 @@ gdbtypes_post_init (struct gdbarch *gdbarch) /* Capability pointer types. */ builtin_type->builtin_data_addr_capability - = lookup_pointer_type (builtin_type->builtin_intcap_t); + = lookup_pointer_type (builtin_type->builtin_void); builtin_type->builtin_code_addr_capability = lookup_pointer_type (lookup_function_type (builtin_type->builtin_void));