From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1879) id 710CB3858D1E; Fri, 11 Nov 2022 19:04:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 710CB3858D1E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1668193481; bh=f8HnulOpH2zG6FXoMhPjXdHaQN+gljikY/67QIj05LQ=; h=From:To:Subject:Date:From; b=HlEPmXrchAesJnMwdgkYZM6UKIGqpvxtk2q4zBjG6u15VfZuxvCxytnR7pBDmpl3N yxIbpwWk8bNoBjT0mLNd25R14svAomCznaTGkn1UXg1KZzKaZzZxtjBeksXQBZHNDm uGEPiXGPGfQdbY5XMgHVf101R/sLe2wP/mvu6Smo= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Simon Marchi To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb: fix start breakpoint expression not working in some languages X-Act-Checkin: binutils-gdb X-Git-Author: Simon Marchi X-Git-Refname: refs/heads/master X-Git-Oldrev: 36895e5335bcfaab939c7e8d2f271face79bc45c X-Git-Newrev: 075732ad92d1d6631c253c6213f2f3e03d07bdb6 Message-Id: <20221111190441.710CB3858D1E@sourceware.org> Date: Fri, 11 Nov 2022 19:04:41 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D075732ad92d1= d6631c253c6213f2f3e03d07bdb6 commit 075732ad92d1d6631c253c6213f2f3e03d07bdb6 Author: Simon Marchi Date: Fri Nov 11 07:58:35 2022 -0500 gdb: fix start breakpoint expression not working in some languages =20 Commit 0be837be9fb4 ("gdb: make "start" breakpoint inferior-specific") regresses gdb.ada/start.exp: =20 (gdb) start Error in expression, near `1'. (gdb) UNTESTED: gdb.ada/start.exp: start failed to land inside the = right procedure =20 This is because in Ada, the equality operator is =3D, not =3D=3D. =20 I checked the other languages supported by GDB, these other languages use =3D for equality: =20 - Pascal: tests like gdb.pascal/hello.exp are affected too - Modula-2: I tried building a Modula-2 hello world using gm2, but it seems like the generated DWARF doesn't specify the Modula-2 language in the CUs, it's C++ and C, so the selected language isn't "modula-2". But if I manually do "set language modula-2" on a dummy program and then "start", I get the same error. =20 Other languages all use =3D=3D. =20 So, a short term fix would be to use =3D or =3D=3D in the expression, b= ased on the current language. If this was meant to be permanent, I would suggest adding something like an "equality_operator" method to language_defn, that returns the right equality operator for the language. But the goal is to replace all this with proper inferior-specific breakpoints, so I hope all this is temporary. =20 Approved-By: Tom de Vries Change-Id: Id4d38e14a80e6bbbb1ad2b2277f974dd55192969 Diff: --- gdb/infcmd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index bf4a68e3557..6f83949cc7c 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -428,8 +428,13 @@ run_command_1 (const char *args, int from_tty, enum ru= n_how run_how) have proper inferior-specific breakpoint support, in the breakpoint machinery. We could then avoid inserting a breakpoint in the program spaces unrelated to this inferior. */ - std::string arg =3D string_printf ("-qualified %s if $_inferior =3D= =3D %d", main_name (), - current_inferior ()->num); + const char *op + =3D ((current_language->la_language =3D=3D language_ada + || current_language->la_language =3D=3D language_pascal + || current_language->la_language =3D=3D language_m2) ? "=3D" : "=3D= =3D"); + std::string arg =3D string_printf + ("-qualified %s if $_inferior %s %d", main_name (), op, + current_inferior ()->num); tbreak_command (arg.c_str (), 0); }