Skip to content

Commit b152df7

Browse files
authored
merge main into amd-staging (#461)
2 parents fb80160 + caaa395 commit b152df7

File tree

42 files changed

+444
-442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+444
-442
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ def verify_stop_exception_info(self, expected_description):
223223
return True
224224
return False
225225

226+
def verify_stop_on_entry(self) -> None:
227+
"""Waits for the process to be stopped and then verifies at least one
228+
thread has the stop reason 'entry'."""
229+
self.dap_server.wait_for_stopped()
230+
self.assertIn(
231+
"entry",
232+
(t["reason"] for t in self.dap_server.thread_stop_reasons.values()),
233+
"Expected at least one thread to report stop reason 'entry' in {self.dap_server.thread_stop_reasons}",
234+
)
235+
226236
def verify_commands(self, flavor: str, output: str, commands: list[str]):
227237
self.assertTrue(output and len(output) > 0, "expect console output")
228238
lines = output.splitlines()

lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "lldb/Utility/Stream.h"
2323
#include "lldb/Utility/Timer.h"
2424
#include "lldb/lldb-private-enumerations.h"
25-
#include "llvm/Support/FormatVariadic.h"
2625
#include "llvm/Support/ThreadPool.h"
2726
#include <atomic>
2827
#include <optional>
@@ -33,10 +32,10 @@ using namespace lldb_private::plugin::dwarf;
3332
using namespace llvm::dwarf;
3433

3534
void ManualDWARFIndex::Index() {
36-
if (m_indexed)
37-
return;
38-
m_indexed = true;
35+
std::call_once(m_indexed_flag, [this]() { IndexImpl(); });
36+
}
3937

38+
void ManualDWARFIndex::IndexImpl() {
4039
ElapsedTime elapsed(m_index_time);
4140
LLDB_SCOPED_TIMERF("%p", static_cast<void *>(m_dwarf));
4241
if (LoadFromCache()) {

lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,14 @@ class ManualDWARFIndex : public DWARFIndex {
6666
void Dump(Stream &s) override;
6767

6868
private:
69+
/// Reads the DWARF debug info to build the index once.
70+
///
71+
/// Should be called before attempting to retrieve symbols.
6972
void Index();
7073

74+
/// Call `ManualDWARFIndex::Index()` instead.
75+
void IndexImpl();
76+
7177
/// Decode a serialized version of this object from data.
7278
///
7379
/// \param data
@@ -170,7 +176,7 @@ class ManualDWARFIndex : public DWARFIndex {
170176
llvm::DenseSet<uint64_t> m_type_sigs_to_avoid;
171177

172178
IndexSet<NameToDIE> m_set;
173-
bool m_indexed = false;
179+
std::once_flag m_indexed_flag;
174180
};
175181
} // namespace dwarf
176182
} // namespace lldb_private::plugin

lldb/test/API/tools/lldb-dap/restart/TestDAP_restart.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,8 @@ def test_stopOnEntry(self):
5151
self.build_and_launch(program, stopOnEntry=True)
5252
[bp_main] = self.set_function_breakpoints(["main"])
5353

54-
self.dap_server.request_configurationDone()
55-
self.dap_server.wait_for_stopped()
56-
# Once the "configuration done" event is sent, we should get a stopped
57-
# event immediately because of stopOnEntry.
58-
self.assertTrue(
59-
len(self.dap_server.thread_stop_reasons) > 0,
60-
"expected stopped event during launch",
61-
)
62-
for _, body in self.dap_server.thread_stop_reasons.items():
63-
if "reason" in body:
64-
reason = body["reason"]
65-
self.assertNotEqual(
66-
reason, "breakpoint", 'verify stop isn\'t "main" breakpoint'
67-
)
54+
self.continue_to_next_stop()
55+
self.verify_stop_on_entry()
6856

6957
# Then, if we continue, we should hit the breakpoint at main.
7058
self.continue_to_breakpoints([bp_main])
@@ -73,17 +61,7 @@ def test_stopOnEntry(self):
7361
# main.
7462
resp = self.dap_server.request_restart()
7563
self.assertTrue(resp["success"])
76-
stopped_events = self.dap_server.wait_for_stopped()
77-
for stopped_event in stopped_events:
78-
if "body" in stopped_event:
79-
body = stopped_event["body"]
80-
if "reason" in body:
81-
reason = body["reason"]
82-
self.assertNotEqual(
83-
reason,
84-
"breakpoint",
85-
'verify stop after restart isn\'t "main" breakpoint',
86-
)
64+
self.verify_stop_on_entry()
8765

8866
@skipIfWindows
8967
def test_arguments(self):

lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_console.py

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,6 @@
1111

1212
@skipIfBuildType(["debug"])
1313
class TestDAP_restart_console(lldbdap_testcase.DAPTestCaseBase):
14-
def verify_stopped_on_entry(self, stopped_events: List[Dict[str, Any]]):
15-
seen_stopped_event = 0
16-
for stopped_event in stopped_events:
17-
body = stopped_event.get("body")
18-
if body is None:
19-
continue
20-
21-
reason = body.get("reason")
22-
if reason is None:
23-
continue
24-
25-
self.assertNotEqual(
26-
reason,
27-
"breakpoint",
28-
'verify stop after restart isn\'t "main" breakpoint',
29-
)
30-
if reason == "entry":
31-
seen_stopped_event += 1
32-
33-
self.assertEqual(seen_stopped_event, 1, "expect only one stopped entry event.")
34-
3514
@skipIfAsan
3615
@skipIfWindows
3716
@skipIf(oslist=["linux"], archs=["arm$"]) # Always times out on buildbot
@@ -92,11 +71,8 @@ def test_stopOnEntry(self):
9271
self.build_and_launch(program, console="integratedTerminal", stopOnEntry=True)
9372
[bp_main] = self.set_function_breakpoints(["main"])
9473

95-
self.dap_server.request_continue() # sends configuration done
96-
stopped_events = self.dap_server.wait_for_stopped()
97-
# We should be stopped at the entry point.
98-
self.assertGreaterEqual(len(stopped_events), 0, "expect stopped events")
99-
self.verify_stopped_on_entry(stopped_events)
74+
self.dap_server.request_configurationDone()
75+
self.verify_stop_on_entry()
10076

10177
# Then, if we continue, we should hit the breakpoint at main.
10278
self.dap_server.request_continue()
@@ -105,8 +81,7 @@ def test_stopOnEntry(self):
10581
# Restart and check that we still get a stopped event before reaching
10682
# main.
10783
self.dap_server.request_restart()
108-
stopped_events = self.dap_server.wait_for_stopped()
109-
self.verify_stopped_on_entry(stopped_events)
84+
self.verify_stop_on_entry()
11085

11186
# continue to main
11287
self.dap_server.request_continue()

lldb/tools/lldb-dap/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
# We need to include the llvm components we depend on manually, as liblldb does
22
# not re-export those.
33
set(LLVM_LINK_COMPONENTS Support)
4-
set(LLVM_TARGET_DEFINITIONS Options.td)
5-
tablegen(LLVM Options.inc -gen-opt-parser-defs)
6-
add_public_tablegen_target(LLDBDAPOptionsTableGen)
74

85
add_lldb_library(lldbDAP
96
Breakpoint.cpp

lldb/tools/lldb-dap/EventHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ llvm::Error SendThreadStoppedEvent(DAP &dap, bool on_entry) {
176176

177177
llvm::DenseSet<lldb::tid_t> old_thread_ids;
178178
old_thread_ids.swap(dap.thread_ids);
179-
uint32_t stop_id = process.GetStopID();
179+
uint32_t stop_id = on_entry ? 0 : process.GetStopID();
180180
const uint32_t num_threads = process.GetNumThreads();
181181

182182
// First make a pass through the threads to see if the focused thread

lldb/tools/lldb-dap/JSONUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ llvm::json::Value CreateThreadStopped(DAP &dap, lldb::SBThread &thread,
711711
break;
712712
}
713713
if (stop_id == 0)
714-
body.try_emplace("reason", "entry");
714+
body["reason"] = "entry";
715715
const lldb::tid_t tid = thread.GetThreadID();
716716
body.try_emplace("threadId", (int64_t)tid);
717717
// If no description has been set, then set it to the default thread stopped

lldb/tools/lldb-dap/tool/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
set(LLVM_TARGET_DEFINITIONS Options.td)
2+
tablegen(LLVM Options.inc -gen-opt-parser-defs)
3+
add_public_tablegen_target(LLDBDAPOptionsTableGen)
4+
15
add_lldb_tool(lldb-dap
26
lldb-dap.cpp
37

0 commit comments

Comments
 (0)