From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32238 invoked by alias); 3 Apr 2008 12:12:22 -0000 Received: (qmail 32221 invoked by uid 22791); 3 Apr 2008 12:12:19 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 03 Apr 2008 12:11:48 +0000 Received: (qmail 9329 invoked from network); 3 Apr 2008 12:11:29 -0000 Received: from unknown (HELO localhost) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 3 Apr 2008 12:11:29 -0000 From: Vladimir Prus To: Daniel Jacobowitz Subject: Re: [RFA] Fix breakpoint condition that use member variables. Date: Thu, 03 Apr 2008 12:51:00 -0000 User-Agent: KMail/1.9.6 (enterprise 0.20070907.709405) Cc: gdb-patches@sources.redhat.com References: <200803221240.16230.vladimir@codesourcery.com> <20080401135952.GB12753@caradoc.them.org> In-Reply-To: <20080401135952.GB12753@caradoc.them.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200804031611.22052.vladimir@codesourcery.com> 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: 2008-04/txt/msg00067.txt.bz2 On Tuesday 01 April 2008 17:59:52 Daniel Jacobowitz wrote: > > diff --git a/gdb/symtab.c b/gdb/symtab.c > > index ddd2310..7d9b4ea 100644 > > --- a/gdb/symtab.c > > +++ b/gdb/symtab.c > > @@ -1198,17 +1198,34 @@ lookup_symbol_aux (const char *name, const char= =20 > > *linkage_name, > >=20=20 > > langdef =3D language_def (language); > >=20=20 > > - if (langdef->la_value_of_this !=3D NULL > > - && is_a_field_of_this !=3D NULL) > > + if (langdef->la_name_of_this !=3D NULL && is_a_field_of_this !=3D NU= LL > > + && block !=3D NULL && !dict_empty (BLOCK_DICT (block))) > > { > > - struct value *v =3D langdef->la_value_of_this (0); > > - > > - if (v && check_field (v, name)) > > + struct symbol *sym =3D lookup_block_symbol (block,=20 > > langdef->la_name_of_this, > > + NULL, VAR_DOMAIN); >=20 > value_of_local always gets the function block. This might have an > inner block that does not correspond to the function. I think you > need to find the enclosing function before checking dict_empty or > calling lookup_block_symbol. You could use block_function to get > the symbol and then SYMBOL_BLOCK_VALUE to get the containing > block, or just walk up BLOCK_SUPERBLOCK looking for BLOCK_FUNCTION. Done, and added a new test that setting a breakpoint inside an inner block of a function actually finds this's fields. > > @@ -2773,10 +2739,7 @@ value_of_local (const char *name, int complain) > > struct value * > > value_of_this (int complain) > > { > > - if (current_language->la_language =3D=3D language_objc) > > - return value_of_local ("self", complain); > > - else > > - return value_of_local ("this", complain); > > + return value_of_local (current_language->la_name_of_this, complain); > > } > >=20=20 > > /* Create a slice (sub-string, sub-array) of ARRAY, that is LENGTH >=20 > Is this going to crash if we get here for a language where it is NULL? Yes. It's not very good idea to call value_of_this in a language that has no this, but for safety, I've added a check. I attach the revised patch, OK? - Volodya =A0=A0=A0=A0=A0=A0=A0=A0[gdb] =A0=A0=A0=A0=A0=A0=A0=A0* valops.c (check_field): Remove. =A0=A0=A0=A0=A0=A0=A0=A0(check_field_in): Rename to check_field. =A0=A0=A0=A0=A0=A0=A0=A0(value_of_this): Use la_name_of_this. =A0=A0=A0=A0=A0=A0=A0=A0* value.h (check_field): Adjust prototype. =A0=A0=A0=A0=A0=A0=A0=A0* language.h (la_value_of_this): Rename to la_name_= of_this. =A0=A0=A0=A0=A0=A0=A0=A0* language.c (unknown_language_defn): Specify "this= " for =A0=A0=A0=A0=A0=A0=A0=A0name_of_this. =A0=A0=A0=A0=A0=A0=A0=A0(auto_language_defn): Likewise. =A0=A0=A0=A0=A0=A0=A0=A0(local_language_defn): Likewise. =A0=A0=A0=A0=A0=A0=A0=A0* ada-lang.c (ada_language_defn): Adjust comment. =A0=A0=A0=A0=A0=A0=A0=A0* c-lang.c (c_language_defn): Adjust comment. =A0=A0=A0=A0=A0=A0=A0=A0(cplus_language_defn): Specify "this" for name_of_t= his. =A0=A0=A0=A0=A0=A0=A0=A0(asm_language_defn): Adjust comment. =A0=A0=A0=A0=A0=A0=A0=A0(minimal_language_defn): Adjust comment. =A0=A0=A0=A0=A0=A0=A0=A0* f-lang.c (f_language_defn): Specify NULL for name= _of_this. =A0=A0=A0=A0=A0=A0=A0=A0* jv-lang.c (java_language_defn): Specify "this" fo= r name_of_this. =A0=A0=A0=A0=A0=A0=A0=A0* m2-lang.c (m2_language_defn): Specify "this" for = name_of_this. =A0=A0=A0=A0=A0=A0=A0=A0* objc-lang.c (objc_language_defn): Specify "self" = for =A0=A0=A0=A0=A0=A0=A0=A0name_of_this. =A0=A0=A0=A0=A0=A0=A0=A0* p-lang.c (pascal_language_defn): Specify "this" f= or =A0=A0=A0=A0=A0=A0=A0=A0name_of_this. =A0=A0=A0=A0=A0=A0=A0=A0* scm-lang.c (scm_language_defn): Specify NULL for = name_of_this. =A0=A0=A0=A0=A0=A0=A0=A0* symtab.c (lookup_symbol_aux): Lookup "this" in the =A0=A0=A0=A0=A0=A0=A0=A0proper scope, and check for field in type of "this"= , without =A0=A0=A0=A0=A0=A0=A0=A0trying to create a value. =A0=A0=A0=A0=A0=A0=A0=A0[gdb/testsuite] =A0=A0=A0=A0=A0=A0=A0=A0* gdb.cp/breakpoint.cc: New code to test conditions= involving =A0=A0=A0=A0=A0=A0=A0=A0member variables. =A0=A0=A0=A0=A0=A0=A0=A0* gdb.cp/breakpoint.exp: Test condition involving m= ember =A0=A0=A0=A0=A0=A0=A0=A0variables. --- =A0gdb/ada-lang.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A02 +- =A0gdb/c-lang.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A08 += ++--- =A0gdb/f-lang.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A02 +- =A0gdb/jv-lang.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A02 +- =A0gdb/language.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A06 ++-- =A0gdb/language.h =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 10 ++---= -- =A0gdb/m2-lang.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A02 +- =A0gdb/objc-lang.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A02 +- =A0gdb/p-lang.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A02 +- =A0gdb/scm-lang.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 =A02 +- =A0gdb/symtab.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 42 +++= ++++++++++++++++++++------ =A0gdb/testsuite/gdb.cp/breakpoint.cc =A0| =A0 29 ++++++++++++++++++++- =A0gdb/testsuite/gdb.cp/breakpoint.exp | =A0 10 +++++++ =A0gdb/valops.c =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0| =A0 49 +++= ++------------------------------ =A0gdb/value.h =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 | =A0 =A02 +- =A015 files changed, 96 insertions(+), 74 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 2f0f55f..8cfc2c8 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -10999,7 +10999,7 @@ const struct language_defn ada_language_defn =3D { =A0 =A0ada_val_print, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Print a value using= appropriate syntax */ =A0 =A0ada_value_print, =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Print a top-level val= ue */ =A0 =A0NULL, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* Language sp= ecific skip_trampoline */ - =A0NULL, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* value_of_this= */ + =A0NULL, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* name_of_this = */ =A0 =A0ada_lookup_symbol_nonlocal, =A0 /* Looking up non-local symbols. =A0= */ =A0 =A0basic_lookup_transparent_type, =A0 =A0 =A0 =A0/* lookup_transparent_= type */ =A0 =A0ada_la_decode, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* Language specific s= ymbol demangler */ diff --git a/gdb/c-lang.c b/gdb/c-lang.c index c4ef9d6..29aa765 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -414,7 +414,7 @@ const struct language_defn c_language_defn =3D =A0 =A0c_val_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Pr= int a value using appropriate syntax */ =A0 =A0c_value_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print = a top-level value */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific skip_trampoline */ - =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* value_of_this */ + =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* name_of_this */ =A0 =A0basic_lookup_symbol_nonlocal,=A0=A0=A0=A0=A0=A0=A0=A0/* lookup_symbo= l_nonlocal */ =A0 =A0basic_lookup_transparent_type,/* lookup_transparent_type */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific symbol demangler */ @@ -527,7 +527,7 @@ const struct language_defn cplus_language_defn =3D =A0 =A0c_val_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Pr= int a value using appropriate syntax */ =A0 =A0c_value_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print = a top-level value */ =A0 =A0cplus_skip_trampoline,=A0=A0=A0=A0=A0=A0=A0/* Language specific skip= _trampoline */ - =A0value_of_this,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* value_of= _this */ + =A0"this", =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* name_of_this */ =A0 =A0cp_lookup_symbol_nonlocal,=A0=A0=A0/* lookup_symbol_nonlocal */ =A0 =A0cp_lookup_transparent_type, =A0 /* lookup_transparent_type */ =A0 =A0cplus_demangle,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language= specific symbol demangler */ @@ -562,7 +562,7 @@ const struct language_defn asm_language_defn =3D =A0 =A0c_val_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Pr= int a value using appropriate syntax */ =A0 =A0c_value_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print = a top-level value */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific skip_trampoline */ - =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* value_of_this */ + =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* name_of_this */ =A0 =A0basic_lookup_symbol_nonlocal,=A0=A0=A0=A0=A0=A0=A0=A0/* lookup_symbo= l_nonlocal */ =A0 =A0basic_lookup_transparent_type,/* lookup_transparent_type */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific symbol demangler */ @@ -602,7 +602,7 @@ const struct language_defn minimal_language_defn =3D =A0 =A0c_val_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Pr= int a value using appropriate syntax */ =A0 =A0c_value_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print = a top-level value */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific skip_trampoline */ - =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* value_of_this */ + =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* name_of_this */ =A0 =A0basic_lookup_symbol_nonlocal,=A0=A0=A0=A0=A0=A0=A0=A0/* lookup_symbo= l_nonlocal */ =A0 =A0basic_lookup_transparent_type,/* lookup_transparent_type */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific symbol demangler */ diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 038126c..5dcbd33 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -324,7 +324,7 @@ const struct language_defn f_language_defn =3D =A0 =A0f_val_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Pr= int a value using appropriate syntax */ =A0 =A0c_value_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* FIXME = */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific skip_trampoline */ - =A0value_of_this,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* value_of= _this */ + =A0NULL, =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0=A0=A0=A0=A0/* name_of_th= is */ =A0 =A0basic_lookup_symbol_nonlocal,=A0=A0=A0=A0=A0=A0=A0=A0/* lookup_symbo= l_nonlocal */ =A0 =A0basic_lookup_transparent_type,/* lookup_transparent_type */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific symbol demangler */ diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c index e6c6f7d..b72b90c 100644 --- a/gdb/jv-lang.c +++ b/gdb/jv-lang.c @@ -1070,7 +1070,7 @@ const struct language_defn java_language_defn =3D =A0 =A0java_val_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print a = value using appropriate syntax */ =A0 =A0java_value_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print a top-= level value */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific skip_trampoline */ - =A0value_of_this,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* value_of= _this */ + =A0"this",=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0/* name_of_th= is */ =A0 =A0basic_lookup_symbol_nonlocal,=A0=A0=A0=A0=A0=A0=A0=A0/* lookup_symbo= l_nonlocal */ =A0 =A0basic_lookup_transparent_type,/* lookup_transparent_type */ =A0 =A0java_demangle,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Langua= ge specific symbol demangler */ diff --git a/gdb/language.c b/gdb/language.c index a26218d..80f6961 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -1192,7 +1192,7 @@ const struct language_defn unknown_language_defn =3D =A0 =A0unk_lang_val_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print a value us= ing appropriate syntax */ =A0 =A0unk_lang_value_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0/* Print a top-level value */ =A0 =A0unk_lang_trampoline,=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific = skip_trampoline */ - =A0value_of_this,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* value_of= _this */ + =A0"this", =A0 =A0 =A0 =A0=A0=A0=A0=A0=A0=A0 =A0 =A0=A0=A0=A0=A0/* name_o= f_this */ =A0 =A0basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */ =A0 =A0basic_lookup_transparent_type,/* lookup_transparent_type */ =A0 =A0unk_lang_demangle,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language speci= fic symbol demangler */ @@ -1228,7 +1228,7 @@ const struct language_defn auto_language_defn =3D =A0 =A0unk_lang_val_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print a value us= ing appropriate syntax */ =A0 =A0unk_lang_value_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0/* Print a top-level value */ =A0 =A0unk_lang_trampoline,=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific = skip_trampoline */ - =A0value_of_this,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* value_of= _this */ + =A0"this",=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0 =A0/* na= me_of_this */ =A0 =A0basic_lookup_symbol_nonlocal,=A0=A0=A0=A0=A0=A0=A0=A0/* lookup_symbo= l_nonlocal */ =A0 =A0basic_lookup_transparent_type,/* lookup_transparent_type */ =A0 =A0unk_lang_demangle,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language speci= fic symbol demangler */ @@ -1263,7 +1263,7 @@ const struct language_defn local_language_defn =3D =A0 =A0unk_lang_val_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print a value us= ing appropriate syntax */ =A0 =A0unk_lang_value_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0/* Print a top-level value */ =A0 =A0unk_lang_trampoline,=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific = skip_trampoline */ - =A0value_of_this,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* value_of= _this */ + =A0"this", =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0 =A0/* name= _of_this */ =A0 =A0basic_lookup_symbol_nonlocal,=A0=A0=A0=A0=A0=A0=A0=A0/* lookup_symbo= l_nonlocal */ =A0 =A0basic_lookup_transparent_type,/* lookup_transparent_type */ =A0 =A0unk_lang_demangle,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language speci= fic symbol demangler */ diff --git a/gdb/language.h b/gdb/language.h index f7e654d..233a5a3 100644 --- a/gdb/language.h +++ b/gdb/language.h @@ -206,14 +206,10 @@ struct language_defn =A0 =A0 =A0 =A0/* Now come some hooks for lookup_symbol. =A0*/ =A0 - =A0 =A0/* If this is non-NULL, lookup_symbol will do the 'field_of_this' - =A0 =A0 =A0 check, using this function to find the value of this. =A0*/ + =A0 =A0/* If this is non-NULL, specifies the name that of the implicit + =A0 =A0 =A0 local variable that refers to the current object instance. = =A0*/ =A0 - =A0 =A0/* FIXME: carlton/2003-05-19: Audit all the language_defn structs - =A0 =A0 =A0 to make sure we're setting this appropriately: I'm sure it - =A0 =A0 =A0 could be NULL in more languages. =A0*/ - - =A0 =A0struct value *(*la_value_of_this) (int complain); + =A0 =A0char *la_name_of_this; =A0 =A0 =A0 =A0/* This is a function that lookup_symbol will call when it gets = to =A0 =A0 =A0 =A0 the part of symbol lookup where C looks up static and global diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index 6b51fd5..bb205ad 100644 --- a/gdb/m2-lang.c +++ b/gdb/m2-lang.c @@ -375,7 +375,7 @@ const struct language_defn m2_language_defn =3D =A0 =A0m2_val_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0/* Print a value using appropriate syntax */ =A0 =A0c_value_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print = a top-level value */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific skip_trampoline */ - =A0value_of_this,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* value_of= _this */ + =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0/* name_of_this */ =A0 =A0basic_lookup_symbol_nonlocal,=A0=A0=A0=A0=A0=A0=A0=A0/* lookup_symbo= l_nonlocal */ =A0 =A0basic_lookup_transparent_type,/* lookup_transparent_type */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific symbol demangler */ diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index ccf8068..08a6bb8 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -509,7 +509,7 @@ const struct language_defn objc_language_defn =3D { =A0 =A0c_val_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Pr= int a value using appropriate syntax */ =A0 =A0c_value_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print = a top-level value */ =A0 =A0objc_skip_trampoline, =A0=A0=A0=A0=A0=A0=A0/* Language specific skip= _trampoline */ - =A0value_of_this,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* value_of= _this */ + =A0"self",=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0 =A0/* na= me_of_this */ =A0 =A0basic_lookup_symbol_nonlocal,=A0=A0=A0=A0=A0=A0=A0=A0/* lookup_symbo= l_nonlocal */ =A0 =A0basic_lookup_transparent_type,/* lookup_transparent_type */ =A0 =A0objc_demangle,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Langua= ge specific symbol demangler */ diff --git a/gdb/p-lang.c b/gdb/p-lang.c index f7b901f..2accf35 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -414,7 +414,7 @@ const struct language_defn pascal_language_defn =3D =A0 =A0pascal_val_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print a valu= e using appropriate syntax */ =A0 =A0pascal_value_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print a top-leve= l value */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific skip_trampoline */ - =A0value_of_this,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* value_of= _this */ + =A0"this",=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0 =A0/* na= me_of_this */ =A0 =A0basic_lookup_symbol_nonlocal,=A0=A0=A0=A0=A0=A0=A0=A0/* lookup_symbo= l_nonlocal */ =A0 =A0basic_lookup_transparent_type,/* lookup_transparent_type */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific symbol demangler */ diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c index 339c614..0692d43 100644 --- a/gdb/scm-lang.c +++ b/gdb/scm-lang.c @@ -253,7 +253,7 @@ const struct language_defn scm_language_defn =3D =A0 =A0scm_val_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print = a value using appropriate syntax */ =A0 =A0scm_value_print,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Print a to= p-level value */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific skip_trampoline */ - =A0value_of_this,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* value_of= _this */ + =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0/* name_of_this */ =A0 =A0basic_lookup_symbol_nonlocal,=A0=A0=A0=A0=A0=A0=A0=A0/* lookup_symbo= l_nonlocal */ =A0 =A0basic_lookup_transparent_type,/* lookup_transparent_type */ =A0 =A0NULL,=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0/* Language specific symbol demangler */ diff --git a/gdb/symtab.c b/gdb/symtab.c index ddd2310..6a452f7 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1198,17 +1198,41 @@ lookup_symbol_aux (const char *name, const char *li= nkage_name, =A0 =A0 =A0langdef =3D language_def (language); =A0 - =A0if (langdef->la_value_of_this !=3D NULL - =A0 =A0 =A0&& is_a_field_of_this !=3D NULL) + =A0if (langdef->la_name_of_this !=3D NULL && is_a_field_of_this !=3D NULL + =A0 =A0 =A0&& block !=3D NULL) =A0 =A0 =A0{ - =A0 =A0 =A0struct value *v =3D langdef->la_value_of_this (0); - - =A0 =A0 =A0if (v && check_field (v, name)) + =A0 =A0 =A0struct symbol *sym =3D NULL; + =A0 =A0 =A0/* 'this' is only defined in the function's block, so find the +=A0=A0=A0=A0=A0=A0=A0 enclosing function block. =A0*/ + =A0 =A0 =A0for (; block && !BLOCK_FUNCTION (block);=20 +=A0=A0=A0=A0=A0=A0=A0 =A0 block =3D BLOCK_SUPERBLOCK (block)); + + =A0 =A0 =A0if (block && !dict_empty (BLOCK_DICT (block))) +=A0=A0=A0=A0=A0=A0=A0sym =3D lookup_block_symbol (block, langdef->la_name_= of_this, +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 =A0 NULL, VAR_DOMAIN); + =A0 =A0 =A0if (sym) =A0=A0=A0=A0=A0=A0=A0=A0{ -=A0=A0=A0=A0=A0=A0=A0 =A0*is_a_field_of_this =3D 1; -=A0=A0=A0=A0=A0=A0=A0 =A0if (symtab !=3D NULL) -=A0=A0=A0=A0=A0=A0=A0 =A0 =A0*symtab =3D NULL; -=A0=A0=A0=A0=A0=A0=A0 =A0return NULL; +=A0=A0=A0=A0=A0=A0=A0 =A0struct type *t =3D sym->type; +=A0=A0=A0=A0=A0=A0=A0 =A0 +=A0=A0=A0=A0=A0=A0=A0 =A0/* I'm not really sure that type of this can ever +=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 be typedefed; just be safe. =A0*/ +=A0=A0=A0=A0=A0=A0=A0 =A0CHECK_TYPEDEF (t); +=A0=A0=A0=A0=A0=A0=A0 =A0if (TYPE_CODE (t) =3D=3D TYPE_CODE_PTR +=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0|| TYPE_CODE (t) =3D=3D TYPE_CODE_REF) +=A0=A0=A0=A0=A0=A0=A0 =A0 =A0t =3D TYPE_TARGET_TYPE (t); +=A0=A0=A0=A0=A0=A0=A0 =A0 +=A0=A0=A0=A0=A0=A0=A0 =A0if (TYPE_CODE (t) !=3D TYPE_CODE_STRUCT +=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0&& TYPE_CODE (t) !=3D TYPE_CODE_UNION) +=A0=A0=A0=A0=A0=A0=A0 =A0 =A0error (_("Internal error: `%s' is not an aggr= egate"),=20 +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 langdef->la_name_of_this= ); +=A0=A0=A0=A0=A0=A0=A0 =A0 +=A0=A0=A0=A0=A0=A0=A0 =A0if (check_field (t, name)) +=A0=A0=A0=A0=A0=A0=A0 =A0 =A0{ +=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0*is_a_field_of_this =3D 1; +=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0if (symtab !=3D NULL) +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0*symtab =3D NULL; +=A0=A0=A0=A0=A0=A0=A0 =A0 =A0 =A0return NULL; +=A0=A0=A0=A0=A0=A0=A0 =A0 =A0} =A0=A0=A0=A0=A0=A0=A0=A0} =A0 =A0 =A0} =A0 diff --git a/gdb/testsuite/gdb.cp/breakpoint.cc b/gdb/testsuite/gdb.cp/brea= kpoint.cc index c719af2..98b7891 100644 --- a/gdb/testsuite/gdb.cp/breakpoint.cc +++ b/gdb/testsuite/gdb.cp/breakpoint.cc @@ -17,8 +17,26 @@ =A0 =A0 You should have received a copy of the GNU General Public License =A0 =A0 along with this program. =A0If not, see . =A0*/ =A0 +int g =3D 0; + =A0class C1 { =A0public: + =A0C1(int i) : i_(i) {} + + =A0int foo () + =A0{ + =A0 =A0return 1; // conditional breakpoint in method + =A0} + + =A0int bar () + =A0{ + =A0 =A0for (int i =3D 0; i < 1; ++i) + =A0 =A0 =A0{ +=A0=A0=A0=A0=A0=A0=A0int t =3D i * 2; +=A0=A0=A0=A0=A0=A0=A0g +=3D t; // conditional breakpoint in method 2 + =A0 =A0 =A0} + =A0} + =A0 =A0class Nested { =A0 =A0public: =A0 =A0 =A0int @@ -27,13 +45,22 @@ public: =A0 =A0 =A0 =A0return 1; =A0 =A0 =A0} =A0 =A0}; + +private: + =A0int i_; =A0}; =A0 =A0int main () =A0{ =A0 =A0C1::Nested c1; =A0 - =A0c1.foo(); + =A0c1.foo (); + =A0 + =A0C1 c2 (2), c3 (3); + =A0c2.foo (); + =A0c2.bar (); + =A0c3.foo (); + =A0c3.bar (); =A0 =A0 =A0return 0; =A0} diff --git a/gdb/testsuite/gdb.cp/breakpoint.exp b/gdb/testsuite/gdb.cp/bre= akpoint.exp index d75e0f7..57f2fd4 100644 --- a/gdb/testsuite/gdb.cp/breakpoint.exp +++ b/gdb/testsuite/gdb.cp/breakpoint.exp @@ -61,5 +61,15 @@ proc test_breakpoint {name} { =A0 =A0test_breakpoint "C1::Nested::foo" =A0 +set bp_location1 [gdb_get_line_number "conditional breakpoint in method"] +set bp_location2 [gdb_get_line_number "conditional breakpoint in method 2"] +gdb_test "break $bp_location1 if i_=3D=3D3" ".*Breakpoint.*" "conditional = breakpoint in method" +gdb_test "break $bp_location2 if i_=3D=3D3" ".*Breakpoint.*" "conditional = breakpoint in method 2" +gdb_test "continue" ".*Breakpoint.*C1::foo.*" "continue to breakpoint" +gdb_test "print i_" "\\\$1 =3D 3" "check the member variable" +gdb_test "continue" ".*Breakpoint.*C1::bar.*" "continue to breakpoint" +gdb_test "print i_" "\\\$2 =3D 3" "check the member variable" + + =A0gdb_exit =A0return 0 diff --git a/gdb/valops.c b/gdb/valops.c index 80bee1e..5b05035 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -80,8 +80,6 @@ static enum =A0oload_classification classify_oload_match (struct badness_vector *, =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 int, int); =A0 -static int check_field_in (struct type *, const char *); - =A0static struct value *value_struct_elt_for_reference (struct type *, =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 = =A0 int, struct type *, =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =A0 = =A0 char *, @@ -2296,12 +2294,12 @@ destructor_name_p (const char *name, const struct t= ype *type) =A0 =A0return 0; =A0} =A0 -/* Helper function for check_field: Given TYPE, a structure/union, +/* Given TYPE, a structure/union, =A0 =A0 return 1 if the component named NAME from the ultimate target =A0 =A0 structure/union is defined, otherwise, return 0. =A0*/ =A0 -static int -check_field_in (struct type *type, const char *name) +int +check_field (struct type *type, const char *name) =A0{ =A0 =A0int i; =A0 @@ -2330,44 +2328,12 @@ check_field_in (struct type *type, const char *name) =A0 =A0 =A0} =A0 =A0 =A0for (i =3D TYPE_N_BASECLASSES (type) - 1; i >=3D 0; i--) - =A0 =A0if (check_field_in (TYPE_BASECLASS (type, i), name)) + =A0 =A0if (check_field (TYPE_BASECLASS (type, i), name)) =A0 =A0 =A0 =A0return 1; =A0 =A0 =A0return 0; =A0} =A0 - -/* C++: Given ARG1, a value of type (pointer to a)* structure/union, - =A0 return 1 if the component named NAME from the ultimate target - =A0 structure/union is defined, otherwise, return 0. =A0*/ - -int -check_field (struct value *arg1, const char *name) -{ - =A0struct type *t; - - =A0arg1 =3D coerce_array (arg1); - - =A0t =3D value_type (arg1); - - =A0/* Follow pointers until we get to a non-pointer. =A0*/ - - =A0for (;;) - =A0 =A0{ - =A0 =A0 =A0CHECK_TYPEDEF (t); - =A0 =A0 =A0if (TYPE_CODE (t) !=3D TYPE_CODE_PTR=20 -=A0=A0=A0=A0=A0=A0=A0 =A0&& TYPE_CODE (t) !=3D TYPE_CODE_REF) -=A0=A0=A0=A0=A0=A0=A0break; - =A0 =A0 =A0t =3D TYPE_TARGET_TYPE (t); - =A0 =A0} - - =A0if (TYPE_CODE (t) !=3D TYPE_CODE_STRUCT - =A0 =A0 =A0&& TYPE_CODE (t) !=3D TYPE_CODE_UNION) - =A0 =A0error (_("Internal error: `this' is not an aggregate")); - - =A0return check_field_in (t, name); -} - =A0/* C++: Given an aggregate type CURTYPE, and a member name NAME, =A0 =A0 return the appropriate member (or the address of the member, if =A0 =A0 WANT_ADDRESS). =A0This function is used to resolve user expressions @@ -2773,10 +2739,9 @@ value_of_local (const char *name, int complain) =A0struct value * =A0value_of_this (int complain) =A0{ - =A0if (current_language->la_language =3D=3D language_objc) - =A0 =A0return value_of_local ("self", complain); - =A0else - =A0 =A0return value_of_local ("this", complain); + =A0if (!current_language->la_name_of_this) + =A0 =A0return 0; + =A0return value_of_local (current_language->la_name_of_this, complain); =A0} =A0 =A0/* Create a slice (sub-string, sub-array) of ARRAY, that is LENGTH diff --git a/gdb/value.h b/gdb/value.h index ba226e5..5f8fe58 100644 --- a/gdb/value.h +++ b/gdb/value.h @@ -530,7 +530,7 @@ extern void print_variable_value (struct symbol *var, =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 =A0struct frame_info *frame, =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0 =A0struct ui_file *stream); =A0 -extern int check_field (struct value *, const char *); +extern int check_field (struct type *, const char *); =A0 =A0extern void typedef_print (struct type *type, struct symbol *news, =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 = =A0 struct ui_file *stream); --=20 1.5.3.5 =20