public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
From: sergiodj+buildbot@sergiodj.net
To: gdb-testers@sourceware.org
Subject: [binutils-gdb] (Ada) fix handling of minimal symbols (UNOP_CAST and UNOP_ADDR)
Date: Fri, 17 Nov 2017 18:07:00 -0000	[thread overview]
Message-ID: <ced9779b4c45b9bc9c16dd98fa30d7a620e93a55@gdb-build> (raw)

*** TEST RESULTS FOR COMMIT ced9779b4c45b9bc9c16dd98fa30d7a620e93a55 ***

Author: Joel Brobecker <brobecker@adacore.com>
Branch: master
Commit: ced9779b4c45b9bc9c16dd98fa30d7a620e93a55

(Ada) fix handling of minimal symbols (UNOP_CAST and UNOP_ADDR)

Consider a program which provides a symbol without debugging
information. For instance, compiling the following code without -g:

    Some_Minimal_Symbol : Integer := 1234;
    pragma Export (C, Some_Minimal_Symbol, "some_minsym");

Trying to print this variable with GDB now causes an error, which
is now expected:

    (gdb) p some_minsym
    'some_minsym' has unknown type; cast it to its declared type

However, trying to cast this symbol, or to take its address
does not work:

    (gdb) p integer(some_minsym)
    'some_minsym' has unknown type; cast it to its declared type
    (gdb) p &some_minsym
    'some_minsym' has unknown type; cast it to its declared type

Another manisfestation of this issue can be seen when trying to
insert an Ada exception catchpoint for a specific standard exception
(this only occurs if the Ada runtime is built without debugging
information, which is the default).  For instance:

    $ (gdb) catch exception constraint_error
    warning: failed to reevaluate internal exception condition for catchpoint 0: 'constraint_error' has unknown type; cast it to its declared type

This is because, internally, the cachtpoint uses a condition referencing
a minimal symbol, more precisely:

   long_integer (e) = long_integer (&constraint_error)

This patch fixes all issues listed above:

  1. resolve_subexp: Special-case the handling of OP_VAR_MSYM_VALUE
     expression elements, where there are no ambiguities to be resolved
     in that situation;

  2. ada_evaluate_subexp: Enhance the handling of the UNOP_CAST
     handling so as to process the case where the target of
     the cast is a minimal symbol (as well as a symbol with debugging
     information). This mimics what's done in C.

gdb/ChangeLog:

        * ada-lang.c (resolve_subexp): Add handling of OP_VAR_MSYM_VALUE.
        (ada_evaluate_subexp_for_cast): New function.
        (ada_evaluate_subexp) <UNOP_CAST>: Replace code by call to
        ada_evaluate_subexp_for_cast.
        (ada_evaluate_subexp) <nosideret>: Replace code by call to
        eval_skip_value.
        * eval.c (evaluate_var_value): Make non-static.
        (evaluate_var_msym_value, eval_skip_value): Likewise.
        * value.h (evaluate_var_value, evaluate_var_msym_value)
        (eval_skip_value): Declare.

gdb/testsuite/ChangeLog:

        * gdb.ada/minsyms: New testcase.

Tested on x86_64-linux. No regression. Fixes the following failures:

    catch_ex.exp: continuing to Program_Error exception
    catch_ex.exp: continuing to failed assertion
    catch_ex.exp: continuing to unhandled exception
    catch_ex.exp: continuing to program completion
    complete.exp: p <Exported_Capitalized>
    complete.exp: p Exported_Capitalized
    complete.exp: p exported_capitalized
    mi_catch_ex.exp: catch Program_Error (unexpected output)
    mi_catch_ex.exp: continue to exception catchpoint hit (unknown output after running)
    mi_catch_ex.exp: continue to assert failure catchpoint hit (unknown output after running)
    mi_catch_ex.exp: continue to unhandled exception catchpoint hit (unknown output after running)
    mi_ex_cond.exp: catch C_E if i = 2 (unexpected output)


             reply	other threads:[~2017-11-17 18:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-17 18:07 sergiodj+buildbot [this message]
2017-11-17 18:07 ` Failures on Fedora-x86_64-native-gdbserver-m32, branch master sergiodj+buildbot
2017-11-17 18:08 ` Failures on Fedora-x86_64-native-gdbserver-m64, " sergiodj+buildbot
2017-11-17 18:09 ` Failures on Fedora-x86_64-m64, " sergiodj+buildbot
2017-11-17 18:11 ` Failures on Fedora-s390x-m64, " sergiodj+buildbot
2017-11-17 18:17 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, " sergiodj+buildbot
2017-11-17 18:22 ` Failures on Fedora-i686, " sergiodj+buildbot
2017-11-17 18:26 ` Failures on Fedora-x86_64-cc-with-index, " sergiodj+buildbot
2017-11-17 18:28 ` Failures on Fedora-x86_64-m32, " sergiodj+buildbot
2017-11-17 18:35 ` Failures on Fedora-x86_64-native-extended-gdbserver-m32, " sergiodj+buildbot
2017-11-17 18:48 ` Failures on Ubuntu-AArch64-m64, " sergiodj+buildbot
2017-11-17 20:01 ` Failures on Ubuntu-AArch32-m32, " sergiodj+buildbot
2017-11-17 20:26 ` Failures on Ubuntu-AArch32-native-extended-gdbserver-m32, " sergiodj+buildbot

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=ced9779b4c45b9bc9c16dd98fa30d7a620e93a55@gdb-build \
    --to=sergiodj+buildbot@sergiodj.net \
    --cc=gdb-testers@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).