* [FYI 2/2] Do not make "prop" field of struct dynamic_prop_list a pointer.
2015-03-24 18:28 [FYI 1/2] GDB: rename DYN_ATTR_DATA_LOCATION into DYN_PROP_DATA_LOCATION Joel Brobecker
@ 2015-03-24 18:28 ` Joel Brobecker
0 siblings, 0 replies; 2+ messages in thread
From: Joel Brobecker @ 2015-03-24 18:28 UTC (permalink / raw)
To: gdb-patches
This is something that was discussed during the review of the patch
adding the struct dynamic_prop_list, and eventually postponed for
later...
struct dynamic_prop_list is declared as follow:
struct dynamic_prop_list
{
[...]
/* The dynamic property itself. */
struct dynamic_prop *prop;
[...]
};
In this case, the pointer indirection is unnecessary and costing us,
for each dynamic property, the memory needed to store one pointer.
This patch removes this pointer indirection, savin us a tiny bit of
memory, as well as reduces a bit the complexity by removing the need
to allocate memory for the property, as the allocation is now part
of the struct itself.
gdb/ChangeLog:
* gdbtypes.h (struct dynamic_prop_list) <prop>: Remove
pointer indirection.
* gdbtypes.c (get_dyn_prop): Adjust, following change above.
(add_dyn_prop, copy_dynamic_prop_list): Likewise.
Tested on x86_64-linux and pushed.
Thanks,
--
Joel
---
gdb/ChangeLog | 7 +++++++
gdb/gdbtypes.c | 7 +++----
gdb/gdbtypes.h | 2 +-
3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 78ccc8a..43dda55 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2015-03-24 Joel Brobecker <brobecker@adacore.com>
+ * gdbtypes.h (struct dynamic_prop_list) <prop>: Remove
+ pointer indirection.
+ * gdbtypes.c (get_dyn_prop): Adjust, following change above.
+ (add_dyn_prop, copy_dynamic_prop_list): Likewise.
+
+2015-03-24 Joel Brobecker <brobecker@adacore.com>
+
* gdbtypes.h (enum dynamic_prop_node_kind) <DYN_PROP_DATA_LOCATION>:
Renames DYN_ATTR_DATA_LOCATION.
(TYPE_DATA_LOCATION): Use DYN_PROP_DATA_LOCATION instead of
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 19579af..217ec70 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2109,7 +2109,7 @@ get_dyn_prop (enum dynamic_prop_node_kind prop_kind, const struct type *type)
while (node != NULL)
{
if (node->prop_kind == prop_kind)
- return node->prop;
+ return &node->prop;
node = node->next;
}
return NULL;
@@ -2128,7 +2128,7 @@ add_dyn_prop (enum dynamic_prop_node_kind prop_kind, struct dynamic_prop prop,
temp = obstack_alloc (&objfile->objfile_obstack,
sizeof (struct dynamic_prop_list));
temp->prop_kind = prop_kind;
- temp->prop = obstack_copy (&objfile->objfile_obstack, &prop, sizeof (prop));
+ temp->prop = prop;
temp->next = TYPE_DYN_PROP_LIST (type);
TYPE_DYN_PROP_LIST (type) = temp;
@@ -4279,8 +4279,7 @@ copy_dynamic_prop_list (struct obstack *objfile_obstack,
node_copy = obstack_copy (objfile_obstack, *node_ptr,
sizeof (struct dynamic_prop_list));
- node_copy->prop = obstack_copy (objfile_obstack, (*node_ptr)->prop,
- sizeof (struct dynamic_prop));
+ node_copy->prop = (*node_ptr)->prop;
*node_ptr = node_copy;
node_ptr = &node_copy->next;
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 15d6cd5..883418f 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -449,7 +449,7 @@ struct dynamic_prop_list
enum dynamic_prop_node_kind prop_kind;
/* The dynamic property itself. */
- struct dynamic_prop *prop;
+ struct dynamic_prop prop;
/* A pointer to the next dynamic property. */
struct dynamic_prop_list *next;
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [FYI 1/2] GDB: rename DYN_ATTR_DATA_LOCATION into DYN_PROP_DATA_LOCATION.
@ 2015-03-24 18:28 Joel Brobecker
2015-03-24 18:28 ` [FYI 2/2] Do not make "prop" field of struct dynamic_prop_list a pointer Joel Brobecker
0 siblings, 1 reply; 2+ messages in thread
From: Joel Brobecker @ 2015-03-24 18:28 UTC (permalink / raw)
To: gdb-patches
The terminology we've been using is (dynamic) "property" rather than
"attribute", so this patch renames an enum to use the same terminology.
No behavior change.
gdb/ChangeLog:
* gdbtypes.h (enum dynamic_prop_node_kind) <DYN_PROP_DATA_LOCATION>:
Renames DYN_ATTR_DATA_LOCATION.
(TYPE_DATA_LOCATION): Use DYN_PROP_DATA_LOCATION instead of
DYN_ATTR_DATA_LOCATION.
* dwarf2read.c (set_die_type): Use DYN_PROP_DATA_LOCATION
instead of DYN_ATTR_DATA_LOCATION.
Tested on x86_64-linux and pushed.
Thanks,
--
Joel
---
gdb/ChangeLog | 9 +++++++++
gdb/dwarf2read.c | 2 +-
gdb/gdbtypes.h | 4 ++--
3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index c2a5520..78ccc8a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2015-03-24 Joel Brobecker <brobecker@adacore.com>
+
+ * gdbtypes.h (enum dynamic_prop_node_kind) <DYN_PROP_DATA_LOCATION>:
+ Renames DYN_ATTR_DATA_LOCATION.
+ (TYPE_DATA_LOCATION): Use DYN_PROP_DATA_LOCATION instead of
+ DYN_ATTR_DATA_LOCATION.
+ * dwarf2read.c (set_die_type): Use DYN_PROP_DATA_LOCATION
+ instead of DYN_ATTR_DATA_LOCATION.
+
2015-03-24 Pedro Alves <palves@redhat.com>
* breakpoint.c (until_break_command): Adjust call to proceed.
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 4946b48..96c5a33 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -22102,7 +22102,7 @@ set_die_type (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
/* Read DW_AT_data_location and set in type. */
attr = dwarf2_attr (die, DW_AT_data_location, cu);
if (attr_to_dynamic_prop (attr, die, cu, &prop))
- add_dyn_prop (DYN_ATTR_DATA_LOCATION, prop, type, objfile);
+ add_dyn_prop (DYN_PROP_DATA_LOCATION, prop, type, objfile);
if (dwarf2_per_objfile->die_type_hash == NULL)
{
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 79d72df..15d6cd5 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -439,7 +439,7 @@ enum dynamic_prop_node_kind
{
/* A property providing a type's data location.
Evaluating this field yields to the location of an object's data. */
- DYN_ATTR_DATA_LOCATION,
+ DYN_PROP_DATA_LOCATION,
};
/* * List for dynamic type attributes. */
@@ -1258,7 +1258,7 @@ extern void allocate_gnat_aux_type (struct type *);
/* Property accessors for the type data location. */
#define TYPE_DATA_LOCATION(thistype) \
- get_dyn_prop (DYN_ATTR_DATA_LOCATION, thistype)
+ get_dyn_prop (DYN_PROP_DATA_LOCATION, thistype)
#define TYPE_DATA_LOCATION_BATON(thistype) \
TYPE_DATA_LOCATION (thistype)->data.baton
#define TYPE_DATA_LOCATION_ADDR(thistype) \
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-24 18:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-24 18:28 [FYI 1/2] GDB: rename DYN_ATTR_DATA_LOCATION into DYN_PROP_DATA_LOCATION Joel Brobecker
2015-03-24 18:28 ` [FYI 2/2] Do not make "prop" field of struct dynamic_prop_list a pointer Joel Brobecker
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).