Commit Graph

199 Commits

Author SHA1 Message Date
OCHyams faf5f1cbba [dexter] Fix DexLimitSteps when breakpoint can't be set at requested location
Using a DexLimitSteps command forces dexter to use the ConditionalController
debugger controller. At each breakpoint the ConditionalController needs to
understand which one has been hit. Prior to this patch, upon hitting a
breakpoint, dexter used the current source location to look up which requested
breakpoint had been hit.

A breakpoint may not get set at the exact location that the user (dexter)
requests. For example, if the requested breakpoint location doesn't exist
in the line table then then debuggers will (usually, AFAICT) set the breakpoint
at the next available valid breakpoint location.

This meant that, occasionally in unoptimised programs and frequently in
optimised programs, the ConditionalController was failing to determine which
breakpoint had been hit.

This is the fix:

Change the DebuggerBase breakpoint interface to use opaque breakpoint ids
instead of using source location to identify breakpoints, and update the
ConditionalController to track breakpoints instead of locations.

These now return a breakpoint id:

    add_breakpoint(self, file_, line)
    _add_breakpoint(self, file_, line)
    add_conditional_breakpoint(self, file_, line, condition)
    _add_conditional_breakpoint(self, file_, line, condition)

Replace:

    delete_conditional_breakpoint(self, file_, line, condition)
    _delete_conditional_breakpoint(self, file_, line, condition)

with:

    delete_breakpoint(self, id)

Add:

    get_triggered_breakpoint_ids(self)

A breakpoint id is guaranteed to be unique for each requested breakpoint, even
for duplicate breakpoint requests. Identifying breakpoints like this, instead
of by location, removes the possibility of mixing up requested and bound
breakpoints.

This closely matches the LLDB debugger interface so little work was required in
LLDB.py, but some extra bookkeeping is required in VisualStudio.py to maintain
the new breakpoint id semantics. No implementation work has been done in
dbgeng.py as DexLimitSteps doesn't seem to support dbgeng at the moment.

Testing
Added:
dexter/feature_tests/commands/perfect/limit_steps/limit_steps_line_mismatch.cpp

There were no unexpected failures running the full debuginfo-tests suite.

The regression tests use dbgeng on windows by default, and as mentioned above
dbgeng isn't supported yet, so I have also manually tested (i.e. without lit)
that this specific test works as expected with clang and Visual Studio 2017 on
Windows.

Reviewed By: TWeaver

Differential Revision: https://reviews.llvm.org/D98699
2021-03-23 11:33:43 +00:00
OCHyams 61d314024d [dexter] Check path != None before calling os.path.exists
The test optnone-simple-functions.cpp added in D97668 fails on macOS.
os.path.exists raises an exception because we pass it None. Guard against this.

Related revision: https://reviews.llvm.org/D97668
2021-03-15 11:40:05 +00:00
Nathan Chancellor 633549f73e debuginfo-tests: Fix check-gdb-mlir-support build after MLIR API change in a4bb667d83
Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D98613
2021-03-15 05:10:15 +00:00
Mehdi Amini 068aa12f96 Fix `debuginfo-tests/llvm-prettyprinters` build after MLIR API change in e6260ad043 (NFC) 2021-03-02 19:21:03 +00:00
OCHyams 14be3f0e88 [debuginfo-tests] Add some optnone tests
Add dexter tests using the optnone attribute in various scenarios. Our users
have found optnone useful when debugging optimised code. We have these tests
downstream (and one upstream already: D89873) and we would like to contribute
them if there is any interest.

The tests are fairly self explanatory. Testing optnone with:
  * optnone-fastmath.cpp: floats and -ffast-math,
  * optnone-simple-functions: simple functions and integer arithmetic,
  * optnone-struct-and-methods: a struct with methods,
  * optnone-vectors-and-functions: templates and integer vector arithmetic.

optnone-vectors-and-functions contains two FIXMEs. The first problem is that
lldb seems to struggle with evaluating expressions with the templates used
here (example below). Perhaps this is PR42920?

  (lldb) p TypeTraits<int __attribute__((ext_vector_type(4)))>::NumElements
  error: <user expression 0>:1:1: no template named 'TypeTraits'
  TypeTraits<int __attribute__((ext_vector_type(4)))>::NumElements
  ^
