From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17759 invoked by alias); 16 Jan 2013 16:09:09 -0000 Received: (qmail 17745 invoked by uid 22791); 16 Jan 2013 16:09:08 -0000 X-SWARE-Spam-Status: No, hits=-5.6 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS,TW_BJ X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 16 Jan 2013 16:08:59 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0GG8xbW010852 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Jan 2013 11:08:59 -0500 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r0GG8usv014670 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 16 Jan 2013 11:08:57 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [3/3] unconditionally call via SYMBOL_COMPUTED_OPS Date: Wed, 16 Jan 2013 16:09:00 -0000 Message-ID: <871udlhzzb.fsf@fleche.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2013-01/txt/msg00340.txt.bz2 There are some FIXME comments scattered about the code concerning the unconditional use of SYMBOL_COMPUTED_OPS. I think the idea here was that we could remove LOC_COMPUTED entirely, and just have a computed ops vector alongside some other LOC_* constant. I didn't go quite that far, but I made it so that if the symbol has computed ops, they are called unconditionally. Then I removed the FIXMEs. Patch #2 fixed the DWARF frame base issue mentioned in these comments by adding the "reader datum" form of synthetic address classes. I did this in patch #2, and not here, because splitting this differently made the patches uglier -- introducing new code only to delete it again. Built and regtested on x86-64 Fedora 16. Tom * ax-gdb.c (gen_var_ref): Unconditionally call via computed ops, if possible. * dwarf2read.c (read_func_scope): Remove old FIXME. * eval.c (evaluate_subexp_standard): Check SYMBOL_COMPUTED_OPS, not LOC_COMPUTED. * findvar.c (symbol_read_needs_frame, default_read_var_value): Unconditionally call via computed ops, if possible. * printcmd.c (address_info): Unconditionally call via computed ops, if possible. * stack.c (read_frame_arg): Unconditionally call via computed ops, if possible. * symtab.c (register_symbol_computed_impl): Sanity check 'ops'. * tracepoint.c (scope_info): Unconditionally call via computed ops, if possible. --- gdb/ax-gdb.c | 14 ++-- gdb/dwarf2read.c | 9 --- gdb/eval.c | 2 +- gdb/findvar.c | 20 ++---- gdb/printcmd.c | 17 +++-- gdb/stack.c | 3 +- gdb/symtab.c | 7 ++ gdb/tracepoint.c | 188 ++++++++++++++++++++++++++++-------------------------- 8 files changed, 131 insertions(+), 129 deletions(-) diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index f0e33cb..a83fb00 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -662,6 +662,12 @@ gen_var_ref (struct gdbarch *gdbarch, struct agent_expr *ax, value->type = check_typedef (SYMBOL_TYPE (var)); value->optimized_out = 0; + if (SYMBOL_COMPUTED_OPS (var) != NULL) + { + SYMBOL_COMPUTED_OPS (var)->tracepoint_var_ref (var, gdbarch, ax, value); + return; + } + /* I'm imitating the code in read_var_value. */ switch (SYMBOL_CLASS (var)) { @@ -750,13 +756,7 @@ gen_var_ref (struct gdbarch *gdbarch, struct agent_expr *ax, break; case LOC_COMPUTED: - /* FIXME: cagney/2004-01-26: It should be possible to - unconditionally call the SYMBOL_COMPUTED_OPS method when available. - Unfortunately DWARF 2 stores the frame-base (instead of the - function) location in a function's symbol. Oops! For the - moment enable this when/where applicable. */ - SYMBOL_COMPUTED_OPS (var)->tracepoint_var_ref (var, gdbarch, ax, value); - break; + gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method")); case LOC_OPTIMIZED_OUT: /* Flag this, but don't say anything; leave it up to callers to diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index a2819ca..e1a20ef 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -9528,15 +9528,6 @@ read_func_scope (struct die_info *die, struct dwarf2_cu *cu) it. */ attr = dwarf2_attr (die, DW_AT_frame_base, cu); if (attr) - /* FIXME: cagney/2004-01-26: The DW_AT_frame_base's location - expression is being recorded directly in the function's symbol - and not in a separate frame-base object. I guess this hack is - to avoid adding some sort of frame-base adjunct/annex to the - function's symbol :-(. The problem with doing this is that it - results in a function symbol with a location expression that - has nothing to do with the location of the function, ouch! The - relationship should be: a function's symbol has-a frame base; a - frame-base has-a location expression. */ dwarf2_symbol_mark_computed (attr, new->name, cu, 1); cu->list_in_scope = &local_symbols; diff --git a/gdb/eval.c b/gdb/eval.c index c9630df..74e33a0 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -792,7 +792,7 @@ evaluate_subexp_standard (struct type *expect_type, if (noside == EVAL_AVOID_SIDE_EFFECTS) return value_zero (SYMBOL_TYPE (sym), not_lval); - if (SYMBOL_CLASS (sym) != LOC_COMPUTED + if (SYMBOL_COMPUTED_OPS (sym) == NULL || SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry == NULL) error (_("Symbol \"%s\" does not have any specific entry value"), SYMBOL_PRINT_NAME (sym)); diff --git a/gdb/findvar.c b/gdb/findvar.c index fb66e0f..22be47a 100644 --- a/gdb/findvar.c +++ b/gdb/findvar.c @@ -367,17 +367,15 @@ address_to_signed_pointer (struct gdbarch *gdbarch, struct type *type, int symbol_read_needs_frame (struct symbol *sym) { + if (SYMBOL_COMPUTED_OPS (sym) != NULL) + return SYMBOL_COMPUTED_OPS (sym)->read_needs_frame (sym); + switch (SYMBOL_CLASS (sym)) { /* All cases listed explicitly so that gcc -Wall will detect it if we failed to consider one. */ case LOC_COMPUTED: - /* FIXME: cagney/2004-01-26: It should be possible to - unconditionally call the SYMBOL_COMPUTED_OPS method when available. - Unfortunately DWARF 2 stores the frame-base (instead of the - function) location in a function's symbol. Oops! For the - moment enable this when/where applicable. */ - return SYMBOL_COMPUTED_OPS (sym)->read_needs_frame (sym); + gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method")); case LOC_REGISTER: case LOC_ARG: @@ -456,6 +454,9 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) if (symbol_read_needs_frame (var)) gdb_assert (frame); + if (SYMBOL_COMPUTED_OPS (var) != NULL) + return SYMBOL_COMPUTED_OPS (var)->read_variable (var, frame); + switch (SYMBOL_CLASS (var)) { case LOC_CONST: @@ -578,12 +579,7 @@ default_read_var_value (struct symbol *var, struct frame_info *frame) break; case LOC_COMPUTED: - /* FIXME: cagney/2004-01-26: It should be possible to - unconditionally call the SYMBOL_COMPUTED_OPS method when available. - Unfortunately DWARF 2 stores the frame-base (instead of the - function) location in a function's symbol. Oops! For the - moment enable this when/where applicable. */ - return SYMBOL_COMPUTED_OPS (var)->read_variable (var, frame); + gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method")); case LOC_UNRESOLVED: { diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 0c7eb1e..82d1c00 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1240,6 +1240,14 @@ address_info (char *exp, int from_tty) section = SYMBOL_OBJ_SECTION (sym); gdbarch = get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile); + if (SYMBOL_COMPUTED_OPS (sym) != NULL) + { + SYMBOL_COMPUTED_OPS (sym)->describe_location (sym, context_pc, + gdb_stdout); + printf_filtered (".\n"); + return; + } + switch (SYMBOL_CLASS (sym)) { case LOC_CONST: @@ -1262,14 +1270,7 @@ address_info (char *exp, int from_tty) break; case LOC_COMPUTED: - /* FIXME: cagney/2004-01-26: It should be possible to - unconditionally call the SYMBOL_COMPUTED_OPS method when available. - Unfortunately DWARF 2 stores the frame-base (instead of the - function) location in a function's symbol. Oops! For the - moment enable this when/where applicable. */ - SYMBOL_COMPUTED_OPS (sym)->describe_location (sym, context_pc, - gdb_stdout); - break; + gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method")); case LOC_REGISTER: /* GDBARCH is the architecture associated with the objfile the symbol diff --git a/gdb/stack.c b/gdb/stack.c index a9dabb5..5f1d4af 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -322,7 +322,8 @@ read_frame_arg (struct symbol *sym, struct frame_info *frame, } } - if (SYMBOL_CLASS (sym) == LOC_COMPUTED + if (SYMBOL_COMPUTED_OPS (sym) != NULL + && SYMBOL_COMPUTED_OPS (sym)->read_variable_at_entry != NULL && print_entry_values != print_entry_values_no && (print_entry_values != print_entry_values_if_needed || !val || value_optimized_out (val))) diff --git a/gdb/symtab.c b/gdb/symtab.c index 6256d9d..e22b342 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -5084,6 +5084,13 @@ register_symbol_computed_impl (enum address_class aclass, symbol_impl[result].aclass = aclass; symbol_impl[result].ops_computed = ops; + /* Sanity check OPS. */ + gdb_assert (ops != NULL); + gdb_assert (ops->tracepoint_var_ref != NULL); + gdb_assert (ops->describe_location != NULL); + gdb_assert (ops->read_needs_frame != NULL); + gdb_assert (ops->read_variable != NULL); + return result; } diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index be45cb4..5b67be2 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2653,101 +2653,107 @@ scope_info (char *args, int from_tty) gdbarch = get_objfile_arch (SYMBOL_SYMTAB (sym)->objfile); printf_filtered ("Symbol %s is ", symname); - switch (SYMBOL_CLASS (sym)) + + if (SYMBOL_COMPUTED_OPS (sym) != NULL) + SYMBOL_COMPUTED_OPS (sym)->describe_location (sym, + BLOCK_START (block), + gdb_stdout); + else { - default: - case LOC_UNDEF: /* Messed up symbol? */ - printf_filtered ("a bogus symbol, class %d.\n", - SYMBOL_CLASS (sym)); - count--; /* Don't count this one. */ - continue; - case LOC_CONST: - printf_filtered ("a constant with value %s (%s)", - plongest (SYMBOL_VALUE (sym)), - hex_string (SYMBOL_VALUE (sym))); - break; - case LOC_CONST_BYTES: - printf_filtered ("constant bytes: "); - if (SYMBOL_TYPE (sym)) - for (j = 0; j < TYPE_LENGTH (SYMBOL_TYPE (sym)); j++) - fprintf_filtered (gdb_stdout, " %02x", - (unsigned) SYMBOL_VALUE_BYTES (sym)[j]); - break; - case LOC_STATIC: - printf_filtered ("in static storage at address "); - printf_filtered ("%s", paddress (gdbarch, - SYMBOL_VALUE_ADDRESS (sym))); - break; - case LOC_REGISTER: - /* GDBARCH is the architecture associated with the objfile - the symbol is defined in; the target architecture may be - different, and may provide additional registers. However, - we do not know the target architecture at this point. - We assume the objfile architecture will contain all the - standard registers that occur in debug info in that - objfile. */ - regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym, - gdbarch); - - if (SYMBOL_IS_ARGUMENT (sym)) - printf_filtered ("an argument in register $%s", - gdbarch_register_name (gdbarch, regno)); - else - printf_filtered ("a local variable in register $%s", - gdbarch_register_name (gdbarch, regno)); - break; - case LOC_ARG: - printf_filtered ("an argument at stack/frame offset %s", - plongest (SYMBOL_VALUE (sym))); - break; - case LOC_LOCAL: - printf_filtered ("a local variable at frame offset %s", - plongest (SYMBOL_VALUE (sym))); - break; - case LOC_REF_ARG: - printf_filtered ("a reference argument at offset %s", - plongest (SYMBOL_VALUE (sym))); - break; - case LOC_REGPARM_ADDR: - /* Note comment at LOC_REGISTER. */ - regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym, - gdbarch); - printf_filtered ("the address of an argument, in register $%s", - gdbarch_register_name (gdbarch, regno)); - break; - case LOC_TYPEDEF: - printf_filtered ("a typedef.\n"); - continue; - case LOC_LABEL: - printf_filtered ("a label at address "); - printf_filtered ("%s", paddress (gdbarch, - SYMBOL_VALUE_ADDRESS (sym))); - break; - case LOC_BLOCK: - printf_filtered ("a function at address "); - printf_filtered ("%s", - paddress (gdbarch, BLOCK_START (SYMBOL_BLOCK_VALUE (sym)))); - break; - case LOC_UNRESOLVED: - msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym), - NULL, NULL); - if (msym == NULL) - printf_filtered ("Unresolved Static"); - else + switch (SYMBOL_CLASS (sym)) { - printf_filtered ("static storage at address "); + default: + case LOC_UNDEF: /* Messed up symbol? */ + printf_filtered ("a bogus symbol, class %d.\n", + SYMBOL_CLASS (sym)); + count--; /* Don't count this one. */ + continue; + case LOC_CONST: + printf_filtered ("a constant with value %s (%s)", + plongest (SYMBOL_VALUE (sym)), + hex_string (SYMBOL_VALUE (sym))); + break; + case LOC_CONST_BYTES: + printf_filtered ("constant bytes: "); + if (SYMBOL_TYPE (sym)) + for (j = 0; j < TYPE_LENGTH (SYMBOL_TYPE (sym)); j++) + fprintf_filtered (gdb_stdout, " %02x", + (unsigned) SYMBOL_VALUE_BYTES (sym)[j]); + break; + case LOC_STATIC: + printf_filtered ("in static storage at address "); + printf_filtered ("%s", paddress (gdbarch, + SYMBOL_VALUE_ADDRESS (sym))); + break; + case LOC_REGISTER: + /* GDBARCH is the architecture associated with the objfile + the symbol is defined in; the target architecture may be + different, and may provide additional registers. However, + we do not know the target architecture at this point. + We assume the objfile architecture will contain all the + standard registers that occur in debug info in that + objfile. */ + regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym, + gdbarch); + + if (SYMBOL_IS_ARGUMENT (sym)) + printf_filtered ("an argument in register $%s", + gdbarch_register_name (gdbarch, regno)); + else + printf_filtered ("a local variable in register $%s", + gdbarch_register_name (gdbarch, regno)); + break; + case LOC_ARG: + printf_filtered ("an argument at stack/frame offset %s", + plongest (SYMBOL_VALUE (sym))); + break; + case LOC_LOCAL: + printf_filtered ("a local variable at frame offset %s", + plongest (SYMBOL_VALUE (sym))); + break; + case LOC_REF_ARG: + printf_filtered ("a reference argument at offset %s", + plongest (SYMBOL_VALUE (sym))); + break; + case LOC_REGPARM_ADDR: + /* Note comment at LOC_REGISTER. */ + regno = SYMBOL_REGISTER_OPS (sym)->register_number (sym, + gdbarch); + printf_filtered ("the address of an argument, in register $%s", + gdbarch_register_name (gdbarch, regno)); + break; + case LOC_TYPEDEF: + printf_filtered ("a typedef.\n"); + continue; + case LOC_LABEL: + printf_filtered ("a label at address "); + printf_filtered ("%s", paddress (gdbarch, + SYMBOL_VALUE_ADDRESS (sym))); + break; + case LOC_BLOCK: + printf_filtered ("a function at address "); printf_filtered ("%s", - paddress (gdbarch, SYMBOL_VALUE_ADDRESS (msym))); + paddress (gdbarch, BLOCK_START (SYMBOL_BLOCK_VALUE (sym)))); + break; + case LOC_UNRESOLVED: + msym = lookup_minimal_symbol (SYMBOL_LINKAGE_NAME (sym), + NULL, NULL); + if (msym == NULL) + printf_filtered ("Unresolved Static"); + else + { + printf_filtered ("static storage at address "); + printf_filtered ("%s", + paddress (gdbarch, + SYMBOL_VALUE_ADDRESS (msym))); + } + break; + case LOC_OPTIMIZED_OUT: + printf_filtered ("optimized out.\n"); + continue; + case LOC_COMPUTED: + gdb_assert_not_reached (_("LOC_COMPUTED variable missing a method")); } - break; - case LOC_OPTIMIZED_OUT: - printf_filtered ("optimized out.\n"); - continue; - case LOC_COMPUTED: - SYMBOL_COMPUTED_OPS (sym)->describe_location (sym, - BLOCK_START (block), - gdb_stdout); - break; } if (SYMBOL_TYPE (sym)) printf_filtered (", length %d.\n", -- 1.7.7.6