Skip to content

Commit 38c9bd4

Browse files
Merge pull request #9770 from adrian-prantl/cherry-pick-source-map
Cherry pick source map fixes
2 parents 25ada5d + fbcabb4 commit 38c9bd4

File tree

31 files changed

+499
-93
lines changed

31 files changed

+499
-93
lines changed

lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ def run_vscode(dbg, args, options):
12671267
def main():
12681268
parser = optparse.OptionParser(
12691269
description=(
1270-
"A testing framework for the Visual Studio Code Debug " "Adaptor protocol"
1270+
"A testing framework for the Visual Studio Code Debug Adaptor protocol"
12711271
)
12721272
)
12731273

lldb/test/API/tools/lldb-dap/attach/TestDAP_attach.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def set_and_hit_breakpoint(self, continueToExit=True):
3939
if continueToExit:
4040
self.continue_to_exit()
4141

42-
@skipIfWindows
4342
@skipIfNetBSD # Hangs on NetBSD as well
4443
def test_by_pid(self):
4544
"""
@@ -56,7 +55,6 @@ def test_by_pid(self):
5655
self.attach(pid=self.process.pid)
5756
self.set_and_hit_breakpoint(continueToExit=True)
5857

59-
@skipIfWindows
6058
@skipIfNetBSD # Hangs on NetBSD as well
6159
def test_by_name(self):
6260
"""
@@ -116,12 +114,8 @@ def test_by_name_waitFor(self):
116114
self.attach(program=program, waitFor=True)
117115
self.set_and_hit_breakpoint(continueToExit=True)
118116

119-
@skipIfWindows
120117
@skipIfDarwin
121118
@skipIfNetBSD # Hangs on NetBSD as well
122-
@skipIf(
123-
archs=["arm", "aarch64"]
124-
) # Example of a flaky run http://lab.llvm.org:8011/builders/lldb-aarch64-ubuntu/builds/5527/steps/test/logs/stdio
125119
def test_commands(self):
126120
"""
127121
Tests the "initCommands", "preRunCommands", "stopCommands",
@@ -155,7 +149,7 @@ def test_commands(self):
155149
initCommands = ["target list", "platform list"]
156150
preRunCommands = ["image list a.out", "image dump sections a.out"]
157151
postRunCommands = ["help trace", "help process trace"]
158-
stopCommands = ["frame variable", "bt"]
152+
stopCommands = ["frame variable", "thread backtrace"]
159153
exitCommands = ["expr 2+3", "expr 3+4"]
160154
terminateCommands = ["expr 4+2"]
161155
self.attach(
@@ -182,7 +176,7 @@ def test_commands(self):
182176
breakpoint_ids = self.set_function_breakpoints(functions)
183177
self.assertEqual(len(breakpoint_ids), len(functions), "expect one breakpoint")
184178
self.continue_to_breakpoints(breakpoint_ids)
185-
output = self.get_console(timeout=1.0)
179+
output = self.collect_console(timeout_secs=10, pattern=stopCommands[-1])
186180
self.verify_commands("stopCommands", output, stopCommands)
187181

188182
# Continue after launch and hit the "pause()" call and stop the target.
@@ -192,7 +186,7 @@ def test_commands(self):
192186
time.sleep(0.5)
193187
self.dap_server.request_pause()
194188
self.dap_server.wait_for_stopped()
195-
output = self.get_console(timeout=1.0)
189+
output = self.collect_console(timeout_secs=10, pattern=stopCommands[-1])
196190
self.verify_commands("stopCommands", output, stopCommands)
197191

198192
# Continue until the program exits
@@ -201,13 +195,12 @@ def test_commands(self):
201195
# "exitCommands" that were run after the second breakpoint was hit
202196
# and the "terminateCommands" due to the debugging session ending
203197
output = self.collect_console(
204-
timeout_secs=1.0,
198+
timeout_secs=10.0,
205199
pattern=terminateCommands[0],
206200
)
207201
self.verify_commands("exitCommands", output, exitCommands)
208202
self.verify_commands("terminateCommands", output, terminateCommands)
209203

210-
@skipIfWindows
211204
@skipIfDarwin
212205
@skipIfNetBSD # Hangs on NetBSD as well
213206
@skipIf(

lldb/test/API/tools/lldb-dap/attach/main.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
#include <stdio.h>
2+
#ifdef _WIN32
3+
#include <process.h>
4+
#include <windows.h>
5+
#else
26
#include <unistd.h>
7+
#endif
38

49
int main(int argc, char const *argv[]) {
510
lldb_enable_attach();
@@ -15,6 +20,10 @@ int main(int argc, char const *argv[]) {
1520
}
1621

1722
printf("pid = %i\n", getpid());
23+
#ifdef _WIN32
24+
Sleep(10 * 1000);
25+
#else
1826
sleep(10);
27+
#endif
1928
return 0; // breakpoint 1
2029
}

lldb/test/API/tools/lldb-dap/completions/TestDAP_completions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
variable_var1_completion = {"text": "var1", "label": "var1 -- int &"}
3333
variable_var2_completion = {"text": "var2", "label": "var2 -- int &"}
3434

35+
# Older version of libcxx produce slightly different typename strings for
36+
# templates like vector.
37+
@skipIf(compiler="clang", compiler_version=["<", "16.0"])
3538
class TestDAP_completions(lldbdap_testcase.DAPTestCaseBase):
3639
def verify_completions(self, actual_list, expected_list, not_expected_list=[]):
3740
for expected_item in expected_list:

lldb/test/API/tools/lldb-dap/console/TestDAP_console.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def check_lldb_command(
3737
),
3838
)
3939

40-
@skipIfWindows
4140
def test_scopes_variables_setVariable_evaluate(self):
4241
"""
4342
Tests that the "scopes" request causes the currently selected
@@ -80,7 +79,6 @@ def test_scopes_variables_setVariable_evaluate(self):
8079

8180
self.check_lldb_command("frame select", "frame #1", "frame 1 is selected")
8281

83-
@skipIfWindows
8482
def test_custom_escape_prefix(self):
8583
program = self.getBuildArtifact("a.out")
8684
self.build_and_launch(program, commandEscapePrefix="::")
@@ -96,7 +94,6 @@ def test_custom_escape_prefix(self):
9694
command_escape_prefix="::",
9795
)
9896

99-
@skipIfWindows
10097
def test_empty_escape_prefix(self):
10198
program = self.getBuildArtifact("a.out")
10299
self.build_and_launch(program, commandEscapePrefix="")
@@ -151,7 +148,6 @@ def test_exit_status_message_sigterm(self):
151148
"Exit status does not contain message 'exited with status'",
152149
)
153150

154-
@skipIfWindows
155151
def test_exit_status_message_ok(self):
156152
program = self.getBuildArtifact("a.out")
157153
self.build_and_launch(program, commandEscapePrefix="")

lldb/test/API/tools/lldb-dap/console/TestDAP_redirection_to_console.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88

99
class TestDAP_redirection_to_console(lldbdap_testcase.DAPTestCaseBase):
10-
@skipIfWindows
1110
def test(self):
1211
"""
1312
Without proper stderr and stdout redirection, the following code would throw an

lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313

1414
class TestDAP_coreFile(lldbdap_testcase.DAPTestCaseBase):
15-
@skipIfWindows
1615
@skipIfLLVMTargetMissing("X86")
1716
def test_core_file(self):
1817
current_dir = os.path.dirname(__file__)
@@ -58,9 +57,8 @@ def test_core_file(self):
5857
self.dap_server.request_next(threadId=32259)
5958
self.assertEqual(self.get_stackFrames(), expected_frames)
6059

61-
@skipIfWindows
6260
@skipIfLLVMTargetMissing("X86")
63-
def test_core_file_source_mapping(self):
61+
def test_core_file_source_mapping_array(self):
6462
"""Test that sourceMap property is correctly applied when loading a core"""
6563
current_dir = os.path.dirname(__file__)
6664
exe_file = os.path.join(current_dir, "linux-x86_64.out")
@@ -72,3 +70,17 @@ def test_core_file_source_mapping(self):
7270
self.attach(exe_file, coreFile=core_file, sourceMap=source_map)
7371

7472
self.assertIn(current_dir, self.get_stackFrames()[0]["source"]["path"])
73+
74+
@skipIfLLVMTargetMissing("X86")
75+
def test_core_file_source_mapping_object(self):
76+
"""Test that sourceMap property is correctly applied when loading a core"""
77+
current_dir = os.path.dirname(__file__)
78+
exe_file = os.path.join(current_dir, "linux-x86_64.out")
79+
core_file = os.path.join(current_dir, "linux-x86_64.core")
80+
81+
self.create_debug_adaptor()
82+
83+
source_map = {"/home/labath/test": current_dir}
84+
self.attach(exe_file, coreFile=core_file, sourceMap=source_map)
85+
86+
self.assertIn(current_dir, self.get_stackFrames()[0]["source"]["path"])

lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,9 @@ def run_test_evaluate_expressions(
101101
if context == "repl":
102102
# In the repl context expressions may be interpreted as lldb
103103
# commands since no variables have the same name as the command.
104-
self.assertEvaluate("var", r"\(lldb\) var\n.*")
104+
self.assertEvaluate("list", r"\(lldb\) list\n.*")
105105
else:
106-
self.assertEvaluateFailure("var") # local variable of a_function
106+
self.assertEvaluateFailure("list") # local variable of a_function
107107

108108
self.assertEvaluateFailure("my_struct") # type name
109109
self.assertEvaluateFailure("int") # type name
@@ -162,7 +162,7 @@ def run_test_evaluate_expressions(
162162

163163
# Expressions at breakpoint 3, which is inside a_function
164164
self.continue_to_next_stop()
165-
self.assertEvaluate("var", "42")
165+
self.assertEvaluate("list", "42")
166166
self.assertEvaluate("static_int", "42")
167167
self.assertEvaluate("non_static_int", "43")
168168

@@ -176,13 +176,13 @@ def run_test_evaluate_expressions(
176176
if self.isExpressionParsedExpected():
177177
self.assertEvaluate("a_function", "0x.*a.out`a_function.*")
178178
self.assertEvaluate("a_function(1)", "1")
179-
self.assertEvaluate("var + 1", "43")
179+
self.assertEvaluate("list + 1", "43")
180180
self.assertEvaluate("foo_func", "0x.*a.out`foo_func.*")
181181
self.assertEvaluate("foo_var", "44")
182182
else:
183183
self.assertEvaluateFailure("a_function")
184184
self.assertEvaluateFailure("a_function(1)")
185-
self.assertEvaluateFailure("var + 1")
185+
self.assertEvaluateFailure("list + 1")
186186
self.assertEvaluateFailure("foo_func")
187187
self.assertEvaluateFailure("foo_var")
188188

lldb/test/API/tools/lldb-dap/evaluate/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ static int static_int = 42;
88

99
int non_static_int = 43;
1010

11-
int a_function(int var) {
12-
return var; // breakpoint 3
11+
int a_function(int list) {
12+
return list; // breakpoint 3
1313
}
1414

1515
struct my_struct {

lldb/test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def setUp(self):
1717
self.main_basename = "main-copy.cpp"
1818
self.main_path = os.path.realpath(self.getBuildArtifact(self.main_basename))
1919

20+
@skipIfWindows
2021
def test_instruction_breakpoint(self):
2122
self.build()
2223
self.instruction_breakpoint_test()
@@ -34,7 +35,7 @@ def instruction_breakpoint_test(self):
3435
# Set source breakpoint 1
3536
response = self.dap_server.request_setBreakpoints(self.main_path, [main_line])
3637
breakpoints = response["body"]["breakpoints"]
37-
self.assertEquals(len(breakpoints), 1)
38+
self.assertEqual(len(breakpoints), 1)
3839
breakpoint = breakpoints[0]
3940
self.assertEqual(
4041
breakpoint["line"], main_line, "incorrect breakpoint source line"

0 commit comments

Comments
 (0)