The second is that while lldb cannot evaluate the following expression, gdb
can, but it reports that the variable has been optimzed away. It does this when
compiling at O0 too. llvm-dwarfdump shows that MysteryNumber does have a
location. I don't know whether the DIE is bad or if both debuggers just don't
support it.

  TypeTraits<int __attribute__((ext_vector_type(4)))>::MysteryNumber

  DW_TAG_variable
      DW_AT_specification   (0x0000006b "MysteryNumber")
      DW_AT_location        (DW_OP_addr 0x601028)
      DW_AT_linkage_name    ("_ZN10TypeTraitsIDv4_iE13MysteryNumberE")

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D97668
2021-03-02 08:46:39 +00:00
Harmen Stoppels a54f160b3a Prefer /usr/bin/env xxx over /usr/bin/xxx where xxx = perl, python, awk
Allow users to use a non-system version of perl, python and awk, which is useful
in certain package managers.

Reviewed By: JDevlieghere, MaskRay

Differential Revision: https://reviews.llvm.org/D95119
2021-02-25 11:32:27 +01:00
OCHyams 52bc1c1bd5 [dexter] Force dexter tests to use the host triple
If the default target and host triple don't match then print the following
message when the lit test runs:

    Forcing dexter tests to use host triple {HOST_TRIPLE}.

If we can't target the host arch then, when lit runs, we mark
the dexter test directories as UNSUPPORTED and print the message:

    Host triple {HOST_TRIPLE} not supported. Skipping dexter tests in
    the debuginfo-tests project.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D96494
2021-02-24 11:11:17 +00:00
OCHyams 54b6d01685 [debuginfo-tests] Recommit test sret.cpp
This test was accidently removed when the directory structure was shuffled
around for dexter in f78c236efd.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D96968
2021-02-19 08:45:15 +00:00
James Henderson e8b9da712f [debuginfo-tests] Delete unused/duplicate imports
Differential Revision: https://reviews.llvm.org/D96502

Reviewed by: aprantl
2021-02-15 14:32:03 +00:00
James Henderson d623652499 [debuginfo-tests] Remove some unused config variables
Differential Revision: https://reviews.llvm.org/D96500

Reviewed by: aprantl
2021-02-15 14:20:56 +00:00
James Henderson 6c330f0df8 [debuginfo-tests] Remove explicit checks for Python 3
LLVM has a minimum requirement of python 3.6 now, and Python is
explicitly checked for in the LLVM CMakeLists.txt, so this check is no
longer needed here.

Differential Revision: https://reviews.llvm.org/D96499

Reviewed by: aprantl
2021-02-15 14:20:55 +00:00
James Henderson a31eae8405 [test][Dexter] Fix test failure if space in python path
The '%dexter_regression_test' substitution was missing quotes around the
python executable, unlike other substitutions of a similar nature in the
file. This changes fixes the issue.

Differential Revision: https://reviews.llvm.org/D96420

Reviewed by: jmorse, aganea
2021-02-11 11:46:39 +00:00
Raphael Isemann a874d182c6 [DebugInfo] Prevent inlining in NRVO-string test cases
Since the new pass manager has been enabled by default these tests had their
-O1 variations failing due to the tested functions being inlined. This just
adds no_inline to the respective code similar to what we did in other
tests (e.g. aa56b30014 ).
2021-02-11 10:33:30 +01:00
Tres Popp c2c83e97c3 Revert "Revert "Reorder MLIRContext location in BuiltinAttributes.h""
This reverts commit 511dd4f438 along with
a couple fixes.

Original message:
Now the context is the first, rather than the last input.

This better matches the rest of the infrastructure and makes
it easier to move these types to being declaratively specified.

Phabricator: https://reviews.llvm.org/D96111
2021-02-08 10:39:58 +01:00
Jeremy Morse c8e6cde95c [Dexter] Avoid infinite loop in dbgeng driver
This method of the dbgeng debugger driver used to just "pass", as setting
dbgeng free running still leads to numerous errors. This wasn't a problem
in the past because, as it turns out, nothing called the go method.
However, a recent refactor uses it.

Rather than launch dbgeng free running, instead have it single step one
step forwards. This is slow, but it makes progress, where previously we
weren't.

Differential Revision: https://reviews.llvm.org/D91737
2021-02-04 14:57:04 +00:00
OCHyams d77a572087 [DebugInfo][dexter] Tweak dexter test for merged values
Tweak dexter-tests/memvars/inline-escaping-function.c added in D94761
(b7e516202e) by adding a 'param' use after the merge point. The test XFAILS
with and without this change, but without it the test looks very similar to
memvars/unused-merged-value.c. The test now demonstrates the problem more
clearly.
2021-01-19 12:45:31 +00:00
OCHyams b7e516202e [DebugInfo][dexter] Add dexter tests for merged values
These dexter tests illustrate PR48719, the summary of which is:

