Skip to content

Commit f93c15d

Browse files
committed
replace multimap with map of vectors
1 parent 6e6baf0 commit f93c15d

File tree

6 files changed

+29
-29
lines changed

6 files changed

+29
-29
lines changed

lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,7 +1809,7 @@ RISCVSingleStepBreakpointLocationsPredictor::GetBreakpointLocations(
18091809
"RISCVSingleStepBreakpointLocationsPredictor::%s: can't find "
18101810
"corresponding load reserve insturuction",
18111811
__FUNCTION__);
1812-
return {*pc + inst->is_rvc ? 2u : 4u};
1812+
return {*pc + (inst->is_rvc ? 2u : 4u)};
18131813
}
18141814

18151815
return SingleStepBreakpointLocationsPredictor::GetBreakpointLocations(status);
@@ -1874,7 +1874,7 @@ RISCVSingleStepBreakpointLocationsPredictor::HandleAtomicSequence(
18741874
"RISCVSingleStepBreakpointLocationsPredictor::%s: can't find "
18751875
"corresponding store conditional insturuction",
18761876
__FUNCTION__);
1877-
return {entry_pc + lr_inst->is_rvc ? 2u : 4u};
1877+
return {entry_pc + (lr_inst->is_rvc ? 2u : 4u)};
18781878
}
18791879

18801880
lldb::addr_t exit_pc = pc;

