[Lldb-commits] [lldb] [lldb-dap] fix disassembly request instruction offset handling (PR #140486)

2025-05-19 Thread Jonas Devlieghere via lldb-commits


@@ -1668,6 +1668,26 @@ SBError SBTarget::SetLabel(const char *label) {
   return Status::FromError(target_sp->SetLabel(label));
 }
 
+uint32_t SBTarget::GetMinimumOpcodeByteSize() const {
+  LLDB_INSTRUMENT_VA(this);
+
+  TargetSP target_sp(GetSP());
+  if (target_sp) {
+return target_sp->GetArchitecture().GetMinimumOpcodeByteSize();
+  }

JDevlieghere wrote:

```suggestion
  if (target_sp)
return target_sp->GetArchitecture().GetMinimumOpcodeByteSize();
```

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


[Lldb-commits] [lldb] [lldb-dap] fix disassembly request instruction offset handling (PR #140486)

2025-05-19 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere commented:

As a general comment, the code is becoming quite complicated and I think it 
would help if we can break things up more. Looking at the protocol arguments we 
have and offset in bytes, an offset in instructions, and then an instruction 
count. If possible please try to mimic that logic in the structure of this 
function:

1. Take the address
2. Apply the byte offset
3. Compute the instruction offset and apply it (the logic to do that is complex 
and therefore this should be factored out into a helper function)
4. Get the number of instructions at the computed offset and create a list of 
SBInstructions to disassemble. You can use a default constructed SBInstruction 
for padding.  
5. Disassemble the list of SBInstructions

Looking at the code, I think that's doable, albeit maybe slightly less 
efficiently? 

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


[Lldb-commits] [lldb] [lldb-dap] fix disassembly request instruction offset handling (PR #140486)

2025-05-19 Thread Jonas Devlieghere via lldb-commits


@@ -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(instructionOffset + 1)) 
{
+  return llvm::make_error(
+  "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 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(
 "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


[Lldb-commits] [lldb] [lldb-dap] fix disassembly request instruction offset handling (PR #140486)

2025-05-19 Thread Jonas Devlieghere via lldb-commits


@@ -56,100 +54,204 @@ DisassembleRequestHandler::Run(const DisassembleArguments 
&args) const {
 }
   }
 
+  int64_t instructionOffset = args.instructionOffset.value_or(0);

JDevlieghere wrote:

Maybe add a comment saying that this is the _number_ of instructions. 
```suggestion
  // Offset (in instructions) to be applied after the byte offset (if any) 
before disassembling. Can be negative.
  int64_t instruction_offset = args.instructionOffset.value_or(0);
```

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


[Lldb-commits] [lldb] [lldb-dap] fix disassembly request instruction offset handling (PR #140486)

2025-05-19 Thread Jonas Devlieghere via lldb-commits


@@ -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(instructionOffset + 1)) 
{
+  return llvm::make_error(
+  "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 instructions;
+  if (instructionOffset < 0)
+instructions = disassembleBackwards(addr, std::abs(instructionOffset),
+flavor_string.c_str(), 
resolve_symbols);

JDevlieghere wrote:

I think it would be more readable if you handled the positive instruction 
offset case in the else case here instead of breaking them up between line 58 
and here.

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


[Lldb-commits] [lldb] [lldb-dap] fix disassembly request instruction offset handling (PR #140486)

2025-05-19 Thread Jonas Devlieghere via lldb-commits


@@ -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(instructionOffset + 1)) 
{
+  return llvm::make_error(
+  "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 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(
 "Failed to find instructions for memory address.");
 
-  const bool resolve_symbols = args.resolveSymbols.value_or(false);
+  // add the disassembly from the given address forward
   const auto num_insts = insts.GetSize();
-  for (size_t i = 0; i < num_insts; ++i) {
+  for (size_t i = 0;
+   i < num_insts && instructions.size() < args.instructionCount; ++i) {
 lldb::SBInstruction inst = insts.GetInstructionAtIndex(i);
-auto addr = inst.GetAddress();
-const auto inst_addr = addr.GetLoadAddress(dap.target);
-const char *m = inst.GetMnemonic(dap.target);
-const char *o = inst.GetOperands(dap.target);
-const char *c = inst.GetComment(dap.target);
-auto d = inst.GetData(dap.target);
-
-std::string bytes;
-llvm::raw_string_ostream sb(bytes);
-for (unsigned i = 0; i < inst.GetByteSize(); i++) {
-  lldb::SBError error;
-  uint8_t b = d.GetUnsignedInt8(error, i);
-  if (error.Success()) {
-sb << llvm::format("%2.2x ", b);
-  }
-}
+instructions.push_back(
+SBInstructionToDisassembledInstruction(inst, resolve_symbols));
+  }
 
-DisassembledInstruction disassembled_inst;
-disassembled_inst.address = inst_addr;
-disassembled_inst.instructionBytes =
-bytes.size() > 0 ? bytes.substr(0, bytes.size() - 1) : "";
-
-std::string instruction;
-llvm::raw_string_ostream si(instruction);
-
-lldb::SBSymbol symbol = addr.GetSymbol();
-// Only add the symbol on the first line of the function.
-if (symbol.IsValid() && symbol.GetStartAddress() == addr) {
-  // If we have a valid symbol, append it as a label prefix for the first
-  // instruction. This is so you can see the start of a function/callsite
-  // in the assembly, at the moment VS Code (1.80) does not visualize the
-  // symbol associated with the assembly instruction.
-  si << (symbol.GetMangledName() != nullptr ? symbol.GetMangledName()
-: symbol.GetName())
- << ": ";
-
-  if (resolve_symbols)
-disassembled_inst.symbol = symbol.GetDisplayName();
-}
+  // Pad the instructions with invalid instructions if needed.
+  if (instructions.size() < args.instructionCount)
+for (size_t i = instructions.size(); i < args.instructionCount; ++i)
+  instructions.push_back(GetInvalidInstruction());
 
-si << llvm::formatv("{0,7} {1,12}", m, o);
-if (c && c[0]) {
-  si << " ; " << c;
-}
+  return DisassembleResponseBody{std::move(instructions)};
+}
+
+std::vector
+DisassembleRequestHandler::disassembleBackwards(
+lldb::SBAddress &addr, const uint32_t instruction_count,
+const char *flavor_string, bool resolve_symbols) const {
+  std::vector instructions;
 
-disassembled_inst.instruction = instruction;
-
-auto line_entry = addr.GetLineEntry();
-// If the line number is 0 then the entry represents a compiler generated
-// location.
-if (line_entry.GetStartAddress() == addr && line_entry.IsValid() &&
-line_entry.GetFileSpec().IsValid() && line_entry.GetLine() != 0) {
-  auto source = CreateSource(line_entry);
-  disassembled_inst.location = std::move(source);
-
-  const auto line = line_entry.GetLine();
-  if (line != 0 && line != LLDB_INVALID_LINE_NUMBER)
-disassembled_inst.line = line;
-
-  const auto column = line_entry.GetColumn();
-  if (column != 0 && column != LLDB_INVALID_COLUMN_NUMBER)
-disassembled_inst.column = column;
-
-  auto end_line_entry = line_entry.GetEndAddress().GetLineEntry();
-  if (end_line_entry.IsValid() &&
-  end_line_entry.GetFil

[Lldb-commits] [lldb] [lldb-dap] fix disassembly request instruction offset handling (PR #140486)

2025-05-19 Thread Jonas Devlieghere via lldb-commits


@@ -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(instructionOffset + 1)) 
{
+  return llvm::make_error(
+  "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 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(
 "Failed to find instructions for memory address.");
 
-  const bool resolve_symbols = args.resolveSymbols.value_or(false);
+  // add the disassembly from the given address forward
   const auto num_insts = insts.GetSize();
-  for (size_t i = 0; i < num_insts; ++i) {
+  for (size_t i = 0;
+   i < num_insts && instructions.size() < args.instructionCount; ++i) {
 lldb::SBInstruction inst = insts.GetInstructionAtIndex(i);
-auto addr = inst.GetAddress();
-const auto inst_addr = addr.GetLoadAddress(dap.target);
-const char *m = inst.GetMnemonic(dap.target);
-const char *o = inst.GetOperands(dap.target);
-const char *c = inst.GetComment(dap.target);
-auto d = inst.GetData(dap.target);
-
-std::string bytes;
-llvm::raw_string_ostream sb(bytes);
-for (unsigned i = 0; i < inst.GetByteSize(); i++) {
-  lldb::SBError error;
-  uint8_t b = d.GetUnsignedInt8(error, i);
-  if (error.Success()) {
-sb << llvm::format("%2.2x ", b);
-  }
-}
+instructions.push_back(
+SBInstructionToDisassembledInstruction(inst, resolve_symbols));
+  }
 
-DisassembledInstruction disassembled_inst;
-disassembled_inst.address = inst_addr;
-disassembled_inst.instructionBytes =
-bytes.size() > 0 ? bytes.substr(0, bytes.size() - 1) : "";
-
-std::string instruction;
-llvm::raw_string_ostream si(instruction);
-
-lldb::SBSymbol symbol = addr.GetSymbol();
-// Only add the symbol on the first line of the function.
-if (symbol.IsValid() && symbol.GetStartAddress() == addr) {
-  // If we have a valid symbol, append it as a label prefix for the first
-  // instruction. This is so you can see the start of a function/callsite
-  // in the assembly, at the moment VS Code (1.80) does not visualize the
-  // symbol associated with the assembly instruction.
-  si << (symbol.GetMangledName() != nullptr ? symbol.GetMangledName()
-: symbol.GetName())
- << ": ";
-
-  if (resolve_symbols)
-disassembled_inst.symbol = symbol.GetDisplayName();
-}
+  // Pad the instructions with invalid instructions if needed.
+  if (instructions.size() < args.instructionCount)
+for (size_t i = instructions.size(); i < args.instructionCount; ++i)
+  instructions.push_back(GetInvalidInstruction());
 
-si << llvm::formatv("{0,7} {1,12}", m, o);
-if (c && c[0]) {
-  si << " ; " << c;
-}
+  return DisassembleResponseBody{std::move(instructions)};
+}
+
+std::vector
+DisassembleRequestHandler::disassembleBackwards(
+lldb::SBAddress &addr, const uint32_t instruction_count,
+const char *flavor_string, bool resolve_symbols) const {
+  std::vector instructions;
 
-disassembled_inst.instruction = instruction;
-
-auto line_entry = addr.GetLineEntry();
-// If the line number is 0 then the entry represents a compiler generated
-// location.
-if (line_entry.GetStartAddress() == addr && line_entry.IsValid() &&
-line_entry.GetFileSpec().IsValid() && line_entry.GetLine() != 0) {
-  auto source = CreateSource(line_entry);
-  disassembled_inst.location = std::move(source);
-
-  const auto line = line_entry.GetLine();
-  if (line != 0 && line != LLDB_INVALID_LINE_NUMBER)
-disassembled_inst.line = line;
-
-  const auto column = line_entry.GetColumn();
-  if (column != 0 && column != LLDB_INVALID_COLUMN_NUMBER)
-disassembled_inst.column = column;
-
-  auto end_line_entry = line_entry.GetEndAddress().GetLineEntry();
-  if (end_line_entry.IsValid() &&
-  end_line_entry.GetFil

[Lldb-commits] [lldb] [lldb-dap] fix disassembly request instruction offset handling (PR #140486)

2025-05-19 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere edited 
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


[Lldb-commits] [lldb] [lldb-dap] Add ContinueRequestHandler unit test (PR #140566)

2025-05-19 Thread Pavel Labath via lldb-commits

labath wrote:

gmock doesn't let you do anything that wouldn't be possible without it. For 
this to work, the code which interacts with the mock needs to be ready to 
accept something other than the real object somehow. That usually means 
making the mocked object polymorphic, but that is a nonstarter here due to the 
interface stability. Other options I see are:
- write a wrapper around SBProcess and then mock that
- make everything a template so that it can be instantiated with a different 
(mock) implementation
- use the fact that liblldb is a (shared) library to write an "alternative 
implementation" of that library

Each of those options comes with a fairly high cost (both upfront and in 
ongoing maintenance)...

https://github.com/llvm/llvm-project/pull/140566
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Retcon SBValue::GetChildAtIndex(synthetic=true) (PR #140065)

2025-05-19 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `fuchsia-x86_64-linux` 
running on `fuchsia-debian-64-us-central1-b-1` while building `lldb` at step 4 
"annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/11/builds/15495


Here is the relevant piece of the build log for the reference

```
Step 4 (annotate) failure: 'python 
../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
  Passed   : 46015 (97.92%)
  Expectedly Failed:27 (0.06%)
[1368/1370] Linking CXX executable 
unittests/tools/llvm-exegesis/LLVMExegesisTests
[1369/1370] Running the LLVM regression tests
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/bin/ld.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using lld-link: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/bin/lld-link
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using ld64.lld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/bin/ld64.lld
llvm-lit: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/utils/lit/lit/llvm/config.py:520:
 note: using wasm-ld: 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/bin/wasm-ld
-- Testing: 59210 tests, 60 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80..
FAIL: LLVM :: tools/dsymutil/X86/op-convert-offset.test (52242 of 59210)
 TEST 'LLVM :: tools/dsymutil/X86/op-convert-offset.test' 
FAILED 
Exit Code: 1

Command Output (stdout):
--
warning: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o:
 timestamp mismatch between object file (2025-05-19 17:22:56.276800899) and 
debug map (2022-07-12 20:49:30.0)
warning: 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o:
 timestamp mismatch between object file (2025-05-19 17:22:56.276800899) and 
debug map (2022-07-12 20:49:30.0)
warning: cann't read address attribute value.
note: while processing op-convert-offset1.c

--
Command Output (stderr):
--
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/bin/dsymutil 
-oso-prepend-path 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs
 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset
 -o 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
 2>&1 # RUN: at line 23
+ /var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/bin/dsymutil 
-oso-prepend-path 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs
 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset
 -o 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/bin/llvm-dwarfdump
 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o
 2>&1 | 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/bin/FileCheck 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test
 --check-prefix OBJ # RUN: at line 24
+ 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/bin/FileCheck 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test
 --check-prefix OBJ
+ 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/bin/llvm-dwarfdump
 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/../Inputs/private/tmp/op-convert-offset/op-convert-offset.o
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/bin/llvm-dwarfdump
 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/test/tools/dsymutil/X86/Output/op-convert-offset.test.tmp.dSYM
 2>&1 | 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/bin/FileCheck 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test
 --check-prefix DSYM # RUN: at line 25
+ 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-kfym3l0t/bin/FileCheck 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/llvm/test/tools/dsymutil/X86/op-convert-offset.test
 --check-prefix DSYM
+ 
/var/lib/buildbot/fuchsia-x86_64-linux/buil

[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Ely Ronnen via lldb-commits


@@ -627,6 +627,60 @@ struct InstructionBreakpoint {
 bool fromJSON(const llvm::json::Value &, InstructionBreakpoint &,
   llvm::json::Path);
 
+/// Properties of a single disassembled instruction, returned by `disassemble`
+/// request.
+struct DisassembledInstruction {
+  enum PresentationHint : unsigned {
+eSourcePresentationHintNormal,
+eSourcePresentationHintInvalid,
+  };
+
+  /// The address of the instruction. Treated as a hex value if prefixed with
+  /// `0x`, or as a decimal value otherwise.
+  std::string address;

eronnen wrote:

:100: 

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen deleted 
https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] Extend information for failed connection for gdb server (PR #139916)

2025-05-19 Thread via lldb-commits

ita-sc wrote:

Thanks for review.
Could you please merge this? (I do not have write access yet)

https://github.com/llvm/llvm-project/pull/139916
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen updated 
https://github.com/llvm/llvm-project/pull/140482

>From 1014235896b79eb4ea05a6822714a66adaa691ac Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 18 May 2025 23:51:58 +0200
Subject: [PATCH 1/2] [lldb-dap] Migrate disassemble request to structured
 handler

---
 .../Handler/DisassembleRequestHandler.cpp | 183 +-
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   9 +-
 .../lldb-dap/Protocol/ProtocolRequests.cpp|  18 ++
 .../lldb-dap/Protocol/ProtocolRequests.h  |  35 
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  34 
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  54 ++
 6 files changed, 193 insertions(+), 140 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index d738f54ff1a9f..938078947259b 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -9,113 +9,34 @@
 #include "DAP.h"
 #include "EventHelper.h"
 #include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
+#include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBInstruction.h"
 #include "llvm/ADT/StringExtras.h"
 
+using namespace lldb_dap::protocol;
+
 namespace lldb_dap {
 
-// "DisassembleRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Disassembles code stored at the provided
-// location.\nClients should only call this request if the corresponding
-// capability `supportsDisassembleRequest` is true.", "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "disassemble" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/DisassembleArguments"
-//   }
-// },
-// "required": [ "command", "arguments" ]
-//   }]
-// },
-// "DisassembleArguments": {
-//   "type": "object",
-//   "description": "Arguments for `disassemble` request.",
-//   "properties": {
-// "memoryReference": {
-//   "type": "string",
-//   "description": "Memory reference to the base location containing the
-//   instructions to disassemble."
-// },
-// "offset": {
-//   "type": "integer",
-//   "description": "Offset (in bytes) to be applied to the reference
-//   location before disassembling. Can be negative."
-// },
-// "instructionOffset": {
-//   "type": "integer",
-//   "description": "Offset (in instructions) to be applied after the byte
-//   offset (if any) before disassembling. Can be negative."
-// },
-// "instructionCount": {
-//   "type": "integer",
-//   "description": "Number of instructions to disassemble starting at the
-//   specified location and offset.\nAn adapter must return exactly this
-//   number of instructions - any unavailable instructions should be
-//   replaced with an implementation-defined 'invalid instruction' value."
-// },
-// "resolveSymbols": {
-//   "type": "boolean",
-//   "description": "If true, the adapter should attempt to resolve memory
-//   addresses and other values to symbolic names."
-// }
-//   },
-//   "required": [ "memoryReference", "instructionCount" ]
-// },
-// "DisassembleResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to `disassemble` request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "instructions": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/DisassembledInstruction"
-// },
-// "description": "The list of disassembled instructions."
-//   }
-// },
-// "required": [ "instructions" ]
-//   }
-// }
-//   }]
-// }
-void DisassembleRequestHandler::operator()(
-const llvm::json::Object &request) const {
-  llvm::json::Object response;
-  FillResponse(request, response);
-  auto *arguments = request.getObject("arguments");
-
-  llvm::StringRef memoryReference =
-  GetString(arguments, "memoryReference").value_or("");
-  auto addr_opt = DecodeMemoryReference(memoryReference);
-  if (!addr_opt.has_value()) {
-response["success"] = false;
-response["message"] =
-"Malformed memory reference: " + memoryReference.str();
-dap.SendJSON(llvm::json::Value(std::move(response)));
-return;
-  }
-  lldb::addr_t addr_ptr = *addr_opt;
+/// Disassembles code stored at the provided location.
+/// Clients should only call this request if the corresponding capability
+/// `supportsDisassembleRequest` is true.
+llvm::Expected
+DisassembleRequestHandler::Run(const DisassembleArguments &args) const {
+  std::vector instructions;
 
-  addr_ptr += GetInteger(arguments, "instructionOffset").value_or(0);
-  l

[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen updated 
https://github.com/llvm/llvm-project/pull/140482

>From 1014235896b79eb4ea05a6822714a66adaa691ac Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 18 May 2025 23:51:58 +0200
Subject: [PATCH 1/3] [lldb-dap] Migrate disassemble request to structured
 handler

---
 .../Handler/DisassembleRequestHandler.cpp | 183 +-
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   9 +-
 .../lldb-dap/Protocol/ProtocolRequests.cpp|  18 ++
 .../lldb-dap/Protocol/ProtocolRequests.h  |  35 
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  34 
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  54 ++
 6 files changed, 193 insertions(+), 140 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index d738f54ff1a9f..938078947259b 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -9,113 +9,34 @@
 #include "DAP.h"
 #include "EventHelper.h"
 #include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
+#include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBInstruction.h"
 #include "llvm/ADT/StringExtras.h"
 
+using namespace lldb_dap::protocol;
+
 namespace lldb_dap {
 
-// "DisassembleRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Disassembles code stored at the provided
-// location.\nClients should only call this request if the corresponding
-// capability `supportsDisassembleRequest` is true.", "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "disassemble" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/DisassembleArguments"
-//   }
-// },
-// "required": [ "command", "arguments" ]
-//   }]
-// },
-// "DisassembleArguments": {
-//   "type": "object",
-//   "description": "Arguments for `disassemble` request.",
-//   "properties": {
-// "memoryReference": {
-//   "type": "string",
-//   "description": "Memory reference to the base location containing the
-//   instructions to disassemble."
-// },
-// "offset": {
-//   "type": "integer",
-//   "description": "Offset (in bytes) to be applied to the reference
-//   location before disassembling. Can be negative."
-// },
-// "instructionOffset": {
-//   "type": "integer",
-//   "description": "Offset (in instructions) to be applied after the byte
-//   offset (if any) before disassembling. Can be negative."
-// },
-// "instructionCount": {
-//   "type": "integer",
-//   "description": "Number of instructions to disassemble starting at the
-//   specified location and offset.\nAn adapter must return exactly this
-//   number of instructions - any unavailable instructions should be
-//   replaced with an implementation-defined 'invalid instruction' value."
-// },
-// "resolveSymbols": {
-//   "type": "boolean",
-//   "description": "If true, the adapter should attempt to resolve memory
-//   addresses and other values to symbolic names."
-// }
-//   },
-//   "required": [ "memoryReference", "instructionCount" ]
-// },
-// "DisassembleResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to `disassemble` request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "instructions": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/DisassembledInstruction"
-// },
-// "description": "The list of disassembled instructions."
-//   }
-// },
-// "required": [ "instructions" ]
-//   }
-// }
-//   }]
-// }
-void DisassembleRequestHandler::operator()(
-const llvm::json::Object &request) const {
-  llvm::json::Object response;
-  FillResponse(request, response);
-  auto *arguments = request.getObject("arguments");
-
-  llvm::StringRef memoryReference =
-  GetString(arguments, "memoryReference").value_or("");
-  auto addr_opt = DecodeMemoryReference(memoryReference);
-  if (!addr_opt.has_value()) {
-response["success"] = false;
-response["message"] =
-"Malformed memory reference: " + memoryReference.str();
-dap.SendJSON(llvm::json::Value(std::move(response)));
-return;
-  }
-  lldb::addr_t addr_ptr = *addr_opt;
+/// Disassembles code stored at the provided location.
+/// Clients should only call this request if the corresponding capability
+/// `supportsDisassembleRequest` is true.
+llvm::Expected
+DisassembleRequestHandler::Run(const DisassembleArguments &args) const {
+  std::vector instructions;
 
-  addr_ptr += GetInteger(arguments, "instructionOffset").value_or(0);
-  l

[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Ely Ronnen via lldb-commits


@@ -627,6 +627,60 @@ struct InstructionBreakpoint {
 bool fromJSON(const llvm::json::Value &, InstructionBreakpoint &,
   llvm::json::Path);
 
+/// Properties of a single disassembled instruction, returned by `disassemble`
+/// request.
+struct DisassembledInstruction {
+  enum PresentationHint : unsigned {
+eSourcePresentationHintNormal,
+eSourcePresentationHintInvalid,
+  };
+
+  /// The address of the instruction. Treated as a hex value if prefixed with
+  /// `0x`, or as a decimal value otherwise.
+  std::string address;

eronnen wrote:

:100: 

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Synchronously wait for breakpoints resolves in tests (PR #140470)

2025-05-19 Thread Ely Ronnen via lldb-commits


@@ -78,8 +84,40 @@ def set_function_breakpoints(self, functions, 
condition=None, hitCondition=None)
 breakpoint_ids = []
 for breakpoint in breakpoints:
 breakpoint_ids.append("%i" % (breakpoint["id"]))
+if wait_for_resolve:
+self.wait_for_breakpoints_to_resolve(breakpoint_ids, timeout=10)
 return breakpoint_ids
 
+def wait_for_breakpoints_to_resolve(

eronnen wrote:

:100: 

https://github.com/llvm/llvm-project/pull/140470
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Use llvm::is_contained (NFC) (PR #140466)

2025-05-19 Thread Matt Arsenault via lldb-commits

https://github.com/arsenm approved this pull request.


https://github.com/llvm/llvm-project/pull/140466
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Ely Ronnen via lldb-commits


@@ -782,4 +785,89 @@ bool fromJSON(const llvm::json::Value &Params, 
InstructionBreakpoint &IB,
  O.mapOptional("mode", IB.mode);
 }
 
+bool fromJSON(const llvm::json::Value &Params,
+  DisassembledInstruction::PresentationHint &PH,
+  llvm::json::Path P) {
+  auto rawHint = Params.getAsString();
+  if (!rawHint) {
+P.report("expected a string");
+return false;
+  }
+  std::optional hint =
+  StringSwitch>(
+  *rawHint)
+  .Case("normal", DisassembledInstruction::
+  eDisassembledInstructionPresentationHintNormal)
+  .Case("invalid", DisassembledInstruction::
+   eDisassembledInstructionPresentationHintInvalid)
+  .Default(std::nullopt);
+  if (!hint) {
+P.report("unexpected value");
+return false;
+  }
+  PH = *hint;
+  return true;
+}
+
+llvm::json::Value toJSON(const DisassembledInstruction::PresentationHint &PH) {
+  switch (PH) {
+  case DisassembledInstruction::eDisassembledInstructionPresentationHintNormal:
+return "normal";
+  case 
DisassembledInstruction::eDisassembledInstructionPresentationHintInvalid:
+return "invalid";
+  }
+  llvm_unreachable("unhandled presentation hint.");
+}
+
+bool fromJSON(const llvm::json::Value &Params, DisassembledInstruction &DI,
+  llvm::json::Path P) {
+  std::optional raw_address =

eronnen wrote:

Maybe it's better to implement `fromJSON` and `toJSON` for `addr_t`, although 
then it means it will be converted to a hex string for all other `addr_t` 
usages too

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Change the launch sequence (PR #138219)

2025-05-19 Thread Pavel Labath via lldb-commits

labath wrote:

I think I've found a(nother) problem with this change. One of the arguments of 
the launch request is `sourceMap`, which sets the `target.source-map` setting. 
The setting is necessary to correctly resolve file+line breakpoints in case the 
file's path on the host system does not match the path from the debug info. By 
deferring the processing of this request, we're effectively ignoring this 
setting as all of the initial breakpoint requests (which are not deferred) will 
not see the intended value. This is kind of a Big Deal(tm) for us since all of 
our binaries are built in the cloud.

I see this has been kind of reverted in #140331. I suspect that fixes this use 
case (checking that is my next step), but I'm writing this to let you know of 
the problem.

https://github.com/llvm/llvm-project/pull/138219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Use llvm::is_contained (NFC) (PR #140466)

2025-05-19 Thread Kazu Hirata via lldb-commits

https://github.com/kazutakahirata closed 
https://github.com/llvm/llvm-project/pull/140466
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 25da043 - [lldb] Use llvm::is_contained (NFC) (#140466)

2025-05-19 Thread via lldb-commits

Author: Kazu Hirata
Date: 2025-05-19T06:18:37-07:00
New Revision: 25da043c55e25d066a5aa8af6ca14cf82a845eb2

URL: 
https://github.com/llvm/llvm-project/commit/25da043c55e25d066a5aa8af6ca14cf82a845eb2
DIFF: 
https://github.com/llvm/llvm-project/commit/25da043c55e25d066a5aa8af6ca14cf82a845eb2.diff

LOG: [lldb] Use llvm::is_contained (NFC) (#140466)

Added: 


Modified: 
lldb/source/Expression/FunctionCaller.cpp

Removed: 




diff  --git a/lldb/source/Expression/FunctionCaller.cpp 
b/lldb/source/Expression/FunctionCaller.cpp
index ddf1e1151bdcf..83cac130ba728 100644
--- a/lldb/source/Expression/FunctionCaller.cpp
+++ b/lldb/source/Expression/FunctionCaller.cpp
@@ -171,10 +171,8 @@ bool FunctionCaller::WriteFunctionArguments(
 m_wrapper_args_addrs.push_back(args_addr_ref);
   } else {
 // Make sure this is an address that we've already handed out.
-if (find(m_wrapper_args_addrs.begin(), m_wrapper_args_addrs.end(),
- args_addr_ref) == m_wrapper_args_addrs.end()) {
+if (!llvm::is_contained(m_wrapper_args_addrs, args_addr_ref))
   return false;
-}
   }
 
   // TODO: verify fun_addr needs to be a callable address



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][SymbolFileDWARF] Don't search for DWP files on macOS (PR #139554)

2025-05-19 Thread Michael Buch via lldb-commits


@@ -4211,6 +4211,9 @@ SymbolFileDWARFDebugMap 
*SymbolFileDWARF::GetDebugMapSymfile() {
 
 const std::shared_ptr &SymbolFileDWARF::GetDwpSymbolFile() 
{
   llvm::call_once(m_dwp_symfile_once_flag, [this]() {
+if (m_objfile_sp->GetArchitecture().GetTriple().isAppleMachO())

Michael137 wrote:

Not sure what the resolution was re. the plugin dependencies discussion. Are we 
find with the current approach?

> you can't really say that SymbolFileDWARF requires ObjectFileMachO (or any 
> other) because one can imagine a setup where someone knows they will only 
> ever need to debug DWARF+ELF and so they want to strip out all of the other 
> object file plugins.

Could question. If we don't want to restrict a use-case such as the one you 
describe, I'm happy to add a `SupportsDWP` API to ObjectFile

https://github.com/llvm/llvm-project/pull/139554
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][SymbolFileDWARF] Don't search for DWP files on macOS (PR #139554)

2025-05-19 Thread Michael Buch via lldb-commits

https://github.com/Michael137 edited 
https://github.com/llvm/llvm-project/pull/139554
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Synchronously wait for breakpoints resolves in tests (PR #140470)

2025-05-19 Thread Ely Ronnen via lldb-commits


@@ -1187,15 +1187,17 @@ def request_locations(self, locationReference):
 }
 return self.send_recv(command_dict)
 
-def request_testGetTargetBreakpoints(self):
+def request_testGetTargetBreakpoints(self, only_resolved=False):

eronnen wrote:

Good idea to move this to `DebugCommunication` but I think we still need to 
have this request because the breakpoints that resolve immediately don't 
generate the `breakpoint` async event

https://github.com/llvm/llvm-project/pull/140470
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][DataFormatters] Adjust retrieval of unordered_map element type (PR #140256)

2025-05-19 Thread Pavel Labath via lldb-commits

https://github.com/labath edited 
https://github.com/llvm/llvm-project/pull/140256
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Change the launch sequence (PR #138219)

2025-05-19 Thread Pavel Labath via lldb-commits

labath wrote:

FWIW, https://github.com/llvm/llvm-project/pull/140331 fixes this. I was 
looking at the test coverage, and it seems that the only test making use of 
this is TestDAP_setBreakpoints.py. It superficially looks like it should catch 
this, but after trying it out, it seems that it does not -- even if it was not 
disabled. I'm going to look at beefing it up.

In the mean time, would you say that the recent changes are sufficient to 
resolve the issues which caused the test to be disabled? 

https://github.com/llvm/llvm-project/pull/138219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

2025-05-19 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/139002

>From 5746e997eea55c05cbbb63ad6f78ca225c9ac855 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Wed, 7 May 2025 21:37:31 -0400
Subject: [PATCH 01/11] [lldb]Make `list` command work with  headers when
 possible.

---
 lldb/source/Commands/CommandObjectSource.cpp | 36 +++-
 lldb/source/Core/ModuleList.cpp  |  2 +
 lldb/test/Shell/Commands/list-header.test| 59 
 3 files changed, 94 insertions(+), 3 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/list-header.test

diff --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index c205813565d52..475317021255c 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -1104,6 +1104,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   bool check_inlines = false;
   SymbolContextList sc_list;
   size_t num_matches = 0;
+  uint32_t start_line = m_options.start_line;
 
   if (!m_options.modules.empty()) {
 ModuleList matching_modules;
@@ -1114,7 +1115,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 matching_modules.Clear();
 target.GetImages().FindModules(module_spec, matching_modules);
 num_matches += matching_modules.ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+filename, start_line, check_inlines,
 SymbolContextItem(eSymbolContextModule |
   eSymbolContextCompUnit),
 sc_list);
@@ -1122,7 +1123,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 }
   } else {
 num_matches = target.GetImages().ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+filename, start_line, check_inlines,
 eSymbolContextModule | eSymbolContextCompUnit, sc_list);
   }
 
@@ -1170,8 +1171,37 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   if (m_options.num_lines == 0)
 m_options.num_lines = 10;
   const uint32_t column = 0;
+
+  // Headers aren't always in the DWARF but if they have
+  // executable code (eg., inlined-functions) then the callsite's 
file(s)
+  // will be found.
+  // So if a header was requested and we got a primary file, then look
+  // thru its support file(s) for the header.
+  lldb::SupportFileSP actual_file_sp =
+  sc.comp_unit->GetPrimarySupportFile();
+  if (llvm::StringRef(m_options.file_name).ends_with(".h")) {
+int support_matches_count = 0;
+for (auto &file : sc.comp_unit->GetSupportFiles()) {
+  if 
(llvm::StringRef(file->GetSpecOnly().GetPath()).ends_with(filename)) {
+actual_file_sp = file;
+++support_matches_count;
+  }
+}
+if (support_matches_count == 0) {
+  result.AppendErrorWithFormat(
+  "No file found for requested header: \"%s.\"\n",
+  m_options.file_name.c_str());
+  return;
+} else if (support_matches_count > 1) {
+  result.AppendErrorWithFormat(
+  "Multiple files found for requested header: \"%s.\"\n",
+  m_options.file_name.c_str());
+  return;
+}
+  }
+
   target.GetSourceManager().DisplaySourceLinesWithLineNumbers(
-  sc.comp_unit->GetPrimarySupportFile(),
+  actual_file_sp,
   m_options.start_line, column, 0, m_options.num_lines, "",
   &result.GetOutputStream(), GetBreakpointLocations());
 
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index d5ddf6e846112..90c6a62727734 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -714,6 +714,8 @@ uint32_t ModuleList::ResolveSymbolContextsForFileSpec(
 const FileSpec &file_spec, uint32_t line, bool check_inlines,
 SymbolContextItem resolve_scope, SymbolContextList &sc_list) const {
   std::lock_guard guard(m_modules_mutex);
+  // If we're looking for a header (not source), then need to check inline.
+  check_inlines = check_inlines || !file_spec.IsSourceImplementationFile();
   for (const ModuleSP &module_sp : m_modules) {
 module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
 resolve_scope, sc_list);
diff --git a/lldb/test/Shell/Commands/list-header.test 
b/lldb/test/Shell/Commands/list-header.test
new file mode 100644
index 0..ca700cd2b2fb1
--- /dev/null
+++ b/lldb/test/Shell/Commands/list-header.test
@@ -0,0 +1,59 @@
+## Test that `list header.h:` works correctly when header is available.
+## 
+# REQUI

[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

2025-05-19 Thread Vy Nguyen via lldb-commits


@@ -1113,17 +1123,25 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 ModuleSpec module_spec(module_file_spec);
 matching_modules.Clear();
 target.GetImages().FindModules(module_spec, matching_modules);
-num_matches += matching_modules.ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+FileSpec file_spec(filename);
+re_compute_check_inlines(file_spec);

oontvoo wrote:

done! clean up the code

https://github.com/llvm/llvm-project/pull/139002
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

2025-05-19 Thread Pavel Labath via lldb-commits

https://github.com/labath approved this pull request.


https://github.com/llvm/llvm-project/pull/139002
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

2025-05-19 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo updated 
https://github.com/llvm/llvm-project/pull/139002

>From 5746e997eea55c05cbbb63ad6f78ca225c9ac855 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Wed, 7 May 2025 21:37:31 -0400
Subject: [PATCH 01/11] [lldb]Make `list` command work with  headers when
 possible.

---
 lldb/source/Commands/CommandObjectSource.cpp | 36 +++-
 lldb/source/Core/ModuleList.cpp  |  2 +
 lldb/test/Shell/Commands/list-header.test| 59 
 3 files changed, 94 insertions(+), 3 deletions(-)
 create mode 100644 lldb/test/Shell/Commands/list-header.test

diff --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index c205813565d52..475317021255c 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -1104,6 +1104,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   bool check_inlines = false;
   SymbolContextList sc_list;
   size_t num_matches = 0;
+  uint32_t start_line = m_options.start_line;
 
   if (!m_options.modules.empty()) {
 ModuleList matching_modules;
@@ -1114,7 +1115,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 matching_modules.Clear();
 target.GetImages().FindModules(module_spec, matching_modules);
 num_matches += matching_modules.ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+filename, start_line, check_inlines,
 SymbolContextItem(eSymbolContextModule |
   eSymbolContextCompUnit),
 sc_list);
@@ -1122,7 +1123,7 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 }
   } else {
 num_matches = target.GetImages().ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+filename, start_line, check_inlines,
 eSymbolContextModule | eSymbolContextCompUnit, sc_list);
   }
 
@@ -1170,8 +1171,37 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   if (m_options.num_lines == 0)
 m_options.num_lines = 10;
   const uint32_t column = 0;
+
+  // Headers aren't always in the DWARF but if they have
+  // executable code (eg., inlined-functions) then the callsite's 
file(s)
+  // will be found.
+  // So if a header was requested and we got a primary file, then look
+  // thru its support file(s) for the header.
+  lldb::SupportFileSP actual_file_sp =
+  sc.comp_unit->GetPrimarySupportFile();
+  if (llvm::StringRef(m_options.file_name).ends_with(".h")) {
+int support_matches_count = 0;
+for (auto &file : sc.comp_unit->GetSupportFiles()) {
+  if 
(llvm::StringRef(file->GetSpecOnly().GetPath()).ends_with(filename)) {
+actual_file_sp = file;
+++support_matches_count;
+  }
+}
+if (support_matches_count == 0) {
+  result.AppendErrorWithFormat(
+  "No file found for requested header: \"%s.\"\n",
+  m_options.file_name.c_str());
+  return;
+} else if (support_matches_count > 1) {
+  result.AppendErrorWithFormat(
+  "Multiple files found for requested header: \"%s.\"\n",
+  m_options.file_name.c_str());
+  return;
+}
+  }
+
   target.GetSourceManager().DisplaySourceLinesWithLineNumbers(
-  sc.comp_unit->GetPrimarySupportFile(),
+  actual_file_sp,
   m_options.start_line, column, 0, m_options.num_lines, "",
   &result.GetOutputStream(), GetBreakpointLocations());
 
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index d5ddf6e846112..90c6a62727734 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -714,6 +714,8 @@ uint32_t ModuleList::ResolveSymbolContextsForFileSpec(
 const FileSpec &file_spec, uint32_t line, bool check_inlines,
 SymbolContextItem resolve_scope, SymbolContextList &sc_list) const {
   std::lock_guard guard(m_modules_mutex);
+  // If we're looking for a header (not source), then need to check inline.
+  check_inlines = check_inlines || !file_spec.IsSourceImplementationFile();
   for (const ModuleSP &module_sp : m_modules) {
 module_sp->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines,
 resolve_scope, sc_list);
diff --git a/lldb/test/Shell/Commands/list-header.test 
b/lldb/test/Shell/Commands/list-header.test
new file mode 100644
index 0..ca700cd2b2fb1
--- /dev/null
+++ b/lldb/test/Shell/Commands/list-header.test
@@ -0,0 +1,59 @@
+## Test that `list header.h:` works correctly when header is available.
+## 
+# REQUI

[Lldb-commits] [lldb] dc25ab3 - [lldb]Make `list` command work with headers when possible. (#139002)

2025-05-19 Thread via lldb-commits

Author: Vy Nguyen
Date: 2025-05-19T11:04:01-04:00
New Revision: dc25ab389c2d441ba378d4db56a4a61e3eedb889

URL: 
https://github.com/llvm/llvm-project/commit/dc25ab389c2d441ba378d4db56a4a61e3eedb889
DIFF: 
https://github.com/llvm/llvm-project/commit/dc25ab389c2d441ba378d4db56a4a61e3eedb889.diff

LOG: [lldb]Make `list` command work with  headers when possible. (#139002)

Given this simple test case:

```
// foo.h
extern int* ptr;
inline void g(int x) {
  *ptr = x; // should raise a SIGILL
}
//--
// foo.cc
#include "foo.h"
int* ptr;

//--
// main.cc

#include "foo.h"

int main() {
  g(123); // Call the inlined function and crash
  return 0;
}

$ clang -g main.cc foo.cc -o main.out
$ lldb main.out
```

When you run `main.out` under lldb, it'd stop inside `void g(int)`
because of the crash.
The stack trace would show that it had crashed in `foo.h`, but if you do
`list foo.h:2`, lldb would complain that it could not find the source
file, which is confusing.

This patch make `list` work with headers.

Added: 
lldb/test/Shell/Commands/list-header.test

Modified: 
lldb/source/Commands/CommandObjectSource.cpp

Removed: 




diff  --git a/lldb/source/Commands/CommandObjectSource.cpp 
b/lldb/source/Commands/CommandObjectSource.cpp
index 8c87af590a372..7e7d3f065b622 100644
--- a/lldb/source/Commands/CommandObjectSource.cpp
+++ b/lldb/source/Commands/CommandObjectSource.cpp
@@ -1108,9 +1108,15 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 }
   }
 } else {
-  const char *filename = m_options.file_name.c_str();
-
+  //  const char *filename = m_options.file_name.c_str();
+  FileSpec file_spec(m_options.file_name);
   bool check_inlines = false;
+  const InlineStrategy inline_strategy = target.GetInlineStrategy();
+  if (inline_strategy == eInlineBreakpointsAlways ||
+  (inline_strategy == eInlineBreakpointsHeaders &&
+   !file_spec.IsSourceImplementationFile()))
+check_inlines = true;
+
   SymbolContextList sc_list;
   size_t num_matches = 0;
 
@@ -1122,17 +1128,20 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
 ModuleSpec module_spec(module_file_spec);
 matching_modules.Clear();
 target.GetImages().FindModules(module_spec, matching_modules);
-num_matches += matching_modules.ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
+num_matches += matching_modules.ResolveSymbolContextsForFileSpec(
+file_spec, 1, check_inlines,
 SymbolContextItem(eSymbolContextModule |
-  eSymbolContextCompUnit),
+  eSymbolContextCompUnit |
+  eSymbolContextLineEntry),
 sc_list);
   }
 }
   } else {
-num_matches = target.GetImages().ResolveSymbolContextForFilePath(
-filename, 0, check_inlines,
-eSymbolContextModule | eSymbolContextCompUnit, sc_list);
+num_matches = target.GetImages().ResolveSymbolContextsForFileSpec(
+file_spec, 1, check_inlines,
+eSymbolContextModule | eSymbolContextCompUnit |
+eSymbolContextLineEntry,
+sc_list);
   }
 
   if (num_matches == 0) {
@@ -1179,10 +1188,18 @@ class CommandObjectSourceList : public 
CommandObjectParsed {
   if (m_options.num_lines == 0)
 m_options.num_lines = 10;
   const uint32_t column = 0;
+
+  // Headers aren't always in the DWARF but if they have
+  // executable code (eg., inlined-functions) then the callsite's
+  // file(s) will be found and assigned to
+  // sc.comp_unit->GetPrimarySupportFile, which is NOT what we want to
+  // print. Instead, we want to print the one from the line entry.
+  lldb::SupportFileSP found_file_sp = sc.line_entry.file_sp;
+
   target.GetSourceManager().DisplaySourceLinesWithLineNumbers(
-  sc.comp_unit->GetPrimarySupportFile(),
-  m_options.start_line, column, 0, m_options.num_lines, "",
-  &result.GetOutputStream(), GetBreakpointLocations());
+  found_file_sp, m_options.start_line, column, 0,
+  m_options.num_lines, "", &result.GetOutputStream(),
+  GetBreakpointLocations());
 
   result.SetStatus(eReturnStatusSuccessFinishResult);
 } else {

diff  --git a/lldb/test/Shell/Commands/list-header.test 
b/lldb/test/Shell/Commands/list-header.test
new file mode 100644
index 0..08bcedd3fc946
--- /dev/null
+++ b/lldb/test/Shell/Commands/list-header.test
@@ -0,0 +1,57 @@
+## Test that `list header.h:` works correctly when header is available.
+## 
+# RUN: split-file %s %t
+
+# RUN: %clang_host -g %t/main_with_inlined.cc %t/

[Lldb-commits] [lldb] [lldb]Make `list` command work with headers when possible. (PR #139002)

2025-05-19 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo closed 
https://github.com/llvm/llvm-project/pull/139002
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen updated 
https://github.com/llvm/llvm-project/pull/140482

>From 1014235896b79eb4ea05a6822714a66adaa691ac Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 18 May 2025 23:51:58 +0200
Subject: [PATCH 1/3] [lldb-dap] Migrate disassemble request to structured
 handler

---
 .../Handler/DisassembleRequestHandler.cpp | 183 +-
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   9 +-
 .../lldb-dap/Protocol/ProtocolRequests.cpp|  18 ++
 .../lldb-dap/Protocol/ProtocolRequests.h  |  35 
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  34 
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  54 ++
 6 files changed, 193 insertions(+), 140 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index d738f54ff1a9f..938078947259b 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -9,113 +9,34 @@
 #include "DAP.h"
 #include "EventHelper.h"
 #include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
+#include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBInstruction.h"
 #include "llvm/ADT/StringExtras.h"
 
+using namespace lldb_dap::protocol;
+
 namespace lldb_dap {
 
-// "DisassembleRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Disassembles code stored at the provided
-// location.\nClients should only call this request if the corresponding
-// capability `supportsDisassembleRequest` is true.", "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "disassemble" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/DisassembleArguments"
-//   }
-// },
-// "required": [ "command", "arguments" ]
-//   }]
-// },
-// "DisassembleArguments": {
-//   "type": "object",
-//   "description": "Arguments for `disassemble` request.",
-//   "properties": {
-// "memoryReference": {
-//   "type": "string",
-//   "description": "Memory reference to the base location containing the
-//   instructions to disassemble."
-// },
-// "offset": {
-//   "type": "integer",
-//   "description": "Offset (in bytes) to be applied to the reference
-//   location before disassembling. Can be negative."
-// },
-// "instructionOffset": {
-//   "type": "integer",
-//   "description": "Offset (in instructions) to be applied after the byte
-//   offset (if any) before disassembling. Can be negative."
-// },
-// "instructionCount": {
-//   "type": "integer",
-//   "description": "Number of instructions to disassemble starting at the
-//   specified location and offset.\nAn adapter must return exactly this
-//   number of instructions - any unavailable instructions should be
-//   replaced with an implementation-defined 'invalid instruction' value."
-// },
-// "resolveSymbols": {
-//   "type": "boolean",
-//   "description": "If true, the adapter should attempt to resolve memory
-//   addresses and other values to symbolic names."
-// }
-//   },
-//   "required": [ "memoryReference", "instructionCount" ]
-// },
-// "DisassembleResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to `disassemble` request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "instructions": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/DisassembledInstruction"
-// },
-// "description": "The list of disassembled instructions."
-//   }
-// },
-// "required": [ "instructions" ]
-//   }
-// }
-//   }]
-// }
-void DisassembleRequestHandler::operator()(
-const llvm::json::Object &request) const {
-  llvm::json::Object response;
-  FillResponse(request, response);
-  auto *arguments = request.getObject("arguments");
-
-  llvm::StringRef memoryReference =
-  GetString(arguments, "memoryReference").value_or("");
-  auto addr_opt = DecodeMemoryReference(memoryReference);
-  if (!addr_opt.has_value()) {
-response["success"] = false;
-response["message"] =
-"Malformed memory reference: " + memoryReference.str();
-dap.SendJSON(llvm::json::Value(std::move(response)));
-return;
-  }
-  lldb::addr_t addr_ptr = *addr_opt;
+/// Disassembles code stored at the provided location.
+/// Clients should only call this request if the corresponding capability
+/// `supportsDisassembleRequest` is true.
+llvm::Expected
+DisassembleRequestHandler::Run(const DisassembleArguments &args) const {
+  std::vector instructions;
 
-  addr_ptr += GetInteger(arguments, "instructionOffset").value_or(0);
-  l

[Lldb-commits] [lld] [lldb] [NFC] Address more bit-field storage sizes (PR #140493)

2025-05-19 Thread Sam Clegg via lldb-commits


@@ -99,15 +99,15 @@ class InputChunk {
   // the beginning of the output section this chunk was assigned to.
   int32_t outSecOff = 0;
 
-  uint8_t sectionKind : 3;
+  uint32_t sectionKind : 3;

sbc100 wrote:

Can you explain why `uint32_t` is better than `uint8_t` here?

https://github.com/llvm/llvm-project/pull/140493
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lld] [lldb] [NFC] Address more bit-field storage sizes (PR #140493)

2025-05-19 Thread Sam Clegg via lldb-commits


@@ -99,15 +99,15 @@ class InputChunk {
   // the beginning of the output section this chunk was assigned to.
   int32_t outSecOff = 0;
 
-  uint8_t sectionKind : 3;
+  uint32_t sectionKind : 3;

sbc100 wrote:

(Perhaps some background in the PR description would be useful).

https://github.com/llvm/llvm-project/pull/140493
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Synchronously wait for breakpoints resolves in tests (PR #140470)

2025-05-19 Thread John Harrison via lldb-commits


@@ -1187,15 +1187,17 @@ def request_locations(self, locationReference):
 }
 return self.send_recv(command_dict)
 
-def request_testGetTargetBreakpoints(self):
+def request_testGetTargetBreakpoints(self, only_resolved=False):

ashgti wrote:

They should be marked `verified` in the response to the `setBreakpoint` 
request, so if we update our state in that call when we get the response then 
it should be consistent.

https://github.com/llvm/llvm-project/pull/140470
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread John Harrison via lldb-commits

https://github.com/ashgti edited 
https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread John Harrison via lldb-commits

https://github.com/ashgti approved this pull request.

LGTM!

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Jonas Devlieghere via lldb-commits


@@ -726,6 +726,41 @@ struct SetDataBreakpointsResponseBody {
 };
 llvm::json::Value toJSON(const SetDataBreakpointsResponseBody &);
 
+/// Arguments to `disassemble` request.
+struct DisassembleArguments {
+  /// Memory reference to the base location containing the instructions to
+  /// disassemble.
+  std::string memoryReference;
+
+  /// Offset (in bytes) to be applied to the reference location before
+  /// disassembling. Can be negative.
+  std::optional offset;
+
+  /// Offset (in instructions) to be applied after the byte offset (if any)
+  /// before disassembling. Can be negative.
+  std::optional instructionOffset;
+
+  /// Number of instructions to disassemble starting at the specified location
+  /// and offset.
+  /// An adapter must return exactly this number of instructions - any
+  /// unavailable instructions should be replaced with an 
implementation-defined
+  /// 'invalid instruction' value.
+  uint32_t instructionCount;
+
+  /// If true, the adapter should attempt to resolve memory addresses and other
+  /// values to symbolic names.
+  std::optional resolveSymbols;
+};
+bool fromJSON(const llvm::json::Value &, DisassembleArguments &,
+  llvm::json::Path);

JDevlieghere wrote:

Add the toJSON forward declaration.

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Jonas Devlieghere via lldb-commits


@@ -782,4 +785,89 @@ bool fromJSON(const llvm::json::Value &Params, 
InstructionBreakpoint &IB,
  O.mapOptional("mode", IB.mode);
 }
 
+bool fromJSON(const llvm::json::Value &Params,
+  DisassembledInstruction::PresentationHint &PH,
+  llvm::json::Path P) {
+  auto rawHint = Params.getAsString();
+  if (!rawHint) {
+P.report("expected a string");
+return false;
+  }
+  std::optional hint =
+  StringSwitch>(
+  *rawHint)
+  .Case("normal", DisassembledInstruction::
+  eDisassembledInstructionPresentationHintNormal)
+  .Case("invalid", DisassembledInstruction::
+   eDisassembledInstructionPresentationHintInvalid)
+  .Default(std::nullopt);
+  if (!hint) {
+P.report("unexpected value");
+return false;
+  }
+  PH = *hint;
+  return true;
+}
+
+llvm::json::Value toJSON(const DisassembledInstruction::PresentationHint &PH) {
+  switch (PH) {
+  case DisassembledInstruction::eDisassembledInstructionPresentationHintNormal:
+return "normal";
+  case 
DisassembledInstruction::eDisassembledInstructionPresentationHintInvalid:
+return "invalid";
+  }
+  llvm_unreachable("unhandled presentation hint.");
+}
+
+bool fromJSON(const llvm::json::Value &Params, DisassembledInstruction &DI,
+  llvm::json::Path P) {
+  std::optional raw_address =
+  Params.getAsObject()->getString("address");
+  if (!raw_address) {
+P.report("missing `address` field");

JDevlieghere wrote:

We're using single quotes (`'`) rather than backticks for the existing error 
messages so let's stay consistent with that.
```suggestion
P.report("missing 'address' field");
```

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Jonas Devlieghere via lldb-commits


@@ -782,4 +785,89 @@ bool fromJSON(const llvm::json::Value &Params, 
InstructionBreakpoint &IB,
  O.mapOptional("mode", IB.mode);
 }
 
+bool fromJSON(const llvm::json::Value &Params,
+  DisassembledInstruction::PresentationHint &PH,
+  llvm::json::Path P) {
+  auto rawHint = Params.getAsString();
+  if (!rawHint) {
+P.report("expected a string");
+return false;
+  }
+  std::optional hint =
+  StringSwitch>(
+  *rawHint)
+  .Case("normal", DisassembledInstruction::
+  eDisassembledInstructionPresentationHintNormal)
+  .Case("invalid", DisassembledInstruction::
+   eDisassembledInstructionPresentationHintInvalid)
+  .Default(std::nullopt);
+  if (!hint) {
+P.report("unexpected value");
+return false;
+  }
+  PH = *hint;
+  return true;
+}
+
+llvm::json::Value toJSON(const DisassembledInstruction::PresentationHint &PH) {
+  switch (PH) {
+  case DisassembledInstruction::eDisassembledInstructionPresentationHintNormal:
+return "normal";
+  case 
DisassembledInstruction::eDisassembledInstructionPresentationHintInvalid:
+return "invalid";
+  }
+  llvm_unreachable("unhandled presentation hint.");
+}
+
+bool fromJSON(const llvm::json::Value &Params, DisassembledInstruction &DI,
+  llvm::json::Path P) {
+  std::optional raw_address =
+  Params.getAsObject()->getString("address");
+  if (!raw_address) {
+P.report("missing `address` field");
+return false;
+  }
+
+  std::optional address = DecodeMemoryReference(*raw_address);
+  if (!address) {
+P.report("invalid `address`");

JDevlieghere wrote:

```suggestion
P.report("invalid 'address'");
```

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Jonas Devlieghere via lldb-commits


@@ -782,4 +785,89 @@ bool fromJSON(const llvm::json::Value &Params, 
InstructionBreakpoint &IB,
  O.mapOptional("mode", IB.mode);
 }
 
+bool fromJSON(const llvm::json::Value &Params,
+  DisassembledInstruction::PresentationHint &PH,
+  llvm::json::Path P) {
+  auto rawHint = Params.getAsString();
+  if (!rawHint) {
+P.report("expected a string");
+return false;
+  }
+  std::optional hint =
+  StringSwitch>(
+  *rawHint)
+  .Case("normal", DisassembledInstruction::
+  eDisassembledInstructionPresentationHintNormal)
+  .Case("invalid", DisassembledInstruction::
+   eDisassembledInstructionPresentationHintInvalid)
+  .Default(std::nullopt);
+  if (!hint) {
+P.report("unexpected value");
+return false;
+  }
+  PH = *hint;
+  return true;
+}
+
+llvm::json::Value toJSON(const DisassembledInstruction::PresentationHint &PH) {
+  switch (PH) {
+  case DisassembledInstruction::eDisassembledInstructionPresentationHintNormal:
+return "normal";
+  case 
DisassembledInstruction::eDisassembledInstructionPresentationHintInvalid:
+return "invalid";
+  }
+  llvm_unreachable("unhandled presentation hint.");
+}
+
+bool fromJSON(const llvm::json::Value &Params, DisassembledInstruction &DI,
+  llvm::json::Path P) {
+  std::optional raw_address =

JDevlieghere wrote:

I think the current approach of special casing this per request is fine because 
it forces us to think about the representation. Also `addr_t` is just a typedef 
for `uint64_t` so adding an overload would require a separate type.

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Jonas Devlieghere via lldb-commits


@@ -726,6 +726,41 @@ struct SetDataBreakpointsResponseBody {
 };
 llvm::json::Value toJSON(const SetDataBreakpointsResponseBody &);
 
+/// Arguments to `disassemble` request.
+struct DisassembleArguments {
+  /// Memory reference to the base location containing the instructions to
+  /// disassemble.
+  std::string memoryReference;
+
+  /// Offset (in bytes) to be applied to the reference location before
+  /// disassembling. Can be negative.
+  std::optional offset;
+
+  /// Offset (in instructions) to be applied after the byte offset (if any)
+  /// before disassembling. Can be negative.
+  std::optional instructionOffset;
+
+  /// Number of instructions to disassemble starting at the specified location
+  /// and offset.
+  /// An adapter must return exactly this number of instructions - any
+  /// unavailable instructions should be replaced with an 
implementation-defined
+  /// 'invalid instruction' value.
+  uint32_t instructionCount;
+
+  /// If true, the adapter should attempt to resolve memory addresses and other
+  /// values to symbolic names.
+  std::optional resolveSymbols;
+};
+bool fromJSON(const llvm::json::Value &, DisassembleArguments &,
+  llvm::json::Path);
+
+/// Response to `disassemble` request.
+struct DisassembleResponseBody {
+  /// The list of disassembled instructions.
+  std::vector instructions;
+};
+llvm::json::Value toJSON(const DisassembleResponseBody &);

JDevlieghere wrote:

Add the fromJSON forward declaration.

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Jonas Devlieghere via lldb-commits


@@ -132,19 +56,14 @@ void DisassembleRequestHandler::operator()(
 }
   }
 
-  lldb::SBInstructionList insts =
-  dap.target.ReadInstructions(addr, inst_count, flavor_string.c_str());
+  lldb::SBInstructionList insts = dap.target.ReadInstructions(
+  addr, args.instructionCount, flavor_string.c_str());
 
-  if (!insts.IsValid()) {
-response["success"] = false;
-response["message"] = "Failed to find instructions for memory address.";
-dap.SendJSON(llvm::json::Value(std::move(response)));
-return;
-  }
+  if (!insts.IsValid())
+return llvm::make_error(
+"Failed to find instructions for memory address.");
 
-  const bool resolveSymbols =
-  GetBoolean(arguments, "resolveSymbols").value_or(false);
-  llvm::json::Array instructions;
+  const bool resolveSymbols = args.resolveSymbols.value_or(false);

JDevlieghere wrote:

```suggestion
  const bool resolve_symbols = args.resolveSymbols.value_or(false);
```

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Change the launch sequence (PR #138219)

2025-05-19 Thread John Harrison via lldb-commits

ashgti wrote:

I'll take a look at the currently disabled DAP tests and see if we can enable 
more of them.

https://github.com/llvm/llvm-project/pull/138219
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add ContinueRequestHandler unit test (PR #140566)

2025-05-19 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere created 
https://github.com/llvm/llvm-project/pull/140566

Add a simple unit test for the ContinueRequestHandler that checks that it 
returns an error when the (dummy process) is not stopped.

>From bf60439a35bb339d706efec7a3e78dc238d71cf6 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere 
Date: Mon, 19 May 2025 09:08:51 -0700
Subject: [PATCH] [lldb-dap] Add ContinueRequestHandler unit test

Add a simple unit test for the ContinueRequestHandler that checks that
it returns an error when the (dummy process) is not stopped.
---
 lldb/unittests/DAP/CMakeLists.txt   |  1 +
 lldb/unittests/DAP/Handler/ContinueTest.cpp | 45 +
 2 files changed, 46 insertions(+)
 create mode 100644 lldb/unittests/DAP/Handler/ContinueTest.cpp

diff --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index cd421401f167b..d9dc4fd454a59 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -2,6 +2,7 @@ add_lldb_unittest(DAPTests
   DAPTest.cpp
   FifoFilesTest.cpp
   Handler/DisconnectTest.cpp
+  Handler/ContinueTest.cpp
   JSONUtilsTest.cpp
   LLDBUtilsTest.cpp
   ProtocolTypesTest.cpp
diff --git a/lldb/unittests/DAP/Handler/ContinueTest.cpp 
b/lldb/unittests/DAP/Handler/ContinueTest.cpp
new file mode 100644
index 0..a67a1a25492c3
--- /dev/null
+++ b/lldb/unittests/DAP/Handler/ContinueTest.cpp
@@ -0,0 +1,45 @@
+//===-- ContinueTest.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DAP.h"
+#include "Handler/RequestHandler.h"
+#include "Protocol/ProtocolRequests.h"
+#include "TestBase.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap_tests;
+using namespace lldb_dap::protocol;
+
+class ContinueRequestHandlerTest : public DAPTestBase {};
+
+TEST_F(ContinueRequestHandlerTest, NotStopped) {
+  SBTarget target;
+  dap->debugger.SetSelectedTarget(target);
+
+  ContinueRequestHandler handler(*dap);
+
+  ContinueArguments args_all_threads;
+  args_all_threads.singleThread = false;
+  args_all_threads.threadId = 0;
+
+  auto result_all_threads = handler.Run(args_all_threads);
+  EXPECT_THAT_EXPECTED(result_all_threads,
+   llvm::FailedWithMessage("not stopped"));
+
+  ContinueArguments args_single_thread;
+  args_single_thread.singleThread = true;
+  args_single_thread.threadId = 1234;
+
+  auto result_single_thread = handler.Run(args_single_thread);
+  EXPECT_THAT_EXPECTED(result_single_thread,
+   llvm::FailedWithMessage("not stopped"));
+}

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add ContinueRequestHandler unit test (PR #140566)

2025-05-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jonas Devlieghere (JDevlieghere)


Changes

Add a simple unit test for the ContinueRequestHandler that checks that it 
returns an error when the (dummy process) is not stopped.

---
Full diff: https://github.com/llvm/llvm-project/pull/140566.diff


2 Files Affected:

- (modified) lldb/unittests/DAP/CMakeLists.txt (+1) 
- (added) lldb/unittests/DAP/Handler/ContinueTest.cpp (+45) 


``diff
diff --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index cd421401f167b..d9dc4fd454a59 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -2,6 +2,7 @@ add_lldb_unittest(DAPTests
   DAPTest.cpp
   FifoFilesTest.cpp
   Handler/DisconnectTest.cpp
+  Handler/ContinueTest.cpp
   JSONUtilsTest.cpp
   LLDBUtilsTest.cpp
   ProtocolTypesTest.cpp
diff --git a/lldb/unittests/DAP/Handler/ContinueTest.cpp 
b/lldb/unittests/DAP/Handler/ContinueTest.cpp
new file mode 100644
index 0..a67a1a25492c3
--- /dev/null
+++ b/lldb/unittests/DAP/Handler/ContinueTest.cpp
@@ -0,0 +1,45 @@
+//===-- ContinueTest.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DAP.h"
+#include "Handler/RequestHandler.h"
+#include "Protocol/ProtocolRequests.h"
+#include "TestBase.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap_tests;
+using namespace lldb_dap::protocol;
+
+class ContinueRequestHandlerTest : public DAPTestBase {};
+
+TEST_F(ContinueRequestHandlerTest, NotStopped) {
+  SBTarget target;
+  dap->debugger.SetSelectedTarget(target);
+
+  ContinueRequestHandler handler(*dap);
+
+  ContinueArguments args_all_threads;
+  args_all_threads.singleThread = false;
+  args_all_threads.threadId = 0;
+
+  auto result_all_threads = handler.Run(args_all_threads);
+  EXPECT_THAT_EXPECTED(result_all_threads,
+   llvm::FailedWithMessage("not stopped"));
+
+  ContinueArguments args_single_thread;
+  args_single_thread.singleThread = true;
+  args_single_thread.threadId = 1234;
+
+  auto result_single_thread = handler.Run(args_single_thread);
+  EXPECT_THAT_EXPECTED(result_single_thread,
+   llvm::FailedWithMessage("not stopped"));
+}

``




https://github.com/llvm/llvm-project/pull/140566
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Listen for broadcast classes. (PR #140142)

2025-05-19 Thread John Harrison via lldb-commits

https://github.com/ashgti closed 
https://github.com/llvm/llvm-project/pull/140142
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Listen for broadcast classes. (PR #140142)

2025-05-19 Thread John Harrison via lldb-commits

ashgti wrote:

I'll close this for now. We can revisit this in the future if we think 
listening more broadly for events is beneficial.

https://github.com/llvm/llvm-project/pull/140142
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread John Harrison via lldb-commits


@@ -782,4 +785,89 @@ bool fromJSON(const llvm::json::Value &Params, 
InstructionBreakpoint &IB,
  O.mapOptional("mode", IB.mode);
 }
 
+bool fromJSON(const llvm::json::Value &Params,
+  DisassembledInstruction::PresentationHint &PH,
+  llvm::json::Path P) {
+  auto rawHint = Params.getAsString();
+  if (!rawHint) {
+P.report("expected a string");
+return false;
+  }
+  std::optional hint =
+  StringSwitch>(
+  *rawHint)
+  .Case("normal", DisassembledInstruction::
+  eDisassembledInstructionPresentationHintNormal)
+  .Case("invalid", DisassembledInstruction::
+   eDisassembledInstructionPresentationHintInvalid)
+  .Default(std::nullopt);
+  if (!hint) {
+P.report("unexpected value");
+return false;
+  }
+  PH = *hint;
+  return true;
+}
+
+llvm::json::Value toJSON(const DisassembledInstruction::PresentationHint &PH) {
+  switch (PH) {
+  case DisassembledInstruction::eDisassembledInstructionPresentationHintNormal:
+return "normal";
+  case 
DisassembledInstruction::eDisassembledInstructionPresentationHintInvalid:
+return "invalid";
+  }
+  llvm_unreachable("unhandled presentation hint.");
+}
+
+bool fromJSON(const llvm::json::Value &Params, DisassembledInstruction &DI,
+  llvm::json::Path P) {
+  std::optional raw_address =

ashgti wrote:

I think that may run into issues with the c++ type system since the type is 
just a typedef like `typedef uint64_t addr_t;` I think c++ doesn't make a 
distinction between other `uint64_t` types and `addr_t`. I could be wrong on 
that though, but that may be an an issue with generalizing this to much.

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper requested changes to this pull request.


https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread Ebuka Ezike via lldb-commits


@@ -0,0 +1,16 @@
+#include 

da-viper wrote:

```suggestion
```
not needed to reduce test times

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread Ebuka Ezike via lldb-commits


@@ -72,21 +99,29 @@ BreakpointLocationsRequestHandler::Run(
 }
   }
 
-  // The line entries are sorted by addresses, but we must return the list
-  // ordered by line / column position.
-  std::sort(locations.begin(), locations.end());
-  locations.erase(llvm::unique(locations), locations.end());
+  return locations;
+}
 
-  std::vector breakpoint_locations;
-  for (auto &l : locations) {
-protocol::BreakpointLocation lc;
-lc.line = l.first;
-lc.column = l.second;
-breakpoint_locations.push_back(std::move(lc));
+std::vector>
+BreakpointLocationsRequestHandler::GetAssemblyBreakpointLocations(
+int64_t sourceReference, uint32_t start_line, uint32_t end_line) const {

da-viper wrote:

use snake_case for sourceReference

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread Ebuka Ezike via lldb-commits


@@ -72,21 +99,29 @@ BreakpointLocationsRequestHandler::Run(
 }
   }
 
-  // The line entries are sorted by addresses, but we must return the list
-  // ordered by line / column position.
-  std::sort(locations.begin(), locations.end());
-  locations.erase(llvm::unique(locations), locations.end());
+  return locations;
+}
 
-  std::vector breakpoint_locations;
-  for (auto &l : locations) {
-protocol::BreakpointLocation lc;
-lc.line = l.first;
-lc.column = l.second;
-breakpoint_locations.push_back(std::move(lc));
+std::vector>
+BreakpointLocationsRequestHandler::GetAssemblyBreakpointLocations(
+int64_t sourceReference, uint32_t start_line, uint32_t end_line) const {
+  std::vector> locations;
+  lldb::SBAddress address(sourceReference, dap.target);
+  if (!address.IsValid())
+return locations;
+
+  lldb::SBSymbol symbol = address.GetSymbol();

da-viper wrote:

Try checking if it is in a function with `address.GetFunction` and `IsValid` to 
have context before checking symbol

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread Ebuka Ezike via lldb-commits


@@ -34,26 +36,22 @@ SourceRequestHandler::Run(const protocol::SourceArguments 
&args) const {
 return llvm::make_error(
 "invalid arguments, expected source.sourceReference to be set");
 
-  lldb::SBProcess process = dap.target.GetProcess();
-  // Upper 32 bits is the thread index ID
-  lldb::SBThread thread =
-  process.GetThreadByIndexID(GetLLDBThreadIndexID(source));
-  // Lower 32 bits is the frame index
-  lldb::SBFrame frame = thread.GetFrameAtIndex(GetLLDBFrameID(source));
-  if (!frame.IsValid())
+  lldb::SBAddress address(source, dap.target);
+  if (!address.IsValid())
 return llvm::make_error("source not found");
 
+  lldb::SBSymbol symbol = address.GetSymbol();
+
   lldb::SBStream stream;
-  lldb::SBExecutionContext exe_ctx(frame);
-  lldb::SBSymbol symbol = frame.GetSymbol();
+  lldb::SBExecutionContext exe_ctx(dap.target);
 
   if (symbol.IsValid()) {

da-viper wrote:

Same as above check if it is in a function scope. 

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread Ebuka Ezike via lldb-commits


@@ -0,0 +1,55 @@
+"""
+Test lldb-dap setBreakpoints request
+"""
+
+
+import dap_server
+import shutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import line_number
+from lldbsuite.test import lldbutil
+import lldbdap_testcase
+import os
+
+
+class TestDAP_setBreakpointsAssembly(lldbdap_testcase.DAPTestCaseBase):
+# @skipIfWindows
+def test_functionality(self):
+"""Tests hitting assembly source breakpoints"""
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+
+self.dap_server.request_evaluate(
+"`settings set stop-disassembly-display no-debuginfo", 
context="repl"
+)
+
+finish_line = line_number("main.c", "// Break here")
+finish_breakpoints = self.set_source_breakpoints("main.c", 
[finish_line])
+
+assmebly_func_breakpoints = 
self.set_function_breakpoints(["assembly_func"])
+self.continue_to_breakpoints(assmebly_func_breakpoints)
+
+assembly_func_frame = self.get_stackFrames()[0]
+self.assertIn(
+"sourceReference",
+assembly_func_frame.get("source"),
+"Expected assembly source frame",
+)
+
+line = assembly_func_frame["line"]
+
+# Set an assembly breakpoint in the next line and check that it's hit
+source_reference = assembly_func_frame["source"]["sourceReference"]
+assembly_breakpoint_ids = self.set_source_breakpoints_assembly(
+source_reference, [line + 1]
+)
+self.continue_to_breakpoints(assembly_breakpoint_ids)
+
+# Continue again and verify it hits in the next function call
+self.continue_to_breakpoints(assmebly_func_breakpoints)
+self.continue_to_breakpoints(assembly_breakpoint_ids)
+
+# Clear the breakpoint and then check that the assembly breakpoint 
does not hit next time
+self.set_source_breakpoints_assembly(source_reference, [])
+self.continue_to_breakpoints(assmebly_func_breakpoints)
+self.continue_to_breakpoints(finish_breakpoints)

da-viper wrote:

```suggestion
self.continue_to_breakpoints(finish_breakpoints)

self.continue_to_exit()
```
Confirm we exit correctly

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add ContinueRequestHandler unit test (PR #140566)

2025-05-19 Thread John Harrison via lldb-commits

https://github.com/ashgti approved this pull request.

LGTM.

Is there anyway we can make a mock or something for the SBProcess? That would 
be helpful for these tests, but I am not sure if we have that somewhere in the 
lldb testing utilities or not already.

https://github.com/llvm/llvm-project/pull/140566
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add ContinueRequestHandler unit test (PR #140566)

2025-05-19 Thread Ebuka Ezike via lldb-commits

https://github.com/da-viper approved this pull request.


https://github.com/llvm/llvm-project/pull/140566
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add ContinueRequestHandler unit test (PR #140566)

2025-05-19 Thread Jonas Devlieghere via lldb-commits

JDevlieghere wrote:

> Is there anyway we can make a mock or something for the SBProcess? That would 
> be helpful for these tests, but I am not sure if we have that somewhere in 
> the lldb testing utilities or not already.

We have a few unit tests that inherit from `lldb_private::Process` for mocking, 
but I've never looked into mocking `SBProcess`. Maybe that's not too hard with 
GMock? 

https://github.com/llvm/llvm-project/pull/140566
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread John Harrison via lldb-commits


@@ -955,6 +955,13 @@ def request_setBreakpoints(self, file_path, line_array, 
data=None):
 """
 (dir, base) = os.path.split(file_path)
 source_dict = {"name": base, "path": file_path}
+return self.request_setBreakpoints_with_source(source_dict, 
line_array, data)
+
+def request_setBreakpointsAssembly(self, sourceReference, line_array, 
data=None):
+source_dict = {"sourceReference": sourceReference}
+return self.request_setBreakpoints_with_source(source_dict, 
line_array, data)
+
+def request_setBreakpoints_with_source(self, source_dict, line_array, 
data=None):

ashgti wrote:

Could we keep the `request_*` names just the DAP requests and make a helper 
without the `request_*` prefix for this? I like the consistency of having 
`request_*` being able to map to specific request and I think its valuable to 
keep that.

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread John Harrison via lldb-commits


@@ -0,0 +1,55 @@
+"""
+Test lldb-dap setBreakpoints request

ashgti wrote:

`Test lldb-dap setBreakpoints in assembly source references`?

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread John Harrison via lldb-commits


@@ -452,6 +475,9 @@ struct DAP {
 
   std::mutex m_active_request_mutex;
   const protocol::Request *m_active_request;
+
+  llvm::StringMap m_source_breakpoints;
+  llvm::DenseMap m_source_assembly_breakpoints;

ashgti wrote:

If we made `protocol::Source` work in a `std::map` (or `llvm::DenseMap`) as a 
key, could we merge these? That could simplify things and make this more 
consistent between the two.

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread John Harrison via lldb-commits


@@ -33,13 +35,42 @@ SourceBreakpoint::SourceBreakpoint(DAP &dap,
   m_line(breakpoint.line),
   m_column(breakpoint.column.value_or(LLDB_INVALID_COLUMN_NUMBER)) {}
 
-void SourceBreakpoint::SetBreakpoint(const llvm::StringRef source_path) {
+void SourceBreakpoint::SetBreakpoint(const protocol::Source &source) {
   lldb::SBMutex lock = m_dap.GetAPIMutex();
   std::lock_guard guard(lock);
 
-  lldb::SBFileSpecList module_list;
-  m_bp = m_dap.target.BreakpointCreateByLocation(
-  source_path.str().c_str(), m_line, m_column, 0, module_list);
+  if (m_line == 0)
+return;
+
+  if (source.sourceReference) {
+// breakpoint set by assembly source.
+lldb::SBAddress source_address(*source.sourceReference, m_dap.target);
+if (!source_address.IsValid())

ashgti wrote:

Should we return an error? Or maybe log that this is invalid?

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread John Harrison via lldb-commits


@@ -0,0 +1,55 @@
+"""
+Test lldb-dap setBreakpoints request
+"""
+
+
+import dap_server
+import shutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import line_number
+from lldbsuite.test import lldbutil
+import lldbdap_testcase
+import os
+
+
+class TestDAP_setBreakpointsAssembly(lldbdap_testcase.DAPTestCaseBase):
+# @skipIfWindows
+def test_functionality(self):

ashgti wrote:

`test_can_break_in_source_references`?

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb] Retcon SBValue::GetChildAtIndex(synthetic=true) (PR #140065)

2025-05-19 Thread via lldb-commits

https://github.com/jimingham approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/140065
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][nfc]Temporarily disable test on non-x86 because output-redirec… (PR #140585)

2025-05-19 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo created 
https://github.com/llvm/llvm-project/pull/140585

…tion doesn't work properly

>From a694c9b4a249ec541115cebdd9a88e75ce8aceb7 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Mon, 19 May 2025 13:38:37 -0400
Subject: [PATCH] [lldb][nfc]Temporarily disable test on non-x86 because
 output-redirection doesn't work properly

---
 lldb/test/Shell/Commands/list-header.test | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lldb/test/Shell/Commands/list-header.test 
b/lldb/test/Shell/Commands/list-header.test
index 08bcedd3fc946..02630602b57d0 100644
--- a/lldb/test/Shell/Commands/list-header.test
+++ b/lldb/test/Shell/Commands/list-header.test
@@ -1,3 +1,5 @@
+# REQUIRES: x86
+
 ## Test that `list header.h:` works correctly when header is available.
 ## 
 # RUN: split-file %s %t

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][nfc]Temporarily disable test on non-x86 because output-redirec… (PR #140585)

2025-05-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vy Nguyen (oontvoo)


Changes

…tion doesn't work properly

---
Full diff: https://github.com/llvm/llvm-project/pull/140585.diff


1 Files Affected:

- (modified) lldb/test/Shell/Commands/list-header.test (+2) 


``diff
diff --git a/lldb/test/Shell/Commands/list-header.test 
b/lldb/test/Shell/Commands/list-header.test
index 08bcedd3fc946..02630602b57d0 100644
--- a/lldb/test/Shell/Commands/list-header.test
+++ b/lldb/test/Shell/Commands/list-header.test
@@ -1,3 +1,5 @@
+# REQUIRES: x86
+
 ## Test that `list header.h:` works correctly when header is available.
 ## 
 # RUN: split-file %s %t

``




https://github.com/llvm/llvm-project/pull/140585
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][nfc]Temporarily disable test on non-x86 because output-redirec… (PR #140585)

2025-05-19 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo edited 
https://github.com/llvm/llvm-project/pull/140585
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 1b44eb2 - [lldb][nfc]Temporarily disable test on non-x86 because output-redirec… (#140585)

2025-05-19 Thread via lldb-commits

Author: Vy Nguyen
Date: 2025-05-19T13:40:38-04:00
New Revision: 1b44eb2f6b862fb171629321bf2f5ec231899c71

URL: 
https://github.com/llvm/llvm-project/commit/1b44eb2f6b862fb171629321bf2f5ec231899c71
DIFF: 
https://github.com/llvm/llvm-project/commit/1b44eb2f6b862fb171629321bf2f5ec231899c71.diff

LOG: [lldb][nfc]Temporarily disable test on non-x86 because output-redirec… 
(#140585)

because output-redirection doesn't work properly

Added: 


Modified: 
lldb/test/Shell/Commands/list-header.test

Removed: 




diff  --git a/lldb/test/Shell/Commands/list-header.test 
b/lldb/test/Shell/Commands/list-header.test
index 08bcedd3fc946..02630602b57d0 100644
--- a/lldb/test/Shell/Commands/list-header.test
+++ b/lldb/test/Shell/Commands/list-header.test
@@ -1,3 +1,5 @@
+# REQUIRES: x86
+
 ## Test that `list header.h:` works correctly when header is available.
 ## 
 # RUN: split-file %s %t



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][nfc]Temporarily disable test on non-x86 because output-redirec… (PR #140585)

2025-05-19 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo closed 
https://github.com/llvm/llvm-project/pull/140585
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][ELF Core] Support all the Generic (Negative) SI Codes. (PR #140150)

2025-05-19 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond updated 
https://github.com/llvm/llvm-project/pull/140150

>From 86ec6c076b9cf8e7afeb7d6bb0e334434f6e0d9e Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Thu, 15 May 2025 13:57:11 -0700
Subject: [PATCH 1/9] Update ThreadElfCore

---
 lldb/include/lldb/Target/UnixSignals.h  |  6 --
 .../Plugins/Process/Utility/LinuxSignals.cpp| 17 ++---
 .../Plugins/Process/elf-core/ThreadElfCore.cpp  | 10 +++---
 .../Plugins/Process/elf-core/ThreadElfCore.h|  6 ++
 lldb/source/Target/UnixSignals.cpp  |  9 +++--
 5 files changed, 38 insertions(+), 10 deletions(-)

diff --git a/lldb/include/lldb/Target/UnixSignals.h 
b/lldb/include/lldb/Target/UnixSignals.h
index b3605ccefddbe..a1807d69f329b 100644
--- a/lldb/include/lldb/Target/UnixSignals.h
+++ b/lldb/include/lldb/Target/UnixSignals.h
@@ -36,7 +36,9 @@ class UnixSignals {
std::optional code = std::nullopt,
std::optional addr = std::nullopt,
std::optional lower = std::nullopt,
-   std::optional upper = std::nullopt) const;
+   std::optional upper = std::nullopt,
+   std::optional pid = std::nullopt,
+   std::optional uid = std::nullopt) const;
 
   bool SignalIsValid(int32_t signo) const;
 
@@ -105,7 +107,7 @@ class UnixSignals {
  llvm::StringRef description,
  llvm::StringRef alias = llvm::StringRef());
 
-  enum SignalCodePrintOption { None, Address, Bounds };
+  enum SignalCodePrintOption { None, Address, Bounds, Sender };
 
   // Instead of calling this directly, use a ADD_SIGCODE macro to get compile
   // time checks when on the native platform.
diff --git a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp 
b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
index 9c4fe55147a28..25d4e4609bbb8 100644
--- a/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
+++ b/lldb/source/Plugins/Process/Utility/LinuxSignals.cpp
@@ -38,6 +38,17 @@
 #define ADD_SIGCODE(signal_name, signal_value, code_name, code_value, ...) 
\
   AddSignalCode(signal_value, code_value, __VA_ARGS__)
 #endif /* if defined(__linux__) && !defined(__mips__) */
+// See siginfo.h in the Linux Kernel, these codes can be sent for any signal.
+#define ADD_LINUX_SIGNAL(signo, name, ...) \
+  AddSignal(signo, name, __VA_ARGS__); \
+  ADD_SIGCODE(signo, signo, SI_QUEUE, -1, "sent by sigqueue"); \
+  ADD_SIGCODE(signo, signo, SI_TIMER, -2, "sent by timer expiration"); \
+  ADD_SIGCODE(signo, signo, SI_MESGQ, -3, "sent by real time mesq state 
change"); \
+  ADD_SIGCODE(signo, signo, SI_ASYNCIO, -4, "sent by AIO completion"); \
+  ADD_SIGCODE(signo, signo, SI_SIGIO, -5, "sent by queued SIGIO"); \
+  ADD_SIGCODE(signo, signo, SI_TKILL, -6, "sent by tkill system call"); \
+  ADD_SIGCODE(signo, signo, SI_DETHREAD, -7, "sent by execve() killing 
subsidiary threads"); \
+  ADD_SIGCODE(signo, signo, SI_ASYNCNL, -60, "sent by glibc async name lookup 
completion"); 
 
 using namespace lldb_private;
 
@@ -46,9 +57,9 @@ LinuxSignals::LinuxSignals() : UnixSignals() { Reset(); }
 void LinuxSignals::Reset() {
   m_signals.clear();
   // clang-format off
-  //SIGNO   NAMESUPPRESS  STOPNOTIFY  DESCRIPTION
-  //==  ==    ==  ==  
===
-  AddSignal(1,  "SIGHUP",   false,true,   true,   "hangup");
+  //   SIGNO   NAMESUPPRESS  STOPNOTIFY  
DESCRIPTION
+  //   ==  ==    ==  ==  
===
+  ADD_LINUX_SIGNAL(1,  "SIGHUP",   false,true,   true,   "hangup");
   AddSignal(2,  "SIGINT",   true, true,   true,   "interrupt");
   AddSignal(3,  "SIGQUIT",  false,true,   true,   "quit");
 
diff --git a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp 
b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
index a0cd0ee5025bd..267879a473463 100644
--- a/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
+++ b/lldb/source/Plugins/Process/elf-core/ThreadElfCore.cpp
@@ -584,9 +584,13 @@ Status ELFLinuxSigInfo::Parse(const DataExtractor &data, 
const ArchSpec &arch,
   // 64b ELF have a 4 byte pad.
   if (data.GetAddressByteSize() == 8)
 offset += 4;
-  // Not every stop signal has a valid address, but that will get resolved in
-  // the unix_signals.GetSignalDescription() call below.
-  if (unix_signals.GetShouldStop(si_signo)) {
+
+ if (si_code < 0) {
+  sigfault.kill._pid = data.GetU32(&offset);
+  sigfault.kill._uid = data.GetU32(&offset);
+ } else if (unix_signals.GetShouldStop(si_signo)) {
+// Not every stop signal has a valid address, but that will get resolved in
+// the unix_signals.GetSignalDescription() call below.
 // Instead of memcpy we call all these individu

[Lldb-commits] [lldb] [lldb] Suppport testing with debug-python on Windows (PR #140443)

2025-05-19 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere closed 
https://github.com/llvm/llvm-project/pull/140443
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] 3bae8e2 - [lldb] Suppport testing with debug-python on Windows (#140443)

2025-05-19 Thread via lldb-commits

Author: nerix
Date: 2025-05-19T11:13:49-07:00
New Revision: 3bae8e2ef2ff02dcba745cb47ea1264fd08885cc

URL: 
https://github.com/llvm/llvm-project/commit/3bae8e2ef2ff02dcba745cb47ea1264fd08885cc
DIFF: 
https://github.com/llvm/llvm-project/commit/3bae8e2ef2ff02dcba745cb47ea1264fd08885cc.diff

LOG: [lldb] Suppport testing with debug-python on Windows (#140443)

When trying to run the LLDB API tests on Windows with a debug
configuration, they fail, because the `_lldb` module won't be found. As
explained in https://github.com/llvm/llvm-project/issues/51272, this is
because lit will run the test with `python.exe` but the module is built
for the debug version of python, `python_d.exe`.

CMake already resolved the debug executable in
`Python3_EXECUTABLE_DEBUG`, so this PR changes the
`config.python_executable` to point to `python_d.exe` on Windows in
debug mode.

The check is equivalent to the one done in the top-level LLDB CMakeLists
[when setting the python
suffix](https://github.com/llvm/llvm-project/blob/3ccb15d6caf57f2a866d496ada2fb52d14b179d2/lldb/CMakeLists.txt#L79-L86).

Added: 


Modified: 
lldb/test/API/CMakeLists.txt
lldb/test/API/lit.site.cfg.py.in

Removed: 




diff  --git a/lldb/test/API/CMakeLists.txt b/lldb/test/API/CMakeLists.txt
index da51f2252d023..b1ace6296f46a 100644
--- a/lldb/test/API/CMakeLists.txt
+++ b/lldb/test/API/CMakeLists.txt
@@ -139,6 +139,12 @@ if(CMAKE_HOST_APPLE)
   endif()
 endif()
 
+if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL Debug)
+  set(LLDB_PYTHON_API_TEST_EXECUTABLE "${Python3_EXECUTABLE_DEBUG}")
+else()
+  set(LLDB_PYTHON_API_TEST_EXECUTABLE "${Python3_EXECUTABLE}")
+endif()
+
 set(dotest_args_replacement ${LLVM_BUILD_MODE})
 
 if(LLDB_BUILT_STANDALONE)

diff  --git a/lldb/test/API/lit.site.cfg.py.in 
b/lldb/test/API/lit.site.cfg.py.in
index ecebc44774859..54807de8819d2 100644
--- a/lldb/test/API/lit.site.cfg.py.in
+++ b/lldb/test/API/lit.site.cfg.py.in
@@ -19,7 +19,7 @@ config.shared_libs = @LLVM_ENABLE_SHARED_LIBS@
 config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"
 config.target_triple = "@LLVM_TARGET_TRIPLE@"
 config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
-config.python_executable = "@Python3_EXECUTABLE@"
+config.python_executable = "@LLDB_PYTHON_API_TEST_EXECUTABLE@"
 config.lua_executable = "@LUA_EXECUTABLE@"
 config.lldb_lua_cpath = "@LLDB_LUA_CPATH@"
 config.lua_test_entry = "TestLuaAPI.py"



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][nfc]Make test "xfail" on windows (PR #140588)

2025-05-19 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo created 
https://github.com/llvm/llvm-project/pull/140588

None

>From 8bf781af04e046076de1e5d6ebcfcf1f508be211 Mon Sep 17 00:00:00 2001
From: Vy Nguyen 
Date: Mon, 19 May 2025 14:26:36 -0400
Subject: [PATCH] [lldb][nfc]Make test "xfail" on windows

---
 lldb/test/Shell/Commands/list-header.test | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lldb/test/Shell/Commands/list-header.test 
b/lldb/test/Shell/Commands/list-header.test
index 02630602b57d0..be77b9fa383ca 100644
--- a/lldb/test/Shell/Commands/list-header.test
+++ b/lldb/test/Shell/Commands/list-header.test
@@ -1,4 +1,6 @@
-# REQUIRES: x86
+## Does not work on windows (yet?) PDB debug-info likely does something wrong
+## with the header files.
+# XFAIL: system-windows
 
 ## Test that `list header.h:` works correctly when header is available.
 ## 

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] fe1c482 - [lldb][nfc]Make test "xfail" on windows (#140588)

2025-05-19 Thread via lldb-commits

Author: Vy Nguyen
Date: 2025-05-19T14:28:18-04:00
New Revision: fe1c4827b77a8d39bb1462cb4df08f6fe572097a

URL: 
https://github.com/llvm/llvm-project/commit/fe1c4827b77a8d39bb1462cb4df08f6fe572097a
DIFF: 
https://github.com/llvm/llvm-project/commit/fe1c4827b77a8d39bb1462cb4df08f6fe572097a.diff

LOG: [lldb][nfc]Make test "xfail" on windows (#140588)

Added: 


Modified: 
lldb/test/Shell/Commands/list-header.test

Removed: 




diff  --git a/lldb/test/Shell/Commands/list-header.test 
b/lldb/test/Shell/Commands/list-header.test
index 02630602b57d0..be77b9fa383ca 100644
--- a/lldb/test/Shell/Commands/list-header.test
+++ b/lldb/test/Shell/Commands/list-header.test
@@ -1,4 +1,6 @@
-# REQUIRES: x86
+## Does not work on windows (yet?) PDB debug-info likely does something wrong
+## with the header files.
+# XFAIL: system-windows
 
 ## Test that `list header.h:` works correctly when header is available.
 ## 



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][nfc]Make test "xfail" on windows (PR #140588)

2025-05-19 Thread Vy Nguyen via lldb-commits

https://github.com/oontvoo closed 
https://github.com/llvm/llvm-project/pull/140588
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][nfc]Make test "xfail" on windows (PR #140588)

2025-05-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Vy Nguyen (oontvoo)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/140588.diff


1 Files Affected:

- (modified) lldb/test/Shell/Commands/list-header.test (+3-1) 


``diff
diff --git a/lldb/test/Shell/Commands/list-header.test 
b/lldb/test/Shell/Commands/list-header.test
index 02630602b57d0..be77b9fa383ca 100644
--- a/lldb/test/Shell/Commands/list-header.test
+++ b/lldb/test/Shell/Commands/list-header.test
@@ -1,4 +1,6 @@
-# REQUIRES: x86
+## Does not work on windows (yet?) PDB debug-info likely does something wrong
+## with the header files.
+# XFAIL: system-windows
 
 ## Test that `list header.h:` works correctly when header is available.
 ## 

``




https://github.com/llvm/llvm-project/pull/140588
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] d8665bb - [lldb-dap] Add ContinueRequestHandler unit test (#140566)

2025-05-19 Thread via lldb-commits

Author: Jonas Devlieghere
Date: 2025-05-19T11:39:19-07:00
New Revision: d8665bb76788790b107c2ed455d691c89987f3f3

URL: 
https://github.com/llvm/llvm-project/commit/d8665bb76788790b107c2ed455d691c89987f3f3
DIFF: 
https://github.com/llvm/llvm-project/commit/d8665bb76788790b107c2ed455d691c89987f3f3.diff

LOG: [lldb-dap] Add ContinueRequestHandler unit test (#140566)

Add a simple unit test for the ContinueRequestHandler that checks that
it returns an error when the (dummy process) is not stopped.

Added: 
lldb/unittests/DAP/Handler/ContinueTest.cpp

Modified: 
lldb/unittests/DAP/CMakeLists.txt

Removed: 




diff  --git a/lldb/unittests/DAP/CMakeLists.txt 
b/lldb/unittests/DAP/CMakeLists.txt
index cd421401f167b..d9dc4fd454a59 100644
--- a/lldb/unittests/DAP/CMakeLists.txt
+++ b/lldb/unittests/DAP/CMakeLists.txt
@@ -2,6 +2,7 @@ add_lldb_unittest(DAPTests
   DAPTest.cpp
   FifoFilesTest.cpp
   Handler/DisconnectTest.cpp
+  Handler/ContinueTest.cpp
   JSONUtilsTest.cpp
   LLDBUtilsTest.cpp
   ProtocolTypesTest.cpp

diff  --git a/lldb/unittests/DAP/Handler/ContinueTest.cpp 
b/lldb/unittests/DAP/Handler/ContinueTest.cpp
new file mode 100644
index 0..a67a1a25492c3
--- /dev/null
+++ b/lldb/unittests/DAP/Handler/ContinueTest.cpp
@@ -0,0 +1,45 @@
+//===-- ContinueTest.cpp 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "DAP.h"
+#include "Handler/RequestHandler.h"
+#include "Protocol/ProtocolRequests.h"
+#include "TestBase.h"
+#include "llvm/Testing/Support/Error.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace lldb;
+using namespace lldb_dap;
+using namespace lldb_dap_tests;
+using namespace lldb_dap::protocol;
+
+class ContinueRequestHandlerTest : public DAPTestBase {};
+
+TEST_F(ContinueRequestHandlerTest, NotStopped) {
+  SBTarget target;
+  dap->debugger.SetSelectedTarget(target);
+
+  ContinueRequestHandler handler(*dap);
+
+  ContinueArguments args_all_threads;
+  args_all_threads.singleThread = false;
+  args_all_threads.threadId = 0;
+
+  auto result_all_threads = handler.Run(args_all_threads);
+  EXPECT_THAT_EXPECTED(result_all_threads,
+   llvm::FailedWithMessage("not stopped"));
+
+  ContinueArguments args_single_thread;
+  args_single_thread.singleThread = true;
+  args_single_thread.threadId = 1234;
+
+  auto result_single_thread = handler.Run(args_single_thread);
+  EXPECT_THAT_EXPECTED(result_single_thread,
+   llvm::FailedWithMessage("not stopped"));
+}



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Add ContinueRequestHandler unit test (PR #140566)

2025-05-19 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere closed 
https://github.com/llvm/llvm-project/pull/140566
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][Progress-On-Dap] Have indeterminate progress actually send events. (PR #140162)

2025-05-19 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.

LGTM if @ashgti is happy. 

https://github.com/llvm/llvm-project/pull/140162
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lld] [lldb] [NFC] Address more bit-field storage sizes (PR #140493)

2025-05-19 Thread Oliver Hunt via lldb-commits


@@ -99,15 +99,15 @@ class InputChunk {
   // the beginning of the output section this chunk was assigned to.
   int32_t outSecOff = 0;
 
-  uint8_t sectionKind : 3;
+  uint32_t sectionKind : 3;

ojhunt wrote:

Unfortunately I can :(

The MS ABI only packs bit-fields if they have the same storage size, e.g.

```cpp
struct S {
   bool b: 1;
   inti: 1
};
```

is 8 bytes.

It's a large part of why we use preferred_type and unsigned bit-fields instead 
of just enum bit-fields.

This PR is the continuing series of fixing the existing cases where the storage 
types are wrong (per MS :D), so we can then enable the warning for this 
behavior, so that we can then just start using enums without risking silently 
terrible padding with MSVC

https://github.com/llvm/llvm-project/pull/140493
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lld] [lldb] [NFC] Address more bit-field storage sizes (PR #140493)

2025-05-19 Thread Oliver Hunt via lldb-commits

https://github.com/ojhunt updated 
https://github.com/llvm/llvm-project/pull/140493

>From 7bf3ebaa15bdabdef20a2b15933fbb66fa0aaa2c Mon Sep 17 00:00:00 2001
From: Oliver Hunt 
Date: Sun, 18 May 2025 20:31:43 -0700
Subject: [PATCH] [NFC] Address more bit-field storage sizes

Follow on work from #139825.

As previously this is fixing a few more cases where adjacent bit-fields
have types with different base storage sizes, as the MS ABI will not
pack those bit-fields.
---
 lld/wasm/InputChunks.h | 6 +++---
 lldb/source/Plugins/Language/ObjC/NSArray.cpp  | 2 +-
 lldb/source/Plugins/Language/ObjC/NSDictionary.cpp | 6 +++---
 lldb/source/Plugins/Language/ObjC/NSSet.cpp| 2 +-
 lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h | 2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/lld/wasm/InputChunks.h b/lld/wasm/InputChunks.h
index 1fe78d76631f1..4bae235b247c5 100644
--- a/lld/wasm/InputChunks.h
+++ b/lld/wasm/InputChunks.h
@@ -99,15 +99,15 @@ class InputChunk {
   // the beginning of the output section this chunk was assigned to.
   int32_t outSecOff = 0;
 
-  uint8_t sectionKind : 3;
+  uint32_t sectionKind : 3;
 
   // Signals that the section is part of the output.  The garbage collector,
   // and COMDAT handling can set a sections' Live bit.
   // If GC is disabled, all sections start out as live by default.
-  unsigned live : 1;
+  uint32_t live : 1;
 
   // Signals the chunk was discarded by COMDAT handling.
-  unsigned discarded : 1;
+  uint32_t discarded : 1;
 
 protected:
   InputChunk(ObjFile *f, Kind k, StringRef name, uint32_t alignment = 0,
diff --git a/lldb/source/Plugins/Language/ObjC/NSArray.cpp 
b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
index 25376e064879d..444286692994d 100644
--- a/lldb/source/Plugins/Language/ObjC/NSArray.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSArray.cpp
@@ -101,7 +101,7 @@ namespace Foundation1010 {
   uint32_t _used;
   uint32_t _offset;
   uint32_t _size : 28;
-  uint64_t _priv1 : 4;
+  uint32_t _priv1 : 4;
   uint32_t _priv2;
   uint32_t _data;
 };
diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp 
b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
index ef1c2c89fe125..4f5c54b2c077c 100644
--- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp
@@ -119,7 +119,7 @@ class NSDictionaryISyntheticFrontEnd : public 
SyntheticChildrenFrontEnd {
 
   struct DataDescriptor_64 {
 uint64_t _used : 58;
-uint32_t _szidx : 6;
+uint64_t _szidx : 6;
   };
 
   struct DictionaryItemDescriptor {
@@ -273,7 +273,7 @@ namespace Foundation1100 {
 
 struct DataDescriptor_64 {
   uint64_t _used : 58;
-  uint32_t _kvo : 1;
+  uint64_t _kvo : 1;
   uint64_t _size;
   uint64_t _mutations;
   uint64_t _objs_addr;
@@ -308,7 +308,7 @@ namespace Foundation1428 {
 
 struct DataDescriptor_64 {
   uint64_t _used : 58;
-  uint32_t _kvo : 1;
+  uint64_t _kvo : 1;
   uint64_t _size;
   uint64_t _buffer;
   uint64_t GetSize() { return _size; }
diff --git a/lldb/source/Plugins/Language/ObjC/NSSet.cpp 
b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
index 7d814e656dc5f..bee6d5ceb41b6 100644
--- a/lldb/source/Plugins/Language/ObjC/NSSet.cpp
+++ b/lldb/source/Plugins/Language/ObjC/NSSet.cpp
@@ -62,7 +62,7 @@ class NSSetISyntheticFrontEnd : public 
SyntheticChildrenFrontEnd {
 
   struct DataDescriptor_64 {
 uint64_t _used : 58;
-uint32_t _szidx : 6;
+uint64_t _szidx : 6;
   };
 
   struct SetItemDescriptor {
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
index 72aeb2743b1e2..022a64e3d7f6f 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h
@@ -189,7 +189,7 @@ class DWARFDebugInfoEntry {
   // If it is zero, then the DIE doesn't have children,
   // or the DWARF claimed it had children but the DIE
   // only contained a single NULL terminating child.
-  uint32_t m_sibling_idx : 31, m_has_children : 1;
+  uint64_t m_sibling_idx : 31, m_has_children : 1;
   uint16_t m_abbr_idx = 0;
   /// A copy of the DW_TAG value so we don't have to go through the compile
   /// unit abbrev table

___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lld] [lldb] [NFC] Address more bit-field storage sizes (PR #140493)

2025-05-19 Thread Oliver Hunt via lldb-commits

https://github.com/ojhunt edited 
https://github.com/llvm/llvm-project/pull/140493
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lld] [lldb] [NFC] Address more bit-field storage sizes (PR #140493)

2025-05-19 Thread Oliver Hunt via lldb-commits

ojhunt wrote:

Force push with no PR changes other than attaching more information to the 
commit message.

https://github.com/llvm/llvm-project/pull/140493
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lld] [lldb] [NFC] Address more bit-field storage sizes (PR #140493)

2025-05-19 Thread Sam Clegg via lldb-commits


@@ -99,15 +99,15 @@ class InputChunk {
   // the beginning of the output section this chunk was assigned to.
   int32_t outSecOff = 0;
 
-  uint8_t sectionKind : 3;
+  uint32_t sectionKind : 3;

sbc100 wrote:

By MS ABI I assume you mean mircrosoft?  

I guess this is not actually a regression on non-MS compilers since the bit 
width means that type does not actually impact the size in the struct?

https://github.com/llvm/llvm-project/pull/140493
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Ely Ronnen via lldb-commits


@@ -132,19 +56,14 @@ void DisassembleRequestHandler::operator()(
 }
   }
 
-  lldb::SBInstructionList insts =
-  dap.target.ReadInstructions(addr, inst_count, flavor_string.c_str());
+  lldb::SBInstructionList insts = dap.target.ReadInstructions(
+  addr, args.instructionCount, flavor_string.c_str());
 
-  if (!insts.IsValid()) {
-response["success"] = false;
-response["message"] = "Failed to find instructions for memory address.";
-dap.SendJSON(llvm::json::Value(std::move(response)));
-return;
-  }
+  if (!insts.IsValid())
+return llvm::make_error(
+"Failed to find instructions for memory address.");
 
-  const bool resolveSymbols =
-  GetBoolean(arguments, "resolveSymbols").value_or(false);
-  llvm::json::Array instructions;
+  const bool resolveSymbols = args.resolveSymbols.value_or(false);

eronnen wrote:

:100: 

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen deleted 
https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen updated 
https://github.com/llvm/llvm-project/pull/140482

>From 1014235896b79eb4ea05a6822714a66adaa691ac Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 18 May 2025 23:51:58 +0200
Subject: [PATCH 1/4] [lldb-dap] Migrate disassemble request to structured
 handler

---
 .../Handler/DisassembleRequestHandler.cpp | 183 +-
 lldb/tools/lldb-dap/Handler/RequestHandler.h  |   9 +-
 .../lldb-dap/Protocol/ProtocolRequests.cpp|  18 ++
 .../lldb-dap/Protocol/ProtocolRequests.h  |  35 
 .../tools/lldb-dap/Protocol/ProtocolTypes.cpp |  34 
 lldb/tools/lldb-dap/Protocol/ProtocolTypes.h  |  54 ++
 6 files changed, 193 insertions(+), 140 deletions(-)

diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index d738f54ff1a9f..938078947259b 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -9,113 +9,34 @@
 #include "DAP.h"
 #include "EventHelper.h"
 #include "JSONUtils.h"
+#include "Protocol/ProtocolRequests.h"
+#include "Protocol/ProtocolTypes.h"
 #include "RequestHandler.h"
 #include "lldb/API/SBInstruction.h"
 #include "llvm/ADT/StringExtras.h"
 
+using namespace lldb_dap::protocol;
+
 namespace lldb_dap {
 
-// "DisassembleRequest": {
-//   "allOf": [ { "$ref": "#/definitions/Request" }, {
-// "type": "object",
-// "description": "Disassembles code stored at the provided
-// location.\nClients should only call this request if the corresponding
-// capability `supportsDisassembleRequest` is true.", "properties": {
-//   "command": {
-// "type": "string",
-// "enum": [ "disassemble" ]
-//   },
-//   "arguments": {
-// "$ref": "#/definitions/DisassembleArguments"
-//   }
-// },
-// "required": [ "command", "arguments" ]
-//   }]
-// },
-// "DisassembleArguments": {
-//   "type": "object",
-//   "description": "Arguments for `disassemble` request.",
-//   "properties": {
-// "memoryReference": {
-//   "type": "string",
-//   "description": "Memory reference to the base location containing the
-//   instructions to disassemble."
-// },
-// "offset": {
-//   "type": "integer",
-//   "description": "Offset (in bytes) to be applied to the reference
-//   location before disassembling. Can be negative."
-// },
-// "instructionOffset": {
-//   "type": "integer",
-//   "description": "Offset (in instructions) to be applied after the byte
-//   offset (if any) before disassembling. Can be negative."
-// },
-// "instructionCount": {
-//   "type": "integer",
-//   "description": "Number of instructions to disassemble starting at the
-//   specified location and offset.\nAn adapter must return exactly this
-//   number of instructions - any unavailable instructions should be
-//   replaced with an implementation-defined 'invalid instruction' value."
-// },
-// "resolveSymbols": {
-//   "type": "boolean",
-//   "description": "If true, the adapter should attempt to resolve memory
-//   addresses and other values to symbolic names."
-// }
-//   },
-//   "required": [ "memoryReference", "instructionCount" ]
-// },
-// "DisassembleResponse": {
-//   "allOf": [ { "$ref": "#/definitions/Response" }, {
-// "type": "object",
-// "description": "Response to `disassemble` request.",
-// "properties": {
-//   "body": {
-// "type": "object",
-// "properties": {
-//   "instructions": {
-// "type": "array",
-// "items": {
-//   "$ref": "#/definitions/DisassembledInstruction"
-// },
-// "description": "The list of disassembled instructions."
-//   }
-// },
-// "required": [ "instructions" ]
-//   }
-// }
-//   }]
-// }
-void DisassembleRequestHandler::operator()(
-const llvm::json::Object &request) const {
-  llvm::json::Object response;
-  FillResponse(request, response);
-  auto *arguments = request.getObject("arguments");
-
-  llvm::StringRef memoryReference =
-  GetString(arguments, "memoryReference").value_or("");
-  auto addr_opt = DecodeMemoryReference(memoryReference);
-  if (!addr_opt.has_value()) {
-response["success"] = false;
-response["message"] =
-"Malformed memory reference: " + memoryReference.str();
-dap.SendJSON(llvm::json::Value(std::move(response)));
-return;
-  }
-  lldb::addr_t addr_ptr = *addr_opt;
+/// Disassembles code stored at the provided location.
+/// Clients should only call this request if the corresponding capability
+/// `supportsDisassembleRequest` is true.
+llvm::Expected
+DisassembleRequestHandler::Run(const DisassembleArguments &args) const {
+  std::vector instructions;
 
-  addr_ptr += GetInteger(arguments, "instructionOffset").value_or(0);
-  l

[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Ely Ronnen via lldb-commits

eronnen wrote:

Fixed comments

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread Ely Ronnen via lldb-commits


@@ -0,0 +1,16 @@
+#include 

eronnen wrote:

fixed, for some reason I'm getting a warning `ISO C requires a translation unit 
to contain at least one declarationclang(-Wempty-translation-unit)` but I can 
ignore

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread Ely Ronnen via lldb-commits


@@ -0,0 +1,55 @@
+"""
+Test lldb-dap setBreakpoints request
+"""
+
+
+import dap_server
+import shutil
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import line_number
+from lldbsuite.test import lldbutil
+import lldbdap_testcase
+import os
+
+
+class TestDAP_setBreakpointsAssembly(lldbdap_testcase.DAPTestCaseBase):
+# @skipIfWindows
+def test_functionality(self):
+"""Tests hitting assembly source breakpoints"""
+program = self.getBuildArtifact("a.out")
+self.build_and_launch(program)
+
+self.dap_server.request_evaluate(
+"`settings set stop-disassembly-display no-debuginfo", 
context="repl"
+)
+
+finish_line = line_number("main.c", "// Break here")
+finish_breakpoints = self.set_source_breakpoints("main.c", 
[finish_line])
+
+assmebly_func_breakpoints = 
self.set_function_breakpoints(["assembly_func"])
+self.continue_to_breakpoints(assmebly_func_breakpoints)
+
+assembly_func_frame = self.get_stackFrames()[0]
+self.assertIn(
+"sourceReference",
+assembly_func_frame.get("source"),
+"Expected assembly source frame",
+)
+
+line = assembly_func_frame["line"]
+
+# Set an assembly breakpoint in the next line and check that it's hit
+source_reference = assembly_func_frame["source"]["sourceReference"]
+assembly_breakpoint_ids = self.set_source_breakpoints_assembly(
+source_reference, [line + 1]
+)
+self.continue_to_breakpoints(assembly_breakpoint_ids)
+
+# Continue again and verify it hits in the next function call
+self.continue_to_breakpoints(assmebly_func_breakpoints)
+self.continue_to_breakpoints(assembly_breakpoint_ids)
+
+# Clear the breakpoint and then check that the assembly breakpoint 
does not hit next time
+self.set_source_breakpoints_assembly(source_reference, [])
+self.continue_to_breakpoints(assmebly_func_breakpoints)
+self.continue_to_breakpoints(finish_breakpoints)

eronnen wrote:

:100: 

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread Ely Ronnen via lldb-commits


@@ -72,21 +99,29 @@ BreakpointLocationsRequestHandler::Run(
 }
   }
 
-  // The line entries are sorted by addresses, but we must return the list
-  // ordered by line / column position.
-  std::sort(locations.begin(), locations.end());
-  locations.erase(llvm::unique(locations), locations.end());
+  return locations;
+}
 
-  std::vector breakpoint_locations;
-  for (auto &l : locations) {
-protocol::BreakpointLocation lc;
-lc.line = l.first;
-lc.column = l.second;
-breakpoint_locations.push_back(std::move(lc));
+std::vector>
+BreakpointLocationsRequestHandler::GetAssemblyBreakpointLocations(
+int64_t sourceReference, uint32_t start_line, uint32_t end_line) const {

eronnen wrote:

:100: 

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread Ely Ronnen via lldb-commits


@@ -72,21 +99,29 @@ BreakpointLocationsRequestHandler::Run(
 }
   }
 
-  // The line entries are sorted by addresses, but we must return the list
-  // ordered by line / column position.
-  std::sort(locations.begin(), locations.end());
-  locations.erase(llvm::unique(locations), locations.end());
+  return locations;
+}
 
-  std::vector breakpoint_locations;
-  for (auto &l : locations) {
-protocol::BreakpointLocation lc;
-lc.line = l.first;
-lc.column = l.second;
-breakpoint_locations.push_back(std::move(lc));
+std::vector>
+BreakpointLocationsRequestHandler::GetAssemblyBreakpointLocations(
+int64_t sourceReference, uint32_t start_line, uint32_t end_line) const {
+  std::vector> locations;
+  lldb::SBAddress address(sourceReference, dap.target);
+  if (!address.IsValid())
+return locations;
+
+  lldb::SBSymbol symbol = address.GetSymbol();

eronnen wrote:

@da-viper not sure I understand, why is `GetFunction` needed before getting the 
symbol?

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] Migrate disassemble request to structured handler (PR #140482)

2025-05-19 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/140482
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][nfc]Make test "xfail" on windows (PR #140588)

2025-05-19 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

https://lab.llvm.org/buildbot/#/builders/197/builds/5542 is broken.

Probably you must use `XFAIL: target-windows` instead of `XFAIL: 
system-windows`.

https://github.com/llvm/llvm-project/pull/140588
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread Ely Ronnen via lldb-commits


@@ -34,26 +36,22 @@ SourceRequestHandler::Run(const protocol::SourceArguments 
&args) const {
 return llvm::make_error(
 "invalid arguments, expected source.sourceReference to be set");
 
-  lldb::SBProcess process = dap.target.GetProcess();
-  // Upper 32 bits is the thread index ID
-  lldb::SBThread thread =
-  process.GetThreadByIndexID(GetLLDBThreadIndexID(source));
-  // Lower 32 bits is the frame index
-  lldb::SBFrame frame = thread.GetFrameAtIndex(GetLLDBFrameID(source));
-  if (!frame.IsValid())
+  lldb::SBAddress address(source, dap.target);
+  if (!address.IsValid())
 return llvm::make_error("source not found");
 
+  lldb::SBSymbol symbol = address.GetSymbol();
+
   lldb::SBStream stream;
-  lldb::SBExecutionContext exe_ctx(frame);
-  lldb::SBSymbol symbol = frame.GetSymbol();
+  lldb::SBExecutionContext exe_ctx(dap.target);
 
   if (symbol.IsValid()) {

eronnen wrote:

also here I'm not sure what it's needed for, isn't the `SBExecutionContext` 
sufficient currently?

https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen edited 
https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb-dap] assembly breakpoints (PR #139969)

2025-05-19 Thread Ely Ronnen via lldb-commits

https://github.com/eronnen deleted 
https://github.com/llvm/llvm-project/pull/139969
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [lldb][nfc]Make test "xfail" on windows (PR #140588)

2025-05-19 Thread Vy Nguyen via lldb-commits

oontvoo wrote:

fixing now. thanks!

https://github.com/llvm/llvm-project/pull/140588
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


  1   2   >