Sometimes we insert dbg.values for merged values (PHIs) when promoting
variables, sometimes we don't. Sometimes there is no PHI because the merged
value is never used. It doesn't matter because LiveDebugValues understands these
merged values (implicit or otherwise) and correctly updates the debug
info. Importantly, these merged variable values (which may or may not exist as
PHIs, and may or not be represented with dbg.values) are //always// implicitly
defined by the combination of incoming edges and the incoming variable locations
along those edges by virtue of LiveDebugValues existing. Unfortunately, it is
possible to mess with the CFG and remove / move these edges before
LiveDebugValues runs. In this case our debug info model only works when the
merged value is tracked by a dbg.value. Currently, this is only done rigorously
for variables which are A) promoted in the first round of mem2reg and B) are
used after the merge point.

As an example, compile the following source with -O3 -g and step through with a
debugger. You will see parama=5 throughout the function fun which is incorrect -
we expect to see param=20 after the conditional assignment.

    __attribute__((optnone))
    void esc(int* p) {}

    __attribute__((optnone))
    void fluff() {}

    __attribute__((noinline))
    int fun(int parama, int paramb) {
      if (parama)
        parama = paramb;
      fluff();           // DexLabel('s0')
      esc(&parama);
      return 0;
    }

    int main() {
      return fun(5, 20);
    }

1. parama is escaped by esc(&parama) so it is not promoted by
   SROA/mem2reg (failing condition "A" above).
2. InstCombine's LowerDbgDeclare converts the dbg.declare to a set of
   dbg.values (tracking the stored SSA values).
3. InstCombine replaces the two stores to parama's alloca (the initial
   parameter register store in entry and the assignment in if.then) with a
   PHI+store in the common sucessor.
4. SimplifyCFG folds the blocks together and converts the PHI to a
   select.

The debug info is not updated to account for the merged value in the successor
prior to SimplifyCFG when it exists as a PHI, or during when it becomes a
select.

As with D89543, which added some dexter tests for escaped locals, the idea is
to build a set of source-level tests which highlights existing issues and
might be useful in evaluating a new debug info model.

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D94761
2021-01-19 11:11:00 +00:00
Mehdi Amini 9e1aaa9943 Fix check-gdb-mlir-support build after MLIR API changed to take Context as first argument 2021-01-07 21:30:39 +00:00
Mehdi Amini 476db17dcb Fix include path for check-gdb-mlir-support to include the MLIR binary dir
This fixes a build failure:

fatal error: 'mlir/IR/BuiltinTypes.h.inc' file not found
2021-01-07 21:29:09 +00:00
Fangrui Song 25bf4a8f42 [debuginfo-test] Fix -Wunused-value 2021-01-06 20:39:07 -08:00
Krzysztof Parzyszek 1b404ad51e Include BuiltinAttributes.h in llvm-prettyprinters/gdb/mlir-support.cpp
This header was introduced in c7cae0e4fa.
2020-12-04 15:57:05 -06:00
River Riddle 09f7a55fad [mlir][Types][NFC] Move all of the builtin Type classes to BuiltinTypes.h
This is part of a larger refactoring the better congregates the builtin structures under the BuiltinDialect. This also removes the problematic "standard" naming that clashes with the "standard" dialect, which is not defined within IR/. A temporary forward is placed in StandardTypes.h to allow time for downstream users to replaced references.

Differential Revision: https://reviews.llvm.org/D92435
2020-12-03 18:02:10 -08:00
Moritz Sichert 5747380772 Added GDB pretty printer for StringMap
Reviewed By: csigg, dblaikie

Differential Revision: https://reviews.llvm.org/D91183
2020-11-18 16:33:34 -08:00
Jonas Devlieghere 2993850237 [debuginfo-tests] Skip optnone-loops.cpp on Darwin
This is failing on GreenDragon:
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/24745/
2020-11-06 13:05:33 -08:00
Louis Dionne 08e6903eb4 [debuginfo-tests] NFC: Move test that was committed to the wrong location
Differential Revision: https://reviews.llvm.org/D90931
2020-11-06 08:23:34 -05:00
Nabeel Omer 3ebcef4b73 [Dexter] add visual studio 2019 debugger support
Adds visual studio debugger support to dexter via option --debugger vs2019

