diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2017-04-28 17:16:17 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2017-04-28 17:16:17 -0400 |
commit | 76e75227c37bc058449a09fe5017eeb40cda0781 (patch) | |
tree | c560183af00d3490f64620cc0c902566544e649e /gdb | |
parent | 51046d9e60727cd6a4cfeae29a05ce2e1e394dc9 (diff) | |
download | gdb-76e75227c37bc058449a09fe5017eeb40cda0781.zip gdb-76e75227c37bc058449a09fe5017eeb40cda0781.tar.gz gdb-76e75227c37bc058449a09fe5017eeb40cda0781.tar.bz2 |
Class-ify lm_info_svr4
This patch makes lm_info_svr4 a "real" class. It initializes fields,
uses bool and replaces XCNEW/xfree with new/delete.
The memcpy in svr4_copy_library_list is replaced by a usage of the
default copy constructor.
gdb/ChangeLog:
* solib-svr4.h (struct lm_info_svr4): Initialize fields.
<l_addr_p>: Change type to bool.
* solib-svr4.c (lm_info_read): Allocate lm_info_svr4 with new.
(svr4_free_so): Free lm_info_svr4 with delete.
(svr4_copy_library_list): Replace memcpy with call to copy
constructor.
(library_list_start_library, svr4_default_sos): Allocate
lm_info_svr4 with new.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 11 | ||||
-rw-r--r-- | gdb/solib-svr4.c | 14 | ||||
-rw-r--r-- | gdb/solib-svr4.h | 8 |
3 files changed, 23 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7ec97d0..eb0571b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,16 @@ 2017-04-28 Simon Marchi <simon.marchi@ericsson.com> + * solib-svr4.h (struct lm_info_svr4): Initialize fields. + <l_addr_p>: Change type to bool. + * solib-svr4.c (lm_info_read): Allocate lm_info_svr4 with new. + (svr4_free_so): Free lm_info_svr4 with delete. + (svr4_copy_library_list): Replace memcpy with call to copy + constructor. + (library_list_start_library, svr4_default_sos): Allocate + lm_info_svr4 with new. + +2017-04-28 Simon Marchi <simon.marchi@ericsson.com> + * solib-target.c (struct lm_info_target): Add destructor, initialize fields. <name>: Change type to std::string. diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 6098d50..080fd79 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -189,7 +189,7 @@ lm_info_read (CORE_ADDR lm_addr) { struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr; - lm_info = XCNEW (lm_info_svr4); + lm_info = new lm_info_svr4; lm_info->lm_addr = lm_addr; lm_info->l_addr_inferior = extract_typed_address (&lm[lmo->l_addr_offset], @@ -1080,7 +1080,9 @@ struct svr4_library_list static void svr4_free_so (struct so_list *so) { - xfree (so->lm_info); + lm_info_svr4 *li = (lm_info_svr4 *) so->lm_info; + + delete li; } /* Implement target_so_ops.clear_so. */ @@ -1125,8 +1127,8 @@ svr4_copy_library_list (struct so_list *src) newobj = XNEW (struct so_list); memcpy (newobj, src, sizeof (struct so_list)); - newobj->lm_info = XNEW (lm_info_svr4); - memcpy (newobj->lm_info, src->lm_info, sizeof (lm_info_svr4)); + lm_info_svr4 *src_li = (lm_info_svr4 *) src->lm_info; + newobj->lm_info = new lm_info_svr4 (*src_li); newobj->next = NULL; *link = newobj; @@ -1162,7 +1164,7 @@ library_list_start_library (struct gdb_xml_parser *parser, struct so_list *new_elem; new_elem = XCNEW (struct so_list); - lm_info_svr4 *li = XCNEW (lm_info_svr4); + lm_info_svr4 *li = new lm_info_svr4; new_elem->lm_info = li; li->lm_addr = *lmp; li->l_addr_inferior = *l_addrp; @@ -1317,7 +1319,7 @@ svr4_default_sos (void) return NULL; newobj = XCNEW (struct so_list); - lm_info_svr4 *li = XCNEW (lm_info_svr4); + lm_info_svr4 *li = new lm_info_svr4; newobj->lm_info = li; /* Nothing will ever check the other fields if we set l_addr_p. */ diff --git a/gdb/solib-svr4.h b/gdb/solib-svr4.h index a9b09aa..705c587 100644 --- a/gdb/solib-svr4.h +++ b/gdb/solib-svr4.h @@ -38,14 +38,14 @@ struct lm_info_svr4 : public lm_info_base It is commonly the same value. It is cached as we want to warn about the difference and compute it only once. L_ADDR is valid iff L_ADDR_P. */ - CORE_ADDR l_addr, l_addr_inferior; - unsigned int l_addr_p : 1; + CORE_ADDR l_addr = 0, l_addr_inferior = 0; + bool l_addr_p = false; /* The target location of lm. */ - CORE_ADDR lm_addr; + CORE_ADDR lm_addr = 0; /* Values read in from inferior's fields of the same name. */ - CORE_ADDR l_ld, l_next, l_prev, l_name; + CORE_ADDR l_ld = 0, l_next = 0, l_prev = 0, l_name = 0; }; /* Critical offsets and sizes which describe struct r_debug and |