]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
inadvertent language switch during breakpoint_re_set_one
authorJoel Brobecker <brobecker@adacore.com>
Fri, 1 Jun 2018 16:36:05 +0000 (09:36 -0700)
committerJoel Brobecker <brobecker@adacore.com>
Fri, 1 Jun 2018 16:36:59 +0000 (09:36 -0700)
commit8e817061976910fd1ac7bb8f689dbd96123ea593
tree91d7b4bef77023fdce47f71271c8a2ad84a8a46a
parent55e99962b24d9f2dc8a64b473259ca12e369fd20
inadvertent language switch during breakpoint_re_set_one

Trying to insert a breakpoint using *FUNC'address with an Ada program
and then running the program until reaching that breakpoint currently
yields the following behavior:

    (gdb) break *a'address
    Breakpoint 1 at 0x40240c: file a.adb, line 1.
    (gdb) run
    [1]  + 27222 suspended (tty output) /[...]/gdb -q simple_main

Unsuspending GDB then shows it was suspended trying to report
the following error:

    Starting program: /home/takamaka.a/brobecke/ex/simple/a
    Error in re-setting breakpoint 1: Unmatched single quote.
    Error in re-setting breakpoint 1: Unmatched single quote.
    Error in re-setting breakpoint 1: Unmatched single quote.
    [Inferior 1 (process 32470) exited normally]

The "a'address" is Ada speak for function A's address ("A" by
itself means the result of calling A with no arguments). The
transcript above shows that we're having problems trying to
parse the breakpoint location while re-setting it.  As a result,
we also fail to stop at the breakpoint.

Normally, breakpoint locations are evaluated with the current_language
being set to the language of the breakpoint. But, unfortunately for us,
what happened in this case is that parse_exp_in_context_1 calls
get_selected_block which eventually leads to a call to select_frame
because the current_frame hadn't been set yet.  select_frame then
finds that our language_mode is auto, and therefore changes the
current_language to match the language of the frame we just selected.
In our case, the language chosen was 'c', which of course is not
able to parse an Ada expression, hence the error.

This patch prevents this by forcing the language_mode to manual
before we call breakpoint_re_set_one.

gdb/ChangeLog:

        * breakpoint.c (breakpoint_re_set): Temporarily force language_mode
        to language_mode_manual while calling breakpoint_re_set_one.

gdb/testsuite/ChangeLog:

        * gdb.ada/bp_fun_addr: New testcase.

Tested on x86_64-linux.
gdb/ChangeLog
gdb/breakpoint.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.ada/bp_fun_addr.exp [new file with mode: 0644]
gdb/testsuite/gdb.ada/bp_fun_addr/a.adb [new file with mode: 0644]