Skip to content

Commit 6e6baf0

Browse files
committed
add more comments
1 parent 41a410a commit 6e6baf0

File tree

7 files changed

+18
-3
lines changed

7 files changed

+18
-3
lines changed

lldb/include/lldb/Core/EmulateInstruction.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ class SingleStepBreakpointLocationsPredictor {
4646

4747
virtual BreakpointLocations GetBreakpointLocations(Status &status);
4848

49-
virtual llvm::Expected<unsigned> GetBreakpointSize(lldb::addr_t bp_addr) {
49+
virtual llvm::Expected<unsigned>
50+
GetBreakpointSize([[maybe_unused]] lldb::addr_t bp_addr) {
5051
return 4;
5152
}
5253

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,7 +1843,8 @@ RISCVSingleStepBreakpointLocationsPredictor::HandleAtomicSequence(
18431843
// RISC-V ISA there can be at most 16 instructions in the sequence.
18441844

18451845
lldb::addr_t entry_pc = pc; // LR instruction address
1846-
pc += 4; // add LR_W, LR_D instruction size
1846+
auto lr_inst = riscv_emulator->ReadInstructionAt(entry_pc);
1847+
pc += lr_inst->is_rvc ? 2 : 4;
18471848

18481849
size_t atomic_length = 0;
18491850
std::optional<DecodeResult> inst;
@@ -1873,7 +1874,7 @@ RISCVSingleStepBreakpointLocationsPredictor::HandleAtomicSequence(
18731874
"RISCVSingleStepBreakpointLocationsPredictor::%s: can't find "
18741875
"corresponding store conditional insturuction",
18751876
__FUNCTION__);
1876-
return {entry_pc + 4};
1877+
return {entry_pc + lr_inst->is_rvc ? 2u : 4u};
18771878
}
18781879

18791880
lldb::addr_t exit_pc = pc;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""
22
Test software step-inst, also known as instruction level single step, in risc-v atomic sequence.
3+
For more information about atomic sequences, see the RISC-V Unprivileged ISA specification.
34
"""
45

56
import lldb

lldb/test/API/riscv/step/branch.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
void __attribute__((naked)) branch_cas(int *a, int *b) {
2+
// Stop at the first instruction. The atomic sequence contains active forward
3+
// branch (bne a5, a1, 2f). After step instruction lldb should stop at the
4+
// branch's target address (ret instruction).
25
asm volatile("1:\n\t"
36
"lr.w a2, (a0)\n\t"
47
"and a5, a2, a4\n\t"

lldb/test/API/riscv/step/incomplete_sequence_without_lr.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
void __attribute__((naked)) incomplete_cas(int *a, int *b) {
2+
// Stop at the first instruction (an sc without a corresponding lr), then make
3+
// a step instruction and ensure that execution stops at the next instruction
4+
// (and).
25
asm volatile("1:\n\t"
36
"sc.w a5, a1, (a3)\n\t"
47
"and a5, a2, a4\n\t"

lldb/test/API/riscv/step/incomplete_sequence_without_sc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
void __attribute__((naked)) incomplete_cas(int *a, int *b) {
2+
// Stop at the first instruction (an lr without a corresponding sc), then make
3+
// a step instruction and ensure that execution stops at the next instruction
4+
// (and).
25
asm volatile("1:\n\t"
36
"lr.w a2, (a0)\n\t"
47
"and a5, a2, a4\n\t"

lldb/test/API/riscv/step/main.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
void __attribute__((naked)) cas(int *a, int *b) {
2+
// This atomic sequence implements a copy-and-swap function. This test should
3+
// at the first instruction, and after step instruction, we should stop at the
4+
// end of the sequence (on the ret instruction).
25
asm volatile("1:\n\t"
36
"lr.w a2, (a0)\n\t"
47
"and a5, a2, a4\n\t"

0 commit comments

Comments
 (0)