From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18245 invoked by alias); 24 Dec 2009 01:33:47 -0000 Received: (qmail 18232 invoked by uid 22791); 24 Dec 2009 01:33:46 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 24 Dec 2009 01:33:40 +0000 Received: (qmail 21344 invoked from network); 24 Dec 2009 01:33:39 -0000 Received: from unknown (HELO macbook-2.local) (stan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 24 Dec 2009 01:33:39 -0000 Message-ID: <4B32C4ED.6050904@codesourcery.com> Date: Thu, 24 Dec 2009 01:33:00 -0000 From: Stan Shebs User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812) MIME-Version: 1.0 To: gdb-patches Subject: [PATCH] Handle OP_THIS in tracepoints Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 2009-12/txt/msg00375.txt.bz2 This one comes up pretty quickly when doing tracepoints in C++; members in expressions use OP_THIS, which amounts to shorthand for a reference to the implicit argument "this". Handling is uncomplicated, mimics expression evaluation. Stan 2009-12-23 Stan Shebs * ax-gdb.c (gen_expr): Handle OP_THIS. Index: ax-gdb.c =================================================================== RCS file: /cvs/src/src/gdb/ax-gdb.c,v retrieving revision 1.54 diff -p -r1.54 ax-gdb.c *** ax-gdb.c 24 Dec 2009 00:40:49 -0000 1.54 --- ax-gdb.c 24 Dec 2009 01:21:21 -0000 *************** *** 35,40 **** --- 35,41 ---- #include "regcache.h" #include "user-regs.h" #include "language.h" + #include "dictionary.h" /* To make sense of this file, you should read doc/agentexpr.texi. Then look at the types and enums in ax-gdb.h. For the code itself, *************** gen_expr (struct expression *exp, union *** 1759,1764 **** --- 1760,1797 ---- } break; + case OP_THIS: + { + char *name; + struct frame_info *frame; + struct symbol *func, *sym; + struct block *b; + + name = current_language->la_name_of_this; + if (!name) + error (_("no `this' in current language")); + + frame = get_selected_frame (_("no frame selected")); + + func = get_frame_function (frame); + if (!func) + error (_("no `%s' in nameless context"), name); + + b = SYMBOL_BLOCK_VALUE (func); + if (dict_empty (BLOCK_DICT (b))) + error (_("no args, no `%s' in block"), name); + + /* Calling lookup_block_symbol is necessary to get the LOC_REGISTER + symbol instead of the LOC_ARG one (if both exist). */ + sym = lookup_block_symbol (b, name, NULL, VAR_DOMAIN); + if (!sym) + error (_("no `%s' found"), name); + + gen_var_ref (exp->gdbarch, ax, value, sym); + (*pc) += 2; + } + break; + case OP_TYPE: error (_("Attempt to use a type name as an expression."));