public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Simon Marchi <simark@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] gdb: fix start breakpoint expression not working in some languages
Date: Fri, 11 Nov 2022 19:04:41 +0000 (GMT)	[thread overview]
Message-ID: <20221111190441.710CB3858D1E@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=075732ad92d1d6631c253c6213f2f3e03d07bdb6

commit 075732ad92d1d6631c253c6213f2f3e03d07bdb6
Author: Simon Marchi <simon.marchi@polymtl.ca>
Date:   Fri Nov 11 07:58:35 2022 -0500

    gdb: fix start breakpoint expression not working in some languages
    
    Commit 0be837be9fb4 ("gdb: make "start" breakpoint inferior-specific")
    regresses gdb.ada/start.exp:
    
        (gdb) start
        Error in expression, near `1'.
        (gdb) UNTESTED: gdb.ada/start.exp: start failed to land inside the right procedure
    
    This is because in Ada, the equality operator is =, not ==.
    
    I checked the other languages supported by GDB, these other languages
    use = for equality:
    
     - 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.
    
    Other languages all use ==.
    
    So, a short term fix would be to use = or == in the expression, based 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.
    
    Approved-By: Tom de Vries <tdevries@suse.de>
    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 run_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 = string_printf ("-qualified %s if $_inferior == %d", main_name (),
-				       current_inferior ()->num);
+      const char *op
+	= ((current_language->la_language == language_ada
+	    || current_language->la_language == language_pascal
+	    || current_language->la_language == language_m2) ? "=" : "==");
+      std::string arg = string_printf
+	("-qualified %s if $_inferior %s %d", main_name (), op,
+	 current_inferior ()->num);
       tbreak_command (arg.c_str (), 0);
     }

                 reply	other threads:[~2022-11-11 19:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221111190441.710CB3858D1E@sourceware.org \
    --to=simark@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).