[all-commits] [llvm/llvm-project] 1c95d8: RISCV enable assembly unwinding (#158161)

barsolo2000 via All-commits all-commits at lists.llvm.org
Thu Sep 18 13:41:38 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 1c95d80ba68efd2ca9a0336529ea5fb7dc871417
      https://github.com/llvm/llvm-project/commit/1c95d80ba68efd2ca9a0336529ea5fb7dc871417
  Author: barsolo2000 <barsolo at meta.com>
  Date:   2025-09-18 (Thu, 18 Sep 2025)

  Changed paths:
    M lldb/include/lldb/Core/Opcode.h
    M lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.cpp
    M lldb/source/Plugins/Instruction/RISCV/EmulateInstructionRISCV.h
    M lldb/unittests/Instruction/CMakeLists.txt
    A lldb/unittests/Instruction/RISCV/TestRiscvInstEmulation.cpp

  Log Message:
  -----------
  RISCV enable assembly unwinding (#158161)

**Added emulator unwinding support for RISCV files.**

Emulated Instructions:
ADD (addi sp, sp, imm)
STORE (sd ra, offset(sp))
LOAD (ld ra, offset(sp)).

We had to overwrite SetInstructions() since UnwindAssemblyInstEmulation
calls EvaluateInstruction() directly after calling SetInstruction(), but
it never calls ReadInstruction(). This means that the m_decoded member
variable in the instruction emulator is never properly initialized. By
overriding SetInstruction(), we decode the instruction bytes and set
m_decoded directly. This ensures that subsequent emulation (including
unwinding) operates on the correct instruction.

We also had to change the the OpCode GetOpcodeBytes function since
recent changes made it so GetOpcodeBytes will return None for type
eType16_32Tuples (an alternative and longer way, would've been to type
check during the overwritten SetInstruction() and call a DataExtractor
with .GetU16(&offset) to set the inst_data.

Added a test - TestSimpleRiscvFunction (took inspiration from:
[link](https://github.com/llvm/llvm-project/blob/main/lldb/unittests/UnwindAssembly/ARM64/TestArm64InstEmulation.cpp))

[----------] 1 test from TestRiscvInstEmulation
[ RUN      ] TestRiscvInstEmulation.TestSimpleRiscvFunction
[       OK ] TestRiscvInstEmulation.TestSimpleRiscvFunction (1 ms)
[----------] 1 test from TestRiscvInstEmulation (1 ms total)

[----------] Global test environment tear-down
[==========] 63 tests from 5 test suites ran. (11 ms total)
[  PASSED  ] 63 tests.

---------

Co-authored-by: Bar Soloveychik <barsolo at fb.com>



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list