diff options
author | Tom Tromey <tromey@redhat.com> | 2010-05-27 19:14:35 +0000 |
---|---|---|
committer | Tom Tromey <tromey@redhat.com> | 2010-05-27 19:14:35 +0000 |
commit | 88bfdde411c988853b8ec9f8699dcb614f7b079a (patch) | |
tree | 66b8853650141c3b5742417884125159dcc48f49 | |
parent | 8c6363cf5c34e8728b3ad010a1611de234d6ed9d (diff) | |
download | gdb-88bfdde411c988853b8ec9f8699dcb614f7b079a.zip gdb-88bfdde411c988853b8ec9f8699dcb614f7b079a.tar.gz gdb-88bfdde411c988853b8ec9f8699dcb614f7b079a.tar.bz2 |
* dwarf2loc.c (struct piece_closure) <refc>: New field.
(allocate_piece_closure): Initialize refc.
(copy_pieced_value_closure): Use refc.
(free_pieced_value_closure): Likewise.
-rw-r--r-- | gdb/ChangeLog | 7 | ||||
-rw-r--r-- | gdb/dwarf2loc.c | 15 |
2 files changed, 19 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6ce98ba..fd2c936 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,12 @@ 2010-05-27 Tom Tromey <tromey@redhat.com> + * dwarf2loc.c (struct piece_closure) <refc>: New field. + (allocate_piece_closure): Initialize refc. + (copy_pieced_value_closure): Use refc. + (free_pieced_value_closure): Likewise. + +2010-05-27 Tom Tromey <tromey@redhat.com> + * arm-tdep.c (push_stack_item): 'contents' now const. (arm_push_dummy_call): Make 'val' const. Use value_contents, not value_contents_writeable. Introduce new temporary. diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c index a5d10f5..79d2277 100644 --- a/gdb/dwarf2loc.c +++ b/gdb/dwarf2loc.c @@ -231,6 +231,9 @@ dwarf_expr_tls_address (void *baton, CORE_ADDR offset) struct piece_closure { + /* Reference count. */ + int refc; + /* The number of pieces used to describe this variable. */ int n_pieces; @@ -250,6 +253,7 @@ allocate_piece_closure (int n_pieces, struct dwarf_expr_piece *pieces, { struct piece_closure *c = XZALLOC (struct piece_closure); + c->refc = 1; c->n_pieces = n_pieces; c->addr_size = addr_size; c->pieces = XCALLOC (n_pieces, struct dwarf_expr_piece); @@ -747,7 +751,8 @@ copy_pieced_value_closure (struct value *v) { struct piece_closure *c = (struct piece_closure *) value_computed_closure (v); - return allocate_piece_closure (c->n_pieces, c->pieces, c->addr_size); + ++c->refc; + return c; } static void @@ -755,8 +760,12 @@ free_pieced_value_closure (struct value *v) { struct piece_closure *c = (struct piece_closure *) value_computed_closure (v); - xfree (c->pieces); - xfree (c); + --c->refc; + if (c->refc == 0) + { + xfree (c->pieces); + xfree (c); + } } /* Functions for accessing a variable described by DW_OP_piece. */ |