From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12284 invoked by alias); 31 Jul 2014 20:22:36 -0000 Mailing-List: contact systemtap-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: systemtap-owner@sourceware.org Received: (qmail 12231 invoked by uid 89); 31 Jul 2014 20:22:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f42.google.com Received: from mail-wg0-f42.google.com (HELO mail-wg0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 31 Jul 2014 20:22:32 +0000 Received: by mail-wg0-f42.google.com with SMTP id l18so3227669wgh.13 for ; Thu, 31 Jul 2014 13:22:29 -0700 (PDT) X-Received: by 10.180.93.8 with SMTP id cq8mr55724wib.17.1406838149154; Thu, 31 Jul 2014 13:22:29 -0700 (PDT) Received: from ixro-lcrestez-lin.ixiacom.com ([109.100.41.154]) by mx.google.com with ESMTPSA id lk7sm15678895wjb.24.2014.07.31.13.22.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Jul 2014 13:22:27 -0700 (PDT) From: Crestez Dan Leonard To: systemtap@sourceware.org Subject: [RFC 07/13] loc2c: Add Dwarf pointer to location_context Date: Thu, 31 Jul 2014 20:22:00 -0000 Message-Id: In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------true" X-IsSubscribed: yes X-SW-Source: 2014-q3/txt/msg00105.txt.bz2 From: Crestez Dan Leonard This is a multi-part message in MIME format. --------------true Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit Content-length: 260 Signed-off-by: Crestez Dan Leonard --- dwflpp.cxx | 10 +++++----- loc2c-test.c | 27 +++++++++++++++++---------- loc2c.c | 20 +++++++++++++------- loc2c.h | 9 ++++++--- 4 files changed, 41 insertions(+), 25 deletions(-) --------------true Content-Type: text/x-patch; name="0007-loc2c-Add-Dwarf-pointer-to-location_context.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0007-loc2c-Add-Dwarf-pointer-to-location_context.patch" Content-length: 9498 diff --git a/dwflpp.cxx b/dwflpp.cxx index dea81b9..10f4abb 100644 --- a/dwflpp.cxx +++ b/dwflpp.cxx @@ -3095,7 +3095,7 @@ dwflpp::translate_location(struct obstack *pool, if (dwarf_whatattr (attr) == DW_AT_const_value) { *tail = c_translate_constant (pool, &loc2c_error, this, - &loc2c_emit_address, 0, pc, attr); + &loc2c_emit_address, 0, pc, attr, module_dwarf); return *tail; } @@ -3173,7 +3173,7 @@ dwflpp::translate_location(struct obstack *pool, return c_translate_location (pool, &loc2c_error, this, &loc2c_emit_address, 1, 0 /* PR9768 */, - pc, attr, expr, len, tail, fb_attr, cfa_ops); + pc, attr, expr, len, tail, fb_attr, cfa_ops, module_dwarf); } @@ -3767,7 +3767,7 @@ dwflpp::literal_stmt_for_local (vector& scopes, head = c_translate_location (&pool, &loc2c_error, this, &loc2c_emit_address, 1, 0, pc, - NULL, &addr_loc, 1, &tail, NULL, NULL); + NULL, &addr_loc, 1, &tail, NULL, NULL, module_dwarf); } else { @@ -3869,7 +3869,7 @@ dwflpp::literal_stmt_for_return (Dwarf_Die *scope_die, &loc2c_emit_address, 1, 0 /* PR9768 */, pc, NULL, locops, nlocops, - &tail, NULL, NULL); + &tail, NULL, NULL, module_dwarf); /* Translate the ->bar->baz[NN] parts. */ @@ -3929,7 +3929,7 @@ dwflpp::literal_stmt_for_pointer (Dwarf_Die *start_typedie, obstack_init (&pool); struct location *head = c_translate_argument (&pool, &loc2c_error, this, &loc2c_emit_address, - 1, "STAP_ARG_pointer"); + 1, "STAP_ARG_pointer", module_dwarf); struct location *tail = head; /* Translate the ->bar->baz[NN] parts. */ diff --git a/loc2c-test.c b/loc2c-test.c index 282047e..370a40f 100644 --- a/loc2c-test.c +++ b/loc2c-test.c @@ -89,7 +89,8 @@ static void handle_fields (struct obstack *pool, struct location *head, struct location *tail, Dwarf_Addr cubias, Dwarf_Die *vardie, Dwarf_Addr pc, - char **fields) + char **fields, + Dwarf *dwarf) { Dwarf_Attribute attr_mem; @@ -192,7 +193,7 @@ handle_fields (struct obstack *pool, c_translate_location (pool, NULL, NULL, NULL, 1, cubias, pc, &attr_mem, locexpr, locexpr_len, - &tail, NULL, NULL); + &tail, NULL, NULL, dwarf); } ++fields; break; @@ -294,7 +295,8 @@ handle_fields (struct obstack *pool, static void handle_variable (Dwarf_Die *lscopes, int lnscopes, int out, Dwarf_Addr cubias, Dwarf_Die *vardie, Dwarf_Addr pc, - Dwarf_Op *cfa_ops, char **fields) + Dwarf_Op *cfa_ops, char **fields, + Dwarf *dwarf) { struct obstack pool; obstack_init (&pool); @@ -345,7 +347,7 @@ handle_variable (Dwarf_Die *lscopes, int lnscopes, int out, if (dwarf_attr_integrate (vardie, DW_AT_const_value, &attr_mem) != NULL) /* There is no location expression, but a constant value instead. */ head = tail = c_translate_constant (&pool, &fail, NULL, NULL, - 1, cubias, &attr_mem); + 1, cubias, &attr_mem, dwarf); else { if (dwarf_attr_integrate (vardie, DW_AT_location, &attr_mem) == NULL) @@ -359,10 +361,10 @@ handle_variable (Dwarf_Die *lscopes, int lnscopes, int out, head = c_translate_location (&pool, &fail, NULL, NULL, 1, cubias, pc, &attr_mem, locexpr, locexpr_len, - &tail, fb_attr, cfa_ops); + &tail, fb_attr, cfa_ops, dwarf); } - handle_fields (&pool, head, tail, cubias, vardie, pc, fields); + handle_fields (&pool, head, tail, cubias, vardie, pc, fields, dwarf); } static void @@ -656,8 +658,11 @@ In the fifth form, the access is a store rather than a fetch." if (dwarf_tag (&scopes[i]) == DW_TAG_subprogram) { const Dwarf_Op *locexpr; + Dwfl_Module *mod = dwfl_addrmodule (dwfl, pc); + Dwarf_Addr bias; + Dwarf *dwarf = dwfl_module_getdwarf (mod, &bias); int locexpr_len = dwfl_module_return_value_location - (dwfl_addrmodule (dwfl, pc), &scopes[i], &locexpr); + (mod, &scopes[i], &locexpr); if (locexpr_len < 0) error (EXIT_FAILURE, 0, "dwfl_module_return_value_location: %s", @@ -668,9 +673,9 @@ In the fifth form, the access is a store rather than a fetch." head = c_translate_location (&pool, &fail, NULL, NULL, 1, cubias, pc, NULL, locexpr, locexpr_len, - &tail, NULL, NULL); + &tail, NULL, NULL, dwarf); handle_fields (&pool, head, tail, cubias, &scopes[i], pc, - &argv[argi]); + &argv[argi], dwarf); free (scopes); dwfl_end (dwfl); return 0; @@ -709,6 +714,7 @@ In the fifth form, the access is a store rather than a fetch." size_t cfa_nops; Dwarf_Addr bias; Dwfl_Module *module = dwfl_addrmodule (dwfl, pc); + Dwarf *dwarf = NULL; if (module != NULL) { // Try debug_frame first, then fall back on eh_frame. @@ -729,10 +735,11 @@ In the fifth form, the access is a store rather than a fetch." dwarf_frame_cfa (frame, &cfa_ops, &cfa_nops); } } + dwarf = dwfl_module_getdwarf (module, &bias); } handle_variable (scopes, n, out, cubias, &vardie, pc, cfa_ops, - &argv[argi]); + &argv[argi], dwarf); } } diff --git a/loc2c.c b/loc2c.c index aef999c..64f34e6 100644 --- a/loc2c.c +++ b/loc2c.c @@ -56,6 +56,7 @@ struct location_context Dwarf_Addr pc; Dwarf_Attribute *fb_attr; const Dwarf_Op *cfa_ops; + Dwarf *dwarf; }; struct location @@ -140,7 +141,8 @@ new_context (struct obstack *pool, struct obstack *, Dwarf_Addr), Dwarf_Addr dwbias, Dwarf_Addr pc_address, Dwarf_Attribute *attr, Dwarf_Attribute *fb_attr, - const Dwarf_Op *cfa_ops) + const Dwarf_Op *cfa_ops, + Dwarf *dwarf) { struct location_context *ctx = obstack_alloc (pool, sizeof *ctx); ctx->pool = pool; @@ -152,6 +154,7 @@ new_context (struct obstack *pool, ctx->pc = pc_address; ctx->fb_attr = fb_attr; ctx->cfa_ops = cfa_ops; + ctx->dwarf = dwarf; return ctx; } @@ -257,10 +260,11 @@ c_translate_constant (struct obstack *pool, void (*emit_address) (void *fail_arg, struct obstack *, Dwarf_Addr), - int indent, Dwarf_Addr dwbias, Dwarf_Attribute *attr) + int indent, Dwarf_Addr dwbias, Dwarf_Attribute *attr, + Dwarf *dwarf) { return translate_constant (new_context (pool, fail, fail_arg, emit_address, - dwbias, 0, attr, NULL, NULL), + dwbias, 0, attr, NULL, NULL, dwarf), indent, attr); } @@ -1428,14 +1432,15 @@ c_translate_location (struct obstack *pool, Dwarf_Attribute *attr, const Dwarf_Op *expr, size_t len, struct location **input, Dwarf_Attribute *fb_attr, - const Dwarf_Op *cfa_ops) + const Dwarf_Op *cfa_ops, + Dwarf *dwarf) { indent += 2; struct location_context *ctx; if (*input == NULL) ctx = new_context (pool, fail, fail_arg, emit_address, dwbias, pc_address, - attr, fb_attr, cfa_ops); + attr, fb_attr, cfa_ops, dwarf); else { ctx = (*input)->context; @@ -1486,7 +1491,8 @@ c_translate_argument (struct obstack *pool, void *fail_arg, void (*emit_address) (void *fail_arg, struct obstack *, Dwarf_Addr), - int indent, const char *value) + int indent, const char *value, + Dwarf *dwarf) { indent += 2; @@ -1496,7 +1502,7 @@ c_translate_argument (struct obstack *pool, struct location *loc = obstack_alloc (pool, sizeof *loc); loc->context = new_context (pool, fail, fail_arg, emit_address, 0, - 0, NULL, NULL, NULL); + 0, NULL, NULL, NULL, dwarf); loc->next = NULL; loc->ops = NULL; loc->nops = 0; diff --git a/loc2c.h b/loc2c.h index 25d2839..92121ae 100644 --- a/loc2c.h +++ b/loc2c.h @@ -39,7 +39,8 @@ struct location *c_translate_location (struct obstack *, size_t locexprlen, struct location **input, Dwarf_Attribute *fb_attr, - const Dwarf_Op *cfa_ops); + const Dwarf_Op *cfa_ops, + Dwarf *dwarf); /* Translate a fragment for a compile-time constant from DW_AT_const_value. */ @@ -53,7 +54,8 @@ struct location *c_translate_constant (struct obstack *, struct obstack *, Dwarf_Addr), int indent, Dwarf_Addr dwbias, - Dwarf_Attribute *attr); + Dwarf_Attribute *attr, + Dwarf *dwarf); /* Translate a fragment to dereference the given DW_TAG_pointer_type DIE, where *INPUT is the location of the pointer with that type. */ @@ -122,7 +124,8 @@ struct location *c_translate_argument (struct obstack *, void (*emit_address) (void *fail_arg, struct obstack *, Dwarf_Addr), - int indent, const char *value); + int indent, const char *value, + Dwarf *dwarf); --------------true--