================ @@ -56,100 +54,204 @@ DisassembleRequestHandler::Run(const DisassembleArguments &args) const { } } + int64_t instructionOffset = args.instructionOffset.value_or(0); + if (instructionOffset > 0) { + lldb::SBInstructionList forward_insts = dap.target.ReadInstructions( + addr, instructionOffset + 1, flavor_string.c_str()); + if (forward_insts.GetSize() != static_cast<size_t>(instructionOffset + 1)) { + return llvm::make_error<DAPError>( + "Failed to disassemble instructions after " + + std::to_string(instructionOffset) + + " instructions from the given address."); + } + + addr = forward_insts.GetInstructionAtIndex(instructionOffset).GetAddress(); + } + + const bool resolve_symbols = args.resolveSymbols.value_or(false); + std::vector<DisassembledInstruction> instructions; + if (instructionOffset < 0) + instructions = disassembleBackwards(addr, std::abs(instructionOffset), + flavor_string.c_str(), resolve_symbols); + + const auto instructions_left = args.instructionCount - instructions.size(); lldb::SBInstructionList insts = dap.target.ReadInstructions( - addr, args.instructionCount, flavor_string.c_str()); + addr, instructions_left, flavor_string.c_str()); if (!insts.IsValid()) return llvm::make_error<DAPError>( "Failed to find instructions for memory address."); - const bool resolve_symbols = args.resolveSymbols.value_or(false); + // add the disassembly from the given address forward ---------------- JDevlieghere wrote:
```suggestion // Add the disassembly starting at the given address. ``` https://github.com/llvm/llvm-project/pull/140486 _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits