Skip to content

[Dexter] Fix test failures on greendragon #66299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// REQUIRES: lldb
// UNSUPPORTED: system-windows
// XFAIL: system-darwin
//
// RUN: %clang -std=gnu++11 -O0 -g -lstdc++ %s -o %t
// RUN: %dexter --fail-lt 1.0 -w \
Expand Down
1 change: 0 additions & 1 deletion cross-project-tests/debuginfo-tests/dexter-tests/ctor.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// REQUIRES: lldb
// UNSUPPORTED: system-windows
// XFAIL: system-darwin
//
// RUN: %clang -std=gnu++11 -O0 -glldb %s -o %t
// RUN: %dexter --fail-lt 1.0 -w \
Expand Down
1 change: 0 additions & 1 deletion cross-project-tests/debuginfo-tests/dexter-tests/dbg-arg.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// REQUIRES: lldb
// UNSUPPORTED: system-windows
// XFAIL: system-darwin
//
// This test case checks debug info during register moves for an argument.
// RUN: %clang -std=gnu11 -m64 -mllvm -fast-isel=false -g %s -o %t
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// REQUIRES: lldb
// UNSUPPORTED: system-windows
// XFAIL: system-darwin
// RUN: %clang -std=gnu++11 -O0 -g %s -o %t
// RUN: %dexter --fail-lt 1.0 -w \
// RUN: --binary %t --debugger 'lldb' -v -- %s
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// REQUIRES: lldb
// UNSUPPORTED: system-windows
// XFAIL: system-darwin
// RUN: %clang -std=gnu11 -O2 -glldb %s -o %t
// RUN: %dexter --fail-lt 1.0 -w --debugger lldb --binary %t -- %s

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// REQUIRES: lldb
// UNSUPPORTED: system-windows
// XFAIL: system-darwin
// RUN: %clang -std=gnu11 -O2 -glldb %s -o %t
// RUN: %dexter --fail-lt 1.0 -w --debugger lldb --binary %t -- %s
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

// REQUIRES: lldb
// UNSUPPORTED: system-windows
// XFAIL: system-darwin

// RUN: %clang -g -O0 %s -o %t
// RUN: %dexter --fail-lt 1.0 -w \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// REQUIRES: lldb
// UNSUPPORTED: system-windows
// XFAIL: system-darwin
//
// RUN: %clang -std=gnu11 -O -glldb %s -o %t
// RUN: %dexter --fail-lt 1.0 -w --binary %t --debugger 'lldb' -- %s
Expand Down
1 change: 0 additions & 1 deletion cross-project-tests/debuginfo-tests/dexter-tests/vla.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// This test case verifies the debug location for variable-length arrays.
// REQUIRES: lldb
// UNSUPPORTED: system-windows
// XFAIL: system-darwin
//
// RUN: %clang -std=gnu11 -O0 -glldb %s -o %t
// RUN: %dexter --fail-lt 1.0 -w --binary %t --debugger 'lldb' -- %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,9 @@ def _run_debugger_custom(self, cmdline):
self.step_collection.debugger = self.debugger.debugger_info
self._break_point_all_lines()
self.debugger.launch(cmdline)

for command_obj in chain.from_iterable(self.step_collection.commands.values()):
self.watches.update(command_obj.get_watches())
early_exit_conditions = self._get_early_exit_conditions()

timed_out = False
total_timeout = Timeout(self.context.options.timeout_total)
max_steps = self.context.options.max_steps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ def run_debugger_subprocess(debugger_controller, working_dir_path):

with open(controller_path, "rb") as fp:
debugger_controller = pickle.load(fp)

return debugger_controller


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,34 @@ def delete_breakpoints(self, ids):
self._target.BreakpointDelete(id)

def launch(self, cmdline):
num_resolved_breakpoints = 0
for b in self._target.breakpoint_iter():
num_resolved_breakpoints += b.GetNumLocations() > 0
assert num_resolved_breakpoints > 0

if self.context.options.target_run_args:
cmdline += shlex.split(self.context.options.target_run_args)
self._process = self._target.LaunchSimple(cmdline, None, os.getcwd())
launch_info = self._target.GetLaunchInfo()
launch_info.SetWorkingDirectory(os.getcwd())
launch_info.SetArguments(cmdline, True)
error = self._interface.SBError()
self._process = self._target.Launch(launch_info, error)

if error.Fail():
raise DebuggerException(error.GetCString())
if not os.path.exists(self._target.executable.fullpath):
raise DebuggerException("exe does not exist")
if not self._process or self._process.GetNumThreads() == 0:
raise DebuggerException("could not launch process")
if self._process.GetNumThreads() != 1:
raise DebuggerException("multiple threads not supported")
self._thread = self._process.GetThreadAtIndex(0)

num_stopped_threads = 0
for thread in self._process:
if thread.GetStopReason() == self._interface.eStopReasonBreakpoint:
num_stopped_threads += 1
assert num_stopped_threads > 0
assert self._thread, (self._process, self._thread)