Differential Revision: https://reviews.llvm.org/D89803

Author:    Nabeel Omer <nabeel.omer@sony.com>
2020-11-04 16:57:19 +00:00
Tom Weaver f2f4554f88 [debuginfo-tests][dexter] add requires lldb to two tests
both deferred_globals.cpp namespace.cpp require lldb in order to run and will
fail if it's not available.

add the required lines to the top of the tests.
2020-10-28 17:33:29 +00:00
Nabeel Omer afc44efc26 [debuginfo-tests][dexter] Add two new debug experience tests
deferred_globals.cpp: Verify that debug information for a local variable does
not hide a global definition that has the same name

namespace.cpp: Ensure that the debug information for a global variable
includes namespace information.

Differential Revision: https://reviews.llvm.org/D89462

Author:    Nabeel Omer <nabeel.omer@sony.com>
2020-10-28 14:21:40 +00:00
OCHyams 66d03af88c [DebugInfo][dexter] Add dexter tests for escaped locals
Recently there has been renewed interest in improving debug-info for variables
that (partially or otherwise) live on the stack in optimised code.

At the moment instcombine speculates that stack slots are probably going to be
promoted to registers, and prepares the debug-info accordingly. It runs a
function called LowerDbgDeclare which converts dbg.declares to a set of
dbg.values after loads, and before stores and calls. Sometimes the stack
location remains (e.g. for escaped locals). If any dbg.values become undef
where the stack location is still valid we end up unnecessarily reducing
variable location coverage due to our inability to track multiple locations
simultaneously. There is a flag to disable this feature
(-instcombine-lower-dbg-declare=0), which prevents this conversion at the cost
of sometimes providing incorrect location info in the face of DSE, DCE, GVN,
CSE etc.

This has been discussed fairly extensively on PR34136.

The idea of these tests is to provide examples of situations that we should
consider when designing a new system, to aid discussions and eventually help
evaluate the implementation.

Dexter isn't ideal for observing specific optimisation behaviour. Writing an
exaustive test suite would be difficult, and the resultant suite would be
fragile. However, I think having some concrete executable examples is useful
at least as a reference.

Differential Revision: https://reviews.llvm.org/D89543
2020-10-26 10:57:36 +00:00
Nabeel Omer 7d8c19a4e9 [Dexter][NFC] Add Missing Commands to Commands.md Contents
NFC patch simply updates the commands.md documentation contents with missing
  links to the DexLimitSteps and DexLabel command documentation.

  Differential Revision: https://reviews.llvm.org/D89689

  Author:    Nabeel Omer <nabeel.omer@sony.com>
2020-10-19 16:38:49 +01:00
Christian Sigg e9b3884161 Add GDB prettyprinters for a few more MLIR types.
Reviewed By: dblaikie, jpienaar

Differential Revision: https://reviews.llvm.org/D87159
2020-09-30 21:22:47 +02:00
OCHyams 485e6db872 Revert "Adding GDB PrettyPrinter for mlir::Identifier."
This reverts commit 9e9e6e698d.

This commit is causing builds that include the 'debuginfo-tests' project to
fail.

Apple has a public bot which shows the failure:
http://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/23667/console
2020-09-03 08:28:15 +01:00
Christian Sigg 9e9e6e698d Adding GDB PrettyPrinter for mlir::Identifier.
This is the first bit from D73546. Primarily setting up the corresponding test. Will add more pretty printers in a separate revision.

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D86937
2020-09-03 08:18:09 +02:00
serge-sans-paille 515bc8c155 Harmonize Python shebang
Differential Revision: https://reviews.llvm.org/D83857
2020-07-16 21:53:45 +02:00
Fangrui Song ac567eec11 [CMake] Add check-debuginfo-* targets
* check-debuginfo-dexter runs lit tests under debuginfo-tests/dexter/
* check-debuginfo-llgdb-tests runs lit tests under debuginfo-tests/llgdb-tests/
* ...

Reviewed By: tbosch

Differential Revision: https://reviews.llvm.org/D82605
2020-06-26 11:18:18 -07:00
Fangrui Song 161ae1f398 [CMake] Add optional lldb dependency to DEBUGINFO_TEST_DEPS
if(TARGET asan) is still brittle as it depends on the order of
compiler-rt and debuginfo-tests in LLVM_ENABLE_PROJECTS.
2020-06-25 18:28:43 -07:00
Fangrui Song e477a5f6c8 [CMake] Add optional asan & safestack dependencies to DEBUGINFO_TEST_DEPS 2020-06-25 17:56:35 -07:00
Fangrui Song 40dd5cb110 [debuginfo-tests] Require "lldb" for some dexter tests 2020-06-25 17:35:01 -07:00
Fangrui Song ca8b7ef763 [CMake] Add llvm-config to DEBUGINFO_TEST_DEPS
Fix `fatal: Could not run process ['/path/to/build/./bin/llvm-config', '--build-mode']`
when running check-debuginfo in a fresh build directory.
2020-06-25 16:49:33 -07:00
Tobias Bosch 53d6bfef32 [Dexter] Add --source-dir-root flag
Summary:
This allows to run dexter tests with separately compiled
binaries that are specified via --binary if the source file
location changed between compilation and dexter test run.

Reviewers: TWeaver, jmorse, probinson, #debug-info

Reviewed By: jmorse

Subscribers: #debug-info, cmtice, llvm-commits

Tags: #llvm, #debug-info

Differential Revision: https://reviews.llvm.org/D81319
2020-06-18 09:29:08 -07:00
Mehdi Amini d31c9e5a46 Change filecheck default to dump input on failure
Having the input dumped on failure seems like a better
default: I debugged FileCheck tests for a while without knowing
about this option, which really helps to understand failures.

Remove `-dump-input-on-failure` and the environment variable
FILECHECK_DUMP_INPUT_ON_FAILURE which are now obsolete.

Differential Revision: https://reviews.llvm.org/D81422
2020-06-09 18:57:46 +00:00
Tom Weaver c6aa829644 [Dexter] Add DexLimitSteps command and ConditionalController
* Adds DexLimitSteps Command.
* Add ConditionalController, a new DebuggerController type.
* 5 regression tests
* documentation

* recommit, fixed accidental adding of unnecessary file

Reviewers: jmorse

Differential Revision: https://reviews.llvm.org/D79786
2020-06-05 12:53:56 +01:00
Tom Weaver 05eabb5204 Revert "[Dexter] Add DexLimitSteps command and ConditionalController"
This reverts commit 81e836a5a6.

Accidentally committed a diff file.
2020-06-03 12:28:26 +01:00
Tom Weaver 81e836a5a6 [Dexter] Add DexLimitSteps command and ConditionalController
* Adds DexLimitSteps Command.
  * Add ConditionalController, a new DebuggerController type.
  * 5 regression tests
  * documentation

  Reviewers: jmorse

  Differential Revision: https://reviews.llvm.org/D79786
2020-06-02 16:19:43 +01:00
Tom Weaver bf1cdc2c6c [Dexter] Add os.path.normcase(...) transform to test path early.
When passing a test path, if the path points directly at a file, then
  normcase would not be called on path.

  This would change the expected lower case drive path, on windows, to be
  uppercase. This patch simply calls normcase on the test path at the earliest
  point possible to avoid this issue.

  Reviewers: djtodoro, jmorse

  Differential Revision: https://reviews.llvm.org/D78633
2020-06-02 16:09:17 +01:00
Christian Sigg 104e38cf76 Only run pretty-printer tests for builds with debug-info.
Reviewers: dblaikie

Reviewed By: dblaikie

Subscribers: tbosch, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79897
2020-05-14 09:19:43 +02:00
Christopher Tetreault f829ba60da Ensure that CMake tries to find Python3 before processing
Summary:
It is possible that CMake tries to process debuginfo-tests before any
attempt to find Python3. Ensure that CMake attempts to find it before
complaining that it doesn't exist.

Reviewers: zturner, rnk, jmorse, chandlerc

Reviewed By: rnk

Subscribers: mgorny, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D79795
2020-05-13 13:56:48 -07:00
Jonas Devlieghere 7f84b6c1ba [debuginfo-tests] Update Python variable in lit.site.cfg.py 2020-04-30 10:51:45 -07:00
Jonas Devlieghere ba8163e629 [debuginfo-tests] Update Python CMake variable 2020-04-29 09:51:32 -07:00
Djordje Todorovic 871388e384 [dexter] Require python >= 3.6
The documentation says we need python >= 3.6. Running it with an older
version, we get verbose output from python interpreter.
This patch fixes that as:

  $ python2 dexter.py list-debuggers
  You need python 3.6 or later to run DExTer

Differential Revision: https://reviews.llvm.org/D78621
2020-04-23 11:46:10 +02:00