From 5f27603700c0d89023f00b6521b36cc911c23f85 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 1 Mar 2023 08:03:49 -0700 Subject: [PATCH] Use const for dwarf2_property_baton Once a baton is stored in a struct type, it doesn't make sense to modify it. This patch constifies the API. Approved-By: Simon Marchi --- gdb/dwarf2/loc.c | 8 ++++---- gdb/dwarf2/loc.h | 2 +- gdb/gdbtypes.h | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index bf582bcfeff..914e016f085 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -347,7 +347,7 @@ decode_debug_loc_dwo_addresses (dwarf2_per_cu_data *per_cu, can be more than one in the list. */ const gdb_byte * -dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton, +dwarf2_find_location_expression (const dwarf2_loclist_baton *baton, size_t *locexpr_length, CORE_ADDR pc) { dwarf2_per_objfile *per_objfile = baton->per_objfile; @@ -1691,7 +1691,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, case PROP_LOCLIST: { - struct dwarf2_property_baton *baton = prop->baton (); + const dwarf2_property_baton *baton = prop->baton (); CORE_ADDR pc; const gdb_byte *data; struct value *val; @@ -1722,7 +1722,7 @@ dwarf2_evaluate_property (const struct dynamic_prop *prop, case PROP_ADDR_OFFSET: { - struct dwarf2_property_baton *baton = prop->baton (); + const dwarf2_property_baton *baton = prop->baton (); const struct property_addr_info *pinfo; struct value *val; @@ -1772,7 +1772,7 @@ dwarf2_compile_property_to_c (string_file *stream, CORE_ADDR pc, struct symbol *sym) { - struct dwarf2_property_baton *baton = prop->baton (); + const dwarf2_property_baton *baton = prop->baton (); const gdb_byte *data; size_t size; dwarf2_per_cu_data *per_cu; diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h index 37925f48497..ad60177e93c 100644 --- a/gdb/dwarf2/loc.h +++ b/gdb/dwarf2/loc.h @@ -37,7 +37,7 @@ extern unsigned int entry_values_debug; /* Find a particular location expression from a location list. */ const gdb_byte *dwarf2_find_location_expression - (struct dwarf2_loclist_baton *baton, + (const dwarf2_loclist_baton *baton, size_t *locexpr_length, CORE_ADDR pc); diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 701a64d457a..c4889a4a05b 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -290,7 +290,7 @@ union dynamic_prop_data /* Storage for dynamic property. */ - dwarf2_property_baton *baton; + const dwarf2_property_baton *baton; /* Storage of variant parts for a type. A type with variant parts has all its fields "linearized" -- stored in a single field @@ -340,7 +340,7 @@ struct dynamic_prop m_data.const_val = const_val; } - dwarf2_property_baton *baton () const + const dwarf2_property_baton *baton () const { gdb_assert (m_kind == PROP_LOCEXPR || m_kind == PROP_LOCLIST @@ -349,19 +349,19 @@ struct dynamic_prop return m_data.baton; } - void set_locexpr (dwarf2_property_baton *baton) + void set_locexpr (const dwarf2_property_baton *baton) { m_kind = PROP_LOCEXPR; m_data.baton = baton; } - void set_loclist (dwarf2_property_baton *baton) + void set_loclist (const dwarf2_property_baton *baton) { m_kind = PROP_LOCLIST; m_data.baton = baton; } - void set_addr_offset (dwarf2_property_baton *baton) + void set_addr_offset (const dwarf2_property_baton *baton) { m_kind = PROP_ADDR_OFFSET; m_data.baton = baton; -- 2.30.2