def step(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ def __init__(self):

def main() -> ReturnCode:
context = Context()

with PrettyOutput() as context.o:
context.logger = Logger(context.o)
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import csv
import pickle
import shutil
import platform

from dex.command.ParseCommand import get_command_infos
from dex.debugger.Debuggers import run_debugger_subprocess
Expand Down Expand Up @@ -217,6 +218,9 @@ def _run_test(self, test_name):
"""
try:
if self.context.options.binary:
if platform.system() == 'Darwin' and os.path.exists(self.context.options.binary + '.dSYM'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be a good idea to add a command line option to manually specify the location of the dsym file, but I'm happy to submit that as an extra patch afterwards.

# On Darwin, the debug info is in the .dSYM which might not be found by lldb, copy it into the tmp working directory
shutil.copytree(self.context.options.binary + '.dSYM', self.context.options.executable + '.dSYM')
# Copy user's binary into the tmp working directory.
shutil.copy(
self.context.options.binary, self.context.options.executable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// The dbgeng driver doesn't support \DexCommandLine yet.
// UNSUPPORTED: system-windows
// XFAIL: system-darwin
//
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Test that a \DexDeclareAddress value can have its value defined after
// the first reference to that value.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: address_after_ref.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// expression after the target line has been stepped on a given number of
// times.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: address_hit_count.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Test that a \DexDeclareAddress value can be used to compare the
// addresses of two local variables that refer to the same address.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: expression_address.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Test that a \DexDeclareAddress value can be used to compare two equal
// pointer variables.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: identical_address.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Test that multiple \DexDeclareAddress references that point to different
// addresses can be used within a single \DexExpectWatchValue.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: multiple_address.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Test that a \DexDeclareAddress value can be used to compare two pointer
// variables that have a fixed offset between them.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: offset_address.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Test that a \DexDeclareAddress value can be used to check the change in
// value of a variable over time, relative to its initial value.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: self_comparison.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// condition (x == 5) is satisfied.
// Tests using the default controller (no \DexLimitSteps).
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: default_conditional.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// given number of times.
// Tests using the default controller (no \DexLimitSteps).
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: default_conditional_hit_count.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// specific number of times.
// Tests using the default controller (no \DexLimitSteps).
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: default_hit_count.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
// is stepped on.
// Tests using the default controller (no \DexLimitSteps).
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: default_simple.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
// The dbgeng driver doesn't support \DexLimitSteps yet.
// UNSUPPORTED: system-windows
// XFAIL: system-darwin
//
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//
// The dbgeng driver doesn't support \DexLimitSteps yet.
// UNSUPPORTED: system-windows
// XFAIL: system-darwin
//
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
// The dbgeng driver doesn't support \DexLimitSteps yet.
// UNSUPPORTED: system-windows
// XFAIL: system-darwin
//
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Test that \DexLimitSteps keyword argument hit_count correctly limits
// the number of times the command can trigger.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: hit_count.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Purpose:
// Check number of step lines are correctly reported in json output.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t --verbose -- %s | FileCheck %s
// CHECK: limit_steps_check_json_step_count.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Check the DexLimit steps only gathers step info for 2 iterations of a
// for loop.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: limit_steps_expect_loop.cpp:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Purpose:
// Ensure that limited stepping breaks for all expected values.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: limit_steps_expect_value.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// doesn't exist. This can happen due to optimisations or label is on an
// empty line.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: limit_steps_line_mismatch.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Purpose:
// Ensure that multiple overlapping \DexLimitSteps ranges do not interfere.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: limit_steps_overlapping_ranges.cpp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Purpose:
// Test that LimitStep commands can exist on the same from line.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: limit_steps_same_line_conditional.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Test that \DexLimitSteps can be used without a condition (i.e. the
// breakpoint range is set any time from_line is stepped on).
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: unconditional.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
// The dbgeng driver doesn't support \DexLimitSteps yet.
// UNSUPPORTED: system-windows
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: not %dexter_regression_test_run --binary %t -v -- %s | FileCheck %s

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Check that the optional keyword argument 'on_line' makes a \DexLabel label
// that line instead of the line the command is found on.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -- %s | FileCheck %s
// CHECK: label_another_line.cpp: (1.0000)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Purpose:
// Check that we can use label-relative line numbers.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t -v -- %s | FileCheck %s
//
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// The dbgeng driver doesn't support --target-run-args yet.
// UNSUPPORTED: system-windows
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t --target-run-args "a b 'c d'" -- %s | FileCheck %s
// CHECK: target_run_args.c:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// The dbgeng driver doesn't support --target-run-args yet.
// UNSUPPORTED: system-windows
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t --target-run-args "a b 'c d'" -- %s | FileCheck %s
// CHECK: target_run_args_with_command.c:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Purpose:
// Check the `view` subtool works with typical inputs.
//
// XFAIL: system-darwin
// RUN: %dexter_regression_test_build %s -o %t
// RUN: %dexter_regression_test_run --binary %t --results %t.results -- %s
//
Expand Down