lldb/source/Plugins/Process/FreeBSD/NativeProcessFreeBSD.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -324,17 +324,15 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
324324
auto thread_info =
325325
m_threads_stepping_with_breakpoint.find(thread->GetID());
326326
if (thread_info != m_threads_stepping_with_breakpoint.end() &&
327-
thread_info->second == regctx.GetPC()) {
327+
llvm::is_contained(thread_info->second, regctx.GetPC())) {
328328
thread->SetStoppedByTrace();
329-
while (thread_info != m_threads_stepping_with_breakpoint.end() {
330-
Status brkpt_error = RemoveBreakpoint(thread_info->second);
329+
for (auto &&bp_addr : thread_info->second) {
330+
Status brkpt_error = RemoveBreakpoint(bp_addr);
331331
if (brkpt_error.Fail())
332332
LLDB_LOG(log, "pid = {0} remove stepping breakpoint: {1}",
333333
thread_info->first, brkpt_error);
334-
m_threads_stepping_with_breakpoint.erase(thread_info);
335-
thread_info =
336-
m_threads_stepping_with_breakpoint.find(thread->GetID());
337334
}
335+
m_threads_stepping_with_breakpoint.erase(thread_info);
338336
} else
339337
thread->SetStoppedByBreakpoint();
340338
FixupBreakpointPCAsNeeded(*thread);

lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ void NativeProcessLinux::MonitorBreakpoint(NativeThreadLinux &thread) {
833833
auto stepping_with_bp_it =
834834
m_threads_stepping_with_breakpoint.find(thread.GetID());
835835
if (stepping_with_bp_it != m_threads_stepping_with_breakpoint.end() &&
836-
stepping_with_bp_it->second == reg_ctx.GetPC())
836+
llvm::is_contained(stepping_with_bp_it->second, reg_ctx.GetPC()))
837837
thread.SetStoppedByTrace();
838838

839839
StopRunningThreads(thread.GetID());
@@ -1960,10 +1960,12 @@ void NativeProcessLinux::SignalIfAllThreadsStopped() {
19601960
// Clear any temporary breakpoints we used to implement software single
19611961
// stepping.
19621962
for (const auto &thread_info : m_threads_stepping_with_breakpoint) {
1963-
Status error = RemoveBreakpoint(thread_info.second);
1964-
if (error.Fail())
1965-
LLDB_LOG(log, "pid = {0} remove stepping breakpoint: {1}",
1966-
thread_info.first, error);
1963+
for (auto &&bp_addr : thread_info.second) {
1964+
Status error = RemoveBreakpoint(bp_addr);
1965+
if (error.Fail())
1966+
LLDB_LOG(log, "pid = {0} remove stepping breakpoint: {1}",
1967+
thread_info.first, error);
1968+
}
19671969
}
19681970
m_threads_stepping_with_breakpoint.clear();
19691971

lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ Status NativeProcessSoftwareSingleStep::SetupSoftwareSingleStepping(
138138
error = SetSoftwareBreakpoint(bp_addr, *bp_size, process);
139139
if (error.Fail())
140140
return error;
141-
142-
m_threads_stepping_with_breakpoint.insert({thread.GetID(), bp_addr});
143141
}
142+
143+
m_threads_stepping_with_breakpoint.insert({thread.GetID(), bp_locations});
144144
return error;
145145
}

lldb/source/Plugins/Process/Utility/NativeProcessSoftwareSingleStep.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class NativeProcessSoftwareSingleStep {
2323
protected:
2424
// List of thread ids stepping with a breakpoint with the address of
2525
// the relevan breakpoint
26-
std::multimap<lldb::tid_t, lldb::addr_t> m_threads_stepping_with_breakpoint;
26+
std::map<lldb::tid_t, std::vector<lldb::addr_t>> m_threads_stepping_with_breakpoint;
2727
};
2828

2929
} // namespace lldb_private

lldb/test/API/riscv/step/TestSoftwareStep.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
class TestSoftwareStep(TestBase):
13-
def do_sequence_test(filename, bkpt_name):
13+
def do_sequence_test(self, filename, bkpt_name):
1414
source_file = filename + ".c"
1515
exe_file = filename + ".x"
1616

@@ -30,15 +30,15 @@ def do_sequence_test(filename, bkpt_name):
3030

3131
return pc - entry_pc
3232

33-
@skipIf(archs=no_match(re.compile("rv*")))
33+
@skipIf(archs=no_match("rv*"))
3434
def test_cas(self):
3535
"""
3636
This test verifies LLDB instruction step handling of a proper lr/sc pair.
3737
"""
38-
difference = do_sequence_test("main", "cas")
39-
self.assertTrue(difference > 0x10)
38+
difference = self.do_sequence_test("main", "cas")
39+
self.assertEqual(difference, 0x1a)
4040

41-
@skipIf(archs=no_match(re.compile("rv*")))
41+
@skipIf(archs=no_match("rv*"))
4242
def test_branch_cas(self):
4343
"""
4444
LLDB cannot predict the actual state of registers within a critical section (i.e., inside an atomic
@@ -51,25 +51,25 @@ def test_branch_cas(self):
5151
test is nearly identical to the previous one, except for the branch condition, which is inverted and
5252
will result in a taken jump.
5353
"""
54-
difference = do_sequence_test("branch", "branch_cas")
55-
self.assertTrue(difference > 0x10)
54+
difference = self.do_sequence_test("branch", "branch_cas")
55+
self.assertEqual(difference, 0x1a)
5656

57-
@skipIf(archs=no_match(re.compile("rv*")))
57+
@skipIf(archs=no_match("rv*"))
5858
def test_incomplete_sequence_without_lr(self):
5959
"""
6060
This test verifies the behavior of a standalone sc instruction without a preceding lr. Since the sc
6161
lacks the required lr pairing, LLDB should treat it as a non-atomic store rather than part of an
6262
atomic sequence.
6363
"""
64-
difference = do_sequence_test("incomplete_sequence_without_lr", "incomplete_cas")
65-
self.assertTrue(difference == 0x4)
64+
difference = self.do_sequence_test("incomplete_sequence_without_lr", "incomplete_cas")
65+
self.assertEqual(difference, 0x4)
6666

67-
@skipIf(archs=no_match(re.compile("rv*")))
67+
@skipIf(archs=no_match("rv*"))
6868
def test_incomplete_sequence_without_sc(self):
6969
"""
7070
This test checks the behavior of a standalone lr instruction without a subsequent sc. Since the lr
7171
lacks its required sc counterpart, LLDB should treat it as a non-atomic load rather than part of an
7272
atomic sequence.
7373
"""
74-
difference = do_sequence_test("incomplete_sequence_without_sc", "incomplete_cas")
75-
self.assertTrue(difference == 0x4)
74+
difference = self.do_sequence_test("incomplete_sequence_without_sc", "incomplete_cas")
75+
self.assertEqual(difference, 0x4)

0 commit comments

Comments
 (0)