From c65dd777559f5e16d3806dcc889b245cbb16ab55 Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Fri, 27 Mar 2020 11:33:55 -0300 Subject: [PATCH] [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. --- gdb/ChangeLog | 10 ++++++ gdb/gdbarch.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++ gdb/gdbarch.h | 25 +++++++++++++ gdb/gdbarch.sh | 17 ++++++++- gdb/gdbtypes.c | 2 +- 5 files changed, 147 insertions(+), 2 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index aa200a33613..613d925e88f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +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. + 2020-10-20 Luis Machado * gdb/c-exp.y (CAPABILITY, INTCAP_KEYWORD, UINTCAP_KEYWORD): New diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index 5e44047c2a9..8bab2d9de9e 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -182,6 +182,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; @@ -394,6 +398,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; @@ -550,6 +555,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. */ @@ -846,9 +858,15 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: cannot_store_register = <%s>\n", host_address_to_string (gdbarch->cannot_store_register)); + fprintf_unfiltered (file, + "gdbarch_dump: capability_bit = %s\n", + plongest (gdbarch->capability_bit)); fprintf_unfiltered (file, "gdbarch_dump: char_signed = %s\n", plongest (gdbarch->char_signed)); + fprintf_unfiltered (file, + "gdbarch_dump: code_capability_bit = %s\n", + plongest (gdbarch->code_capability_bit)); fprintf_unfiltered (file, "gdbarch_dump: code_of_frame_writable = <%s>\n", host_address_to_string (gdbarch->code_of_frame_writable)); @@ -903,6 +921,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: core_xfer_siginfo = <%s>\n", host_address_to_string (gdbarch->core_xfer_siginfo)); + fprintf_unfiltered (file, + "gdbarch_dump: data_capability_bit = %s\n", + plongest (gdbarch->data_capability_bit)); fprintf_unfiltered (file, "gdbarch_dump: decr_pc_after_break = %s\n", core_addr_to_string_nz (gdbarch->decr_pc_after_break)); @@ -972,6 +993,9 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) fprintf_unfiltered (file, "gdbarch_dump: dwarf2_addr_size = %s\n", plongest (gdbarch->dwarf2_addr_size)); + fprintf_unfiltered (file, + "gdbarch_dump: dwarf2_capability_size = %s\n", + plongest (gdbarch->dwarf2_capability_size)); fprintf_unfiltered (file, "gdbarch_dump: dwarf2_reg_to_regnum = <%s>\n", host_address_to_string (gdbarch->dwarf2_reg_to_regnum)); @@ -1902,6 +1926,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/gdbarch.h b/gdb/gdbarch.h index 9f98ae83566..fd9692d1684 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -249,6 +249,31 @@ 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.sh b/gdb/gdbarch.sh index f9aed71fa7c..08ad20f2649 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -381,7 +381,22 @@ v;int;addr_bit;;;8 * sizeof (void*);0;gdbarch_ptr_bit (gdbarch); # GCC back-end defines a DWARF2_ADDR_SIZE other than the target pointer size, # and if Dwarf versions < 4 need to be supported. v;int;dwarf2_addr_size;;;sizeof (void*);0;gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT; -# + +# 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 +v;int;code_capability_bit;;;8 * sizeof (void*);gdbarch->int_bit;;0 +# data_capability is the size of a target capability as represented in gdb +v;int;data_capability_bit;;;8 * sizeof (void*);0;gdbarch_ptr_bit (gdbarch); +# capability_bit is the size of a target capability as represented in gdb +v;int;capability_bit;;;8 * sizeof (void*);0;gdbarch_ptr_bit (gdbarch); + +# 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. +v;int;dwarf2_capability_size;;;sizeof (void*);0;gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT; + # One if \`char' acts like \`signed char', zero if \`unsigned char'. v;int;char_signed;;;1;-1;1 # diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index aabfac65eaa..a52a57c8394 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -5896,7 +5896,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)); -- 2.47.3