[Lldb-commits] [lldb] [lldb-dap] Enabling instruction breakpoint support to lldb-dap. (PR #105278)

2024-08-27 Thread David Spickett via lldb-commits

DavidSpickett wrote:

The rest of the tests are disabled on Windows, this one should be too.

One of these days I'll figure out what's wrong with them all.

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


[Lldb-commits] [lldb] [lldb-dap] Enabling instruction breakpoint support to lldb-dap. (PR #105278)

2024-08-27 Thread Santhosh Kumar Ellendula via lldb-commits

santhoshe447 wrote:

> The rest of the lldb-dap tests are disabled on Windows, this one should be 
> too.
> 
> One of these days I'll figure out what's wrong with them all.

Thanks,
I have submitted the PR for this.
https://github.com/llvm/llvm-project/pull/106200

https://github.com/llvm/llvm-project/pull/105278
___
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 for TestDAP_instruction_breakpoint.py test failure on windows. (PR #106200)

2024-08-27 Thread Santhosh Kumar Ellendula via lldb-commits

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Fix for TestDAP_instruction_breakpoint.py test failure on windows. (PR #106200)

2024-08-27 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] fbef4c2 - [lldb][lldb-dap] Fix for TestDAP_instruction_breakpoint.py test failure on windows. (#106200)

2024-08-27 Thread via lldb-commits

Author: Santhosh Kumar Ellendula
Date: 2024-08-27T10:31:18+01:00
New Revision: fbef4c2d31d1e3d1e5f7e285fdf397aeb161

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

LOG: [lldb][lldb-dap] Fix for TestDAP_instruction_breakpoint.py test failure on 
windows. (#106200)

TestDAP_instruction_breakpoint.py failed on windows, so these tests were
skipped for windows build.

-

Co-authored-by: Santhosh Kumar Ellendula 
Co-authored-by: Santhosh Kumar Ellendula 

Added: 


Modified: 

lldb/test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py

Removed: 




diff  --git 
a/lldb/test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py
 
b/lldb/test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py
index 91b04aca7b7bd8..3862be7bfa34c2 100644
--- 
a/lldb/test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py
+++ 
b/lldb/test/API/tools/lldb-dap/instruction-breakpoint/TestDAP_instruction_breakpoint.py
@@ -17,6 +17,7 @@ def setUp(self):
 self.main_basename = "main-copy.cpp"
 self.main_path = 
os.path.realpath(self.getBuildArtifact(self.main_basename))
 
+@skipIfWindows
 def test_instruction_breakpoint(self):
 self.build()
 self.instruction_breakpoint_test()



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


[Lldb-commits] [lldb] [lldb][lldb-dap] Fix for TestDAP_instruction_breakpoint.py test failure on windows. (PR #106200)

2024-08-27 Thread David Spickett via lldb-commits

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


[Lldb-commits] [lldb] [lldb][lldb-dap] Fix for TestDAP_instruction_breakpoint.py test failure on windows. (PR #106200)

2024-08-27 Thread David Spickett via lldb-commits

DavidSpickett wrote:

Thanks!

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


[Lldb-commits] [lldb] [lldb] unique_ptr-ify some GetUserExpression APIs. (PR #106034)

2024-08-27 Thread Pavel Labath via lldb-commits

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


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


[Lldb-commits] [lldb] ca3b9af - Add logs for SymbolFileDWARF::FindTypes (#106030)

2024-08-27 Thread via lldb-commits

Author: Dmitrii Galimzianov
Date: 2024-08-27T10:41:09+01:00
New Revision: ca3b9af98c0b119598bc26a9130f468b196d83b3

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

LOG: Add logs for SymbolFileDWARF::FindTypes (#106030)

`SymbolFileDWARF::FindTypes` was logged prior to [this
commit](https://github.com/llvm/llvm-project/commit/dd9587795811ba21e6ca6ad52b4531e17e6babd6#diff-edef3a65d5d569bbb75a4158d35b827aa5d42ee03ccd3b0c1d4f354afa12210c).
This is a helpful log message for checking for redundant type searches

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 7e0cf36d0de1b8..d887d81912b27e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -2737,10 +2737,19 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
   if (results.AlreadySearched(this))
 return;
 
+  auto type_basename = query.GetTypeBasename();
+
+  Log *log = GetLog(DWARFLog::Lookups);
+  if (log) {
+GetObjectFile()->GetModule()->LogMessage(
+log, "SymbolFileDWARF::FindTypes(type_basename=\"{0}\")",
+type_basename);
+  }
+
   std::lock_guard guard(GetModuleMutex());
 
   bool have_index_match = false;
-  m_index->GetTypes(query.GetTypeBasename(), [&](DWARFDIE die) {
+  m_index->GetTypes(type_basename, [&](DWARFDIE die) {
 // Check the language, but only if we have a language filter.
 if (query.HasLanguage()) {
   if (!query.LanguageMatches(GetLanguageFamily(*die.GetCU(
@@ -2779,8 +2788,14 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
 return !results.Done(query); // Keep iterating if we aren't done.
   });
 
-  if (results.Done(query))
+  if (results.Done(query)) {
+if (log) {
+  GetObjectFile()->GetModule()->LogMessage(
+  log, "SymbolFileDWARF::FindTypes(type_basename=\"{0}\") => {1}",
+  type_basename, results.GetTypeMap().GetSize());
+}
 return;
+  }
 
   // With -gsimple-template-names, a templated type's DW_AT_name will not
   // contain the template parameters. Try again stripping '<' and anything
@@ -2795,10 +2810,10 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
 // it trims any context items down by removing template parameter names.
 TypeQuery query_simple(query);
 if (UpdateCompilerContextForSimpleTemplateNames(query_simple)) {
-
+  auto type_basename_simple = query_simple.GetTypeBasename();
   // Copy our match's context and update the basename we are looking for
   // so we can use this only to compare the context correctly.
-  m_index->GetTypes(query_simple.GetTypeBasename(), [&](DWARFDIE die) {
+  m_index->GetTypes(type_basename_simple, [&](DWARFDIE die) {
 // Check the language, but only if we have a language filter.
 if (query.HasLanguage()) {
   if (!query.LanguageMatches(GetLanguageFamily(*die.GetCU(
@@ -2834,8 +2849,17 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
 }
 return !results.Done(query); // Keep iterating if we aren't done.
   });
-  if (results.Done(query))
+  if (results.Done(query)) {
+if (log) {
+  GetObjectFile()->GetModule()->LogMessage(
+  log,
+  "SymbolFileDWARF::FindTypes(type_basename=\"{0}\") => {1} "
+  "(simplified as \"{2}\")",
+  type_basename, results.GetTypeMap().GetSize(),
+  type_basename_simple);
+}
 return;
+  }
 }
   }
 
@@ -2847,8 +2871,11 @@ void SymbolFileDWARF::FindTypes(const TypeQuery &query, 
TypeResults &results) {
   for (const auto &pair : m_external_type_modules) {
 if (ModuleSP external_module_sp = pair.second) {
   external_module_sp->FindTypes(query, results);
-  if (results.Done(query))
+  if (results.Done(query)) {
+// We don't log the results here as they are already logged in the
+// nested FindTypes call
 return;
+  }
 }
   }
 }



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


[Lldb-commits] [lldb] Add logs for SymbolFileDWARF::FindTypes (PR #106030)

2024-08-27 Thread Michael Buch via lldb-commits

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


[Lldb-commits] [lldb] Add logs for SymbolFileDWARF::FindTypes (PR #106030)

2024-08-27 Thread via lldb-commits

github-actions[bot] wrote:



@DmT021 Congratulations on having your first Pull Request (PR) merged into the 
LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested by our [build bots](https://lab.llvm.org/buildbot/). If there is a 
problem with a build, you may receive a report in an email or a comment on this 
PR.

Please check whether problems have been caused by your change specifically, as 
the builds can include changes from many authors. It is not uncommon for your 
change to be included in a build that fails due to someone else's changes, or 
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself. This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


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


[Lldb-commits] [clang] [lldb] [llvm] [ARM] musttail fixes (PR #102896)

2024-08-27 Thread via lldb-commits

https://github.com/kiran-isaac updated 
https://github.com/llvm/llvm-project/pull/102896

>From 24806b179d34b4afb21832e4a2150c13995b59e0 Mon Sep 17 00:00:00 2001
From: Kiran 
Date: Thu, 8 Aug 2024 13:07:24 +0100
Subject: [PATCH 1/4] [ARM] musttail fixes

Backend:
- Caller and callee arguments no longer have to match, just to take up the same 
space, as they can be changed before the call
- Allowed tail calls if callee and callee both (or neither) use sret, wheras 
before it would be dissalowed if either used sret
- Allowed tail calls if byval args are used
- Added debug trace for IsEligibleForTailCallOptimisation

Frontend (clang):
- Do not generate extra alloca if sret is used with musttail, as the space for 
the sret is allocated already

Change-Id: Ic7f246a7eca43c06874922d642d7dc44bdfc98ec
---
 clang/lib/CodeGen/CGCall.cpp  |   2 +-
 llvm/include/llvm/CodeGen/CallingConvLower.h  |   2 +
 llvm/lib/CodeGen/CallingConvLower.cpp |  61 +++
 llvm/lib/Target/ARM/ARMISelLowering.cpp   | 141 ++
 .../ARM/2013-05-13-AAPCS-byval-padding.ll |  16 +-
 .../ARM/2013-05-13-AAPCS-byval-padding2.ll|  13 +-
 llvm/test/CodeGen/ARM/fp-arg-shuffle.ll   |  22 +
 llvm/test/CodeGen/ARM/fp16-vector-argument.ll |  41 +-
 llvm/test/CodeGen/ARM/struct_byval.ll | 455 --
 llvm/test/CodeGen/ARM/tail-call-float.ll  |  99 +++-
 10 files changed, 661 insertions(+), 191 deletions(-)

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 070001a180ab88..1144de0b6ba7b5 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5085,7 +5085,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   RawAddress SRetAlloca = RawAddress::invalid();
   llvm::Value *UnusedReturnSizePtr = nullptr;
   if (RetAI.isIndirect() || RetAI.isInAlloca() || RetAI.isCoerceAndExpand()) {
-if (IsVirtualFunctionPointerThunk && RetAI.isIndirect()) {
+if ((IsVirtualFunctionPointerThunk || IsMustTail) && RetAI.isIndirect()) {
   SRetPtr = makeNaturalAddressForPointer(CurFn->arg_begin() +
  IRFunctionArgs.getSRetArgNo(),
  RetTy, 
CharUnits::fromQuantity(1));
diff --git a/llvm/include/llvm/CodeGen/CallingConvLower.h 
b/llvm/include/llvm/CodeGen/CallingConvLower.h
index 932a2a94ab1f1a..fdb5982cb2042b 100644
--- a/llvm/include/llvm/CodeGen/CallingConvLower.h
+++ b/llvm/include/llvm/CodeGen/CallingConvLower.h
@@ -540,6 +540,8 @@ class CCState {
});
   }
 
+  void dump() const;
+
 private:
   /// MarkAllocated - Mark a register and all of its aliases as allocated.
   void MarkAllocated(MCPhysReg Reg);
diff --git a/llvm/lib/CodeGen/CallingConvLower.cpp 
b/llvm/lib/CodeGen/CallingConvLower.cpp
index b7152587a9fa05..7ba3ea83115db2 100644
--- a/llvm/lib/CodeGen/CallingConvLower.cpp
+++ b/llvm/lib/CodeGen/CallingConvLower.cpp
@@ -290,3 +290,64 @@ bool CCState::resultsCompatible(CallingConv::ID CalleeCC,
   return std::equal(RVLocs1.begin(), RVLocs1.end(), RVLocs2.begin(),
 RVLocs2.end(), AreCompatible);
 }
+
+void CCState::dump() const {
+  dbgs() << "CCState:\n";
+  for (const CCValAssign &Loc : Locs) {
+if (Loc.isRegLoc()) {
+  dbgs() << "  Reg " << TRI.getName(Loc.getLocReg());
+} else if (Loc.isMemLoc()) {
+  dbgs() << "  Mem " << Loc.getLocMemOffset();
+} else {
+  assert(Loc.isPendingLoc());
+  dbgs() << "  Pend " << Loc.getExtraInfo();
+}
+
+dbgs() << " ValVT:" << Loc.getValVT();
+dbgs() << " LocVT:" << Loc.getLocVT();
+
+if (Loc.needsCustom())
+  dbgs() << " custom";
+
+switch (Loc.getLocInfo()) {
+case CCValAssign::Full:
+  dbgs() << " Full";
+  break;
+case CCValAssign::SExt:
+  dbgs() << " SExt";
+  break;
+case CCValAssign::ZExt:
+  dbgs() << " ZExt";
+  break;
+case CCValAssign::AExt:
+  dbgs() << " AExt";
+  break;
+case CCValAssign::SExtUpper:
+  dbgs() << " SExtUpper";
+  break;
+case CCValAssign::ZExtUpper:
+  dbgs() << " ZExtUpper";
+  break;
+case CCValAssign::AExtUpper:
+  dbgs() << " AExtUpper";
+  break;
+case CCValAssign::BCvt:
+  dbgs() << " BCvt";
+  break;
+case CCValAssign::Trunc:
+  dbgs() << " Trunc";
+  break;
+case CCValAssign::VExt:
+  dbgs() << " VExt";
+  break;
+case CCValAssign::FPExt:
+  dbgs() << " FPExt";
+  break;
+case CCValAssign::Indirect:
+  dbgs() << " Indirect";
+  break;
+}
+
+dbgs() << "\n";
+  }
+}
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp 
b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 476b7b349294ab..aeba673f9a2f77 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -2407,8 +2407,8 @@ 
ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
 isTailCall = false;
 
   // For both t

[Lldb-commits] [lldb] [lldb] Add 'FindInMemory()' overload for PostMortemProcess. (PR #102536)

2024-08-27 Thread Pavel Labath via lldb-commits

labath wrote:

> Let me know if you guys don't want this patch in. I will closed it and apply 
> it to our local branch. @jasonmolenda @labath

Without claiming official authority to make this decision, I'm going to say 
that *I* don't think this is a good idea, because the patch is very (and IMO, 
unnecessarily) specific to post mortem processes. My (currently WIP) patch 
(#104193) gets you most of the speed benefits, works with live processes as 
well and it does that without introducing any new APIs.

What you do downstream is up to you, but I would encourage you to wait for me 
to finish up that patch, as this doesn't look like something that would be a 
good idea to carry downstream (I certainly wouldn't want to do it).

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Michael Buch via lldb-commits


@@ -39,8 +39,8 @@ using namespace lldb_private;
 
 Status::Status() : m_string() {}
 
-Status::Status(ValueType err, ErrorType type)
-: m_code(err), m_type(type), m_string() {}
+Status::Status(ValueType err, ErrorType type, llvm::StringRef msg)

Michael137 wrote:

```suggestion
Status::Status(ValueType err, ErrorType type, std::string msg)
```
If you're going to sink it into `m_string` anyway?

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Michael Buch via lldb-commits


@@ -51,13 +51,13 @@ Status::Status(std::error_code EC)
   : eErrorTypeGeneric),
   m_string(EC.message()) {}
 
-Status::Status(const char *format, ...) : m_string() {
-  va_list args;
-  va_start(args, format);
-  SetErrorToGenericError();
-  SetErrorStringWithVarArg(format, args);
-  va_end(args);
-}
+Status::Status(std::string &&err_str)
+: m_code(LLDB_GENERIC_ERROR), m_type(eErrorTypeGeneric),
+  m_string(std::move(err_str)) {}
+
+Status::Status(llvm::StringRef err_str)

Michael137 wrote:

Do we need this constructor?

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Michael Buch via lldb-commits


@@ -51,13 +51,13 @@ Status::Status(std::error_code EC)
   : eErrorTypeGeneric),
   m_string(EC.message()) {}
 
-Status::Status(const char *format, ...) : m_string() {
-  va_list args;
-  va_start(args, format);
-  SetErrorToGenericError();
-  SetErrorStringWithVarArg(format, args);
-  va_end(args);
-}
+Status::Status(std::string &&err_str)

Michael137 wrote:

Why `std::string&&`? Looks like in a lot of the cases you're going to have to 
do a c-str -> std::string conversion anyway? For the 
`FromErrorStringWithFormat` where you construct `Status` with an l-value 
string, you're actually silently copying (because this `std::string&&` overload 
isn't picked, instead it picks the `llvm::StringRef` constructor, and copies 
the string).

All this might just be easier to reason about if you make it a by-value 
argument, for all cases. And the double-move (for std::move 
construction+std::move from the argument is probably not worth optimizing away 
by-hand?).

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Pavel Labath via lldb-commits

labath wrote:

I like this. I have just two remarks:
- it might be better to split this into three steps (add new APIs, port to new 
APIs, remove old APIs), as that will make reverts easier/less disruptive (I 
don't know how much we can trust pre-commit CI these days, but I wouldn't be 
surprised if this breaks some platform-specific code).
- since this seems like a perfect opportunity to bikesh^Wdiscuss the names, I'm 
going to ask if there's any appetite for shortening some of the new factory 
functions. `Status::FromErrorStringWithFormatv` is a bit of a mouthful, so I 
was thinking if we could  use something shorter instead (`Status::FromFormatv` 
or even `Status::Formatv`) ?

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


[Lldb-commits] [lldb] [lldb] Updated TCPSocket to listen multiple ports on the same single thread (PR #104797)

2024-08-27 Thread Pavel Labath via lldb-commits

labath wrote:

Having a single socket listen on multiple ports sounds like a bad idea to me. 
The socket class is complicated enough as it is, and it's not the way the 
MainLoop class was meant to be used (the idea being for it to be created at the 
topmost level possible, so that any number of users could register their 
handlers).

I think that a better and more versatile API would be something like:
```
std::vector /*or sth like that*/ 
TCPSocket::Accept(MainLoop &mainloop, 
std::function accepted_socket)> /*or similar*/ 
socket_cb);
```

Then we could create two sockets and have them listen on the same main loop 
instance. It should be possible to reimplement the existing TCPSocket::Accept 
function on top of this API.

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


[Lldb-commits] [lldb] [lldb] Updated TCPSocket to listen multiple ports on the same single thread (PR #104797)

2024-08-27 Thread Dmitry Vasilyev via lldb-commits

slydiman wrote:

@labath 
> Having a single socket listen on multiple ports sounds like a bad idea to me. 

Note that currently the class TCPSocket already contains a list of NativeSocket 
`m_listen_sockets`. 
We do not need 2 TCPSocket instances with 2 separated lists of native sockets 
even with a common MainLoop.

We have 2 options:
- A) 2 threads - first one calls TCPSocket::Accept() for the platform 
connection, second calls TCPSocket::Accept() for the gdb connection
- B) 1 thread - a common TCPSocket::Accept() can accept platform and gdb 
connections from both ports

You don't like multithreading. So I implemented the option B. It was easy 
because the class TCPSocket already contains  `m_listen_sockets`. 

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


[Lldb-commits] [lldb] d517b22 - [LLDB][SBSaveCore] Add selectable memory regions to SBSaveCore (#105442)

2024-08-27 Thread via lldb-commits

Author: Jacob Lalonde
Date: 2024-08-27T07:33:12-07:00
New Revision: d517b224117f760e6a7299b267256e3240c04edb

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

LOG: [LLDB][SBSaveCore] Add selectable memory regions to SBSaveCore (#105442)

This patch adds the option to specify specific memory ranges to be
included in a given core file. The current implementation lets user
specified ranges either be in addition to a certain save style, or
independent of them via the newly added custom enum.

To achieve being inclusive of save style, I've moved from a std::vector
of ranges to a RangeDataVector, and to join overlapping ranges to
prevent duplication of memory ranges in the core file.

As a non function bonus, when SBSavecore was initially created, the
header was included in the lldb-private interfaces, and I've fixed that
and moved it the forward declare as an oversight. CC @bulbazord in case
we need to include that into swift.

Added: 


Modified: 
lldb/include/lldb/API/SBMemoryRegionInfo.h
lldb/include/lldb/API/SBSaveCoreOptions.h
lldb/include/lldb/Symbol/SaveCoreOptions.h
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Utility/RangeMap.h
lldb/include/lldb/lldb-enumerations.h
lldb/include/lldb/lldb-forward.h
lldb/include/lldb/lldb-private-interfaces.h
lldb/source/API/SBSaveCoreOptions.cpp
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
lldb/source/Symbol/SaveCoreOptions.cpp
lldb/source/Target/Process.cpp

lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py

Removed: 




diff  --git a/lldb/include/lldb/API/SBMemoryRegionInfo.h 
b/lldb/include/lldb/API/SBMemoryRegionInfo.h
index be55de4ead1fa8..f9a5dc993d7cb6 100644
--- a/lldb/include/lldb/API/SBMemoryRegionInfo.h
+++ b/lldb/include/lldb/API/SBMemoryRegionInfo.h
@@ -120,7 +120,7 @@ class LLDB_API SBMemoryRegionInfo {
 private:
   friend class SBProcess;
   friend class SBMemoryRegionInfoList;
-
+  friend class SBSaveCoreOptions;
   friend class lldb_private::ScriptInterpreter;
 
   lldb_private::MemoryRegionInfo &ref();

diff  --git a/lldb/include/lldb/API/SBSaveCoreOptions.h 
b/lldb/include/lldb/API/SBSaveCoreOptions.h
index ba48ba5eaea5a0..c076d3ce6f7575 100644
--- a/lldb/include/lldb/API/SBSaveCoreOptions.h
+++ b/lldb/include/lldb/API/SBSaveCoreOptions.h
@@ -80,6 +80,17 @@ class LLDB_API SBSaveCoreOptions {
   /// \return True if the thread was removed, false if it was not in the list.
   bool RemoveThread(lldb::SBThread thread);
 
+  /// Add a memory region to save in the core file.
+  ///
+  /// \param region The memory region to save.
+  /// \returns An empty SBError upon success, or an error if the region is
+  /// invalid.
+  /// \note Ranges that overlapped will be unioned into a single region, this
+  /// also supercedes stack minification. Specifying full regions and a
+  /// non-custom core style will include the specified regions and union them
+  /// with all style specific regions.
+  SBError AddMemoryRegionToSave(const SBMemoryRegionInfo ®ion);
+
   /// Reset all options.
   void Clear();
 

diff  --git a/lldb/include/lldb/Symbol/SaveCoreOptions.h 
b/lldb/include/lldb/Symbol/SaveCoreOptions.h
index f4fed4676fa4ae..d90d08026016dc 100644
--- a/lldb/include/lldb/Symbol/SaveCoreOptions.h
+++ b/lldb/include/lldb/Symbol/SaveCoreOptions.h
@@ -10,13 +10,15 @@
 #define LLDB_SOURCE_PLUGINS_OBJECTFILE_SaveCoreOPTIONS_H
 
 #include "lldb/Utility/FileSpec.h"
-#include "lldb/lldb-forward.h"
-#include "lldb/lldb-types.h"
+#include "lldb/Utility/RangeMap.h"
 
 #include 
+#include 
 #include 
 #include 
 
+using MemoryRanges = lldb_private::RangeVector;
+
 namespace lldb_private {
 
 class SaveCoreOptions {
@@ -38,8 +40,12 @@ class SaveCoreOptions {
   Status AddThread(lldb::ThreadSP thread_sp);
   bool RemoveThread(lldb::ThreadSP thread_sp);
   bool ShouldThreadBeSaved(lldb::tid_t tid) const;
+  bool HasSpecifiedThreads() const;
 
   Status EnsureValidConfiguration(lldb::ProcessSP process_sp) const;
+  const MemoryRanges &GetCoreFileMemoryRanges() const;
+
+  void AddMemoryRegionToSave(const lldb_private::MemoryRegionInfo ®ion);
 
   void Clear();
 
@@ -51,6 +57,7 @@ class SaveCoreOptions {
   std::optional m_style;
   lldb::ProcessSP m_process_sp;
   std::unordered_set m_threads_to_save;
+  MemoryRanges m_regi

[Lldb-commits] [lldb] [LLDB][SBSaveCore] Add selectable memory regions to SBSaveCore (PR #105442)

2024-08-27 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [lldb] [lldb][WIP] memory find speedup+bugfix (PR #104193)

2024-08-27 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/104193

>From b46820a91f1ad8d6db46210e3135abdb1ab475e8 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 14 Aug 2024 19:58:27 +0200
Subject: [PATCH] [lldb] Fix and speedup the `memory find` command

This patch fixes an issue where the `memory find` command would
effectively stop searching after encountering a memory read error (which
could happen due to unreadable memory), without giving any indication
that it has done so (it would just print it could not find the pattern).

To make matters worse, it would not terminate after encountering this
error, but rather proceed to slowly increment the address pointer, which
meant that searching a large region could take a very long time (and
give the appearance that lldb is actually searching for the thing).

The patch fixes this first problem (*) by detecting read errors and
skipping over (using GetMemoryRegionInfo) the unreadable parts of memory
and resuming the search after them. It also reads the memory in bulk (up
to 1MB), which speeds up the search significantly (up to 6x for live
processes, 18x for core files).

(*) The fix does not work on windows yet, because the ReadMemory API
does not return partial results (like it does for other systems). I'm
preparing a separate patch to deal with that.
---
 lldb/source/Target/Process.cpp| 68 +++
 .../memory/find/TestMemoryFind.py | 25 +-
 .../API/functionalities/memory/find/main.cpp  | 83 +--
 3 files changed, 131 insertions(+), 45 deletions(-)

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index b2a0f13b9a1549..5d066d264bd3f5 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -114,33 +114,6 @@ class ProcessOptionValueProperties
   }
 };
 
-class ProcessMemoryIterator {
-public:
-  ProcessMemoryIterator(Process &process, lldb::addr_t base)
-  : m_process(process), m_base_addr(base) {}
-
-  bool IsValid() { return m_is_valid; }
-
-  uint8_t operator[](lldb::addr_t offset) {
-if (!IsValid())
-  return 0;
-
-uint8_t retval = 0;
-Status error;
-if (0 == m_process.ReadMemory(m_base_addr + offset, &retval, 1, error)) {
-  m_is_valid = false;
-  return 0;
-}
-
-return retval;
-  }
-
-private:
-  Process &m_process;
-  const lldb::addr_t m_base_addr;
-  bool m_is_valid = true;
-};
-
 static constexpr OptionEnumValueElement g_follow_fork_mode_values[] = {
 {
 eFollowParent,
@@ -3367,21 +3340,48 @@ lldb::addr_t Process::FindInMemory(lldb::addr_t low, 
lldb::addr_t high,
   if (region_size < size)
 return LLDB_INVALID_ADDRESS;
 
+  // See "Boyer-Moore string search algorithm".
   std::vector bad_char_heuristic(256, size);
-  ProcessMemoryIterator iterator(*this, low);
-
   for (size_t idx = 0; idx < size - 1; idx++) {
 decltype(bad_char_heuristic)::size_type bcu_idx = buf[idx];
 bad_char_heuristic[bcu_idx] = size - idx - 1;
   }
-  for (size_t s = 0; s <= (region_size - size);) {
+
+  // Memory we're currently searching through.
+  llvm::SmallVector mem;
+  // Position of the memory buffer.
+  addr_t mem_pos = low;
+  // Maximum number of bytes read (and buffered). We need to read at least
+  // `size` bytes for a successful match.
+  const size_t max_read_size = std::max(size, 0x1);
+
+  for (addr_t s = low; s <= (high - size);) {
+if (s + size > mem.size() + mem_pos) {
+  // We need to read more data. We don't attempt to reuse the data we've
+  // already read (up to `size-1` bytes from `s` to `mem_pos+mem.size()`).
+  // This is fine for patterns much smaller than max_read_size. For very
+  // long patterns we may need to do something more elaborate.
+  mem.resize_for_overwrite(max_read_size);
+  Status error;
+  mem.resize(
+  ReadMemory(s, mem.data(), std::min(mem.size(), high - s), error));
+  mem_pos = s;
+  if (error.Fail() || size > mem.size()) {
+// We didn't read enough data. Skip to the next memory region.
+MemoryRegionInfo info;
+error = GetMemoryRegionInfo(mem_pos + mem.size(), info);
+if (error.Fail())
+  break;
+s = info.GetRange().GetRangeEnd();
+continue;
+  }
+}
 int64_t j = size - 1;
-while (j >= 0 && buf[j] == iterator[s + j])
+while (j >= 0 && buf[j] == mem[s + j - mem_pos])
   j--;
 if (j < 0)
-  return low + s;
-else
-  s += bad_char_heuristic[iterator[s + size - 1]];
+  return s; // We have a match.
+s += bad_char_heuristic[mem[s + size - 1 - mem_pos]];
   }
 
   return LLDB_INVALID_ADDRESS;
diff --git a/lldb/test/API/functionalities/memory/find/TestMemoryFind.py 
b/lldb/test/API/functionalities/memory/find/TestMemoryFind.py
index 09611cc808777d..88fbd0c192a58e 100644
--- a/lldb/test/API/functionalities/memory/find/TestMemoryFind.py
+++ b/lldb/test/API/functionalities/memory/find/Tes

[Lldb-commits] [lldb] [lldb][WIP] memory find speedup+bugfix (PR #104193)

2024-08-27 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix and speedup the `memory find` command (PR #104193)

2024-08-27 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix and speedup the `memory find` command (PR #104193)

2024-08-27 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/104193

>From 7b8b8b699902d2365ea43e5ae015546c4d20fac8 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 14 Aug 2024 19:58:27 +0200
Subject: [PATCH] [lldb] Fix and speedup the `memory find` command

This patch fixes an issue where the `memory find` command would
effectively stop searching after encountering a memory read error (which
could happen due to unreadable memory), without giving any indication
that it has done so (it would just print it could not find the pattern).

To make matters worse, it would not terminate after encountering this
error, but rather proceed to slowly increment the address pointer, which
meant that searching a large region could take a very long time (and
give the appearance that lldb is actually searching for the thing).

The patch fixes this first problem (*) by detecting read errors and
skipping over (using GetMemoryRegionInfo) the unreadable parts of memory
and resuming the search after them. It also reads the memory in bulk (up
to 1MB), which speeds up the search significantly (up to 6x for live
processes, 18x for core files).

(*) The fix does not work on windows yet, because the ReadMemory API
does not return partial results (like it does for other systems). I'm
preparing a separate patch to deal with that.
---
 lldb/source/Target/Process.cpp| 68 +++
 .../memory/find/TestMemoryFind.py | 30 ++-
 .../API/functionalities/memory/find/main.cpp  | 83 +--
 3 files changed, 136 insertions(+), 45 deletions(-)

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index b2a0f13b9a1549..5d066d264bd3f5 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -114,33 +114,6 @@ class ProcessOptionValueProperties
   }
 };
 
-class ProcessMemoryIterator {
-public:
-  ProcessMemoryIterator(Process &process, lldb::addr_t base)
-  : m_process(process), m_base_addr(base) {}
-
-  bool IsValid() { return m_is_valid; }
-
-  uint8_t operator[](lldb::addr_t offset) {
-if (!IsValid())
-  return 0;
-
-uint8_t retval = 0;
-Status error;
-if (0 == m_process.ReadMemory(m_base_addr + offset, &retval, 1, error)) {
-  m_is_valid = false;
-  return 0;
-}
-
-return retval;
-  }
-
-private:
-  Process &m_process;
-  const lldb::addr_t m_base_addr;
-  bool m_is_valid = true;
-};
-
 static constexpr OptionEnumValueElement g_follow_fork_mode_values[] = {
 {
 eFollowParent,
@@ -3367,21 +3340,48 @@ lldb::addr_t Process::FindInMemory(lldb::addr_t low, 
lldb::addr_t high,
   if (region_size < size)
 return LLDB_INVALID_ADDRESS;
 
+  // See "Boyer-Moore string search algorithm".
   std::vector bad_char_heuristic(256, size);
-  ProcessMemoryIterator iterator(*this, low);
-
   for (size_t idx = 0; idx < size - 1; idx++) {
 decltype(bad_char_heuristic)::size_type bcu_idx = buf[idx];
 bad_char_heuristic[bcu_idx] = size - idx - 1;
   }
-  for (size_t s = 0; s <= (region_size - size);) {
+
+  // Memory we're currently searching through.
+  llvm::SmallVector mem;
+  // Position of the memory buffer.
+  addr_t mem_pos = low;
+  // Maximum number of bytes read (and buffered). We need to read at least
+  // `size` bytes for a successful match.
+  const size_t max_read_size = std::max(size, 0x1);
+
+  for (addr_t s = low; s <= (high - size);) {
+if (s + size > mem.size() + mem_pos) {
+  // We need to read more data. We don't attempt to reuse the data we've
+  // already read (up to `size-1` bytes from `s` to `mem_pos+mem.size()`).
+  // This is fine for patterns much smaller than max_read_size. For very
+  // long patterns we may need to do something more elaborate.
+  mem.resize_for_overwrite(max_read_size);
+  Status error;
+  mem.resize(
+  ReadMemory(s, mem.data(), std::min(mem.size(), high - s), error));
+  mem_pos = s;
+  if (error.Fail() || size > mem.size()) {
+// We didn't read enough data. Skip to the next memory region.
+MemoryRegionInfo info;
+error = GetMemoryRegionInfo(mem_pos + mem.size(), info);
+if (error.Fail())
+  break;
+s = info.GetRange().GetRangeEnd();
+continue;
+  }
+}
 int64_t j = size - 1;
-while (j >= 0 && buf[j] == iterator[s + j])
+while (j >= 0 && buf[j] == mem[s + j - mem_pos])
   j--;
 if (j < 0)
-  return low + s;
-else
-  s += bad_char_heuristic[iterator[s + size - 1]];
+  return s; // We have a match.
+s += bad_char_heuristic[mem[s + size - 1 - mem_pos]];
   }
 
   return LLDB_INVALID_ADDRESS;
diff --git a/lldb/test/API/functionalities/memory/find/TestMemoryFind.py 
b/lldb/test/API/functionalities/memory/find/TestMemoryFind.py
index 09611cc808777d..72acfb3d600701 100644
--- a/lldb/test/API/functionalities/memory/find/TestMemoryFind.py
+++ b/lldb/test/API/functionalities/memory/find/Te

[Lldb-commits] [lldb] [lldb] Fix and speedup the `memory find` command (PR #104193)

2024-08-27 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix and speedup the `memory find` command (PR #104193)

2024-08-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Pavel Labath (labath)


Changes

This patch fixes an issue where the `memory find` command would
effectively stop searching after encountering a memory read error (which
could happen due to unreadable memory), without giving any indication
that it has done so (it would just print it could not find the pattern).

To make matters worse, it would not terminate after encountering this
error, but rather proceed to slowly increment the address pointer, which
meant that searching a large region could take a very long time (and
give the appearance that lldb is actually searching for the thing).

The patch fixes this first problem (*) by detecting read errors and
skipping over (using GetMemoryRegionInfo) the unreadable parts of memory
and resuming the search after them. It also reads the memory in bulk (up
to 1MB), which speeds up the search significantly (up to 6x for live
processes, 18x for core files).

(*) The fix does not work on windows yet, because the ReadMemory API
does not return partial results (like it does for other systems). I'm
preparing a separate patch to deal with that.


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


3 Files Affected:

- (modified) lldb/source/Target/Process.cpp (+34-34) 
- (modified) lldb/test/API/functionalities/memory/find/TestMemoryFind.py 
(+27-3) 
- (modified) lldb/test/API/functionalities/memory/find/main.cpp (+75-8) 


``diff
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index b2a0f13b9a1549..5d066d264bd3f5 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -114,33 +114,6 @@ class ProcessOptionValueProperties
   }
 };
 
-class ProcessMemoryIterator {
-public:
-  ProcessMemoryIterator(Process &process, lldb::addr_t base)
-  : m_process(process), m_base_addr(base) {}
-
-  bool IsValid() { return m_is_valid; }
-
-  uint8_t operator[](lldb::addr_t offset) {
-if (!IsValid())
-  return 0;
-
-uint8_t retval = 0;
-Status error;
-if (0 == m_process.ReadMemory(m_base_addr + offset, &retval, 1, error)) {
-  m_is_valid = false;
-  return 0;
-}
-
-return retval;
-  }
-
-private:
-  Process &m_process;
-  const lldb::addr_t m_base_addr;
-  bool m_is_valid = true;
-};
-
 static constexpr OptionEnumValueElement g_follow_fork_mode_values[] = {
 {
 eFollowParent,
@@ -3367,21 +3340,48 @@ lldb::addr_t Process::FindInMemory(lldb::addr_t low, 
lldb::addr_t high,
   if (region_size < size)
 return LLDB_INVALID_ADDRESS;
 
+  // See "Boyer-Moore string search algorithm".
   std::vector bad_char_heuristic(256, size);
-  ProcessMemoryIterator iterator(*this, low);
-
   for (size_t idx = 0; idx < size - 1; idx++) {
 decltype(bad_char_heuristic)::size_type bcu_idx = buf[idx];
 bad_char_heuristic[bcu_idx] = size - idx - 1;
   }
-  for (size_t s = 0; s <= (region_size - size);) {
+
+  // Memory we're currently searching through.
+  llvm::SmallVector mem;
+  // Position of the memory buffer.
+  addr_t mem_pos = low;
+  // Maximum number of bytes read (and buffered). We need to read at least
+  // `size` bytes for a successful match.
+  const size_t max_read_size = std::max(size, 0x1);
+
+  for (addr_t s = low; s <= (high - size);) {
+if (s + size > mem.size() + mem_pos) {
+  // We need to read more data. We don't attempt to reuse the data we've
+  // already read (up to `size-1` bytes from `s` to `mem_pos+mem.size()`).
+  // This is fine for patterns much smaller than max_read_size. For very
+  // long patterns we may need to do something more elaborate.
+  mem.resize_for_overwrite(max_read_size);
+  Status error;
+  mem.resize(
+  ReadMemory(s, mem.data(), std::min(mem.size(), high - s), error));
+  mem_pos = s;
+  if (error.Fail() || size > mem.size()) {
+// We didn't read enough data. Skip to the next memory region.
+MemoryRegionInfo info;
+error = GetMemoryRegionInfo(mem_pos + mem.size(), info);
+if (error.Fail())
+  break;
+s = info.GetRange().GetRangeEnd();
+continue;
+  }
+}
 int64_t j = size - 1;
-while (j >= 0 && buf[j] == iterator[s + j])
+while (j >= 0 && buf[j] == mem[s + j - mem_pos])
   j--;
 if (j < 0)
-  return low + s;
-else
-  s += bad_char_heuristic[iterator[s + size - 1]];
+  return s; // We have a match.
+s += bad_char_heuristic[mem[s + size - 1 - mem_pos]];
   }
 
   return LLDB_INVALID_ADDRESS;
diff --git a/lldb/test/API/functionalities/memory/find/TestMemoryFind.py 
b/lldb/test/API/functionalities/memory/find/TestMemoryFind.py
index 09611cc808777d..72acfb3d600701 100644
--- a/lldb/test/API/functionalities/memory/find/TestMemoryFind.py
+++ b/lldb/test/API/functionalities/memory/find/TestMemoryFind.py
@@ -10,14 +10,16 @@
 
 
 class MemoryFindTestCase(TestBase):
+
+NO_DEBUG_INFO_TESTCASE = True
+
 def setUp(sel

[Lldb-commits] [lldb] [lldb] Fix and speedup the `memory find` command (PR #104193)

2024-08-27 Thread Pavel Labath via lldb-commits

https://github.com/labath updated 
https://github.com/llvm/llvm-project/pull/104193

>From 7b8b8b699902d2365ea43e5ae015546c4d20fac8 Mon Sep 17 00:00:00 2001
From: Pavel Labath 
Date: Wed, 14 Aug 2024 19:58:27 +0200
Subject: [PATCH 1/2] [lldb] Fix and speedup the `memory find` command

This patch fixes an issue where the `memory find` command would
effectively stop searching after encountering a memory read error (which
could happen due to unreadable memory), without giving any indication
that it has done so (it would just print it could not find the pattern).

To make matters worse, it would not terminate after encountering this
error, but rather proceed to slowly increment the address pointer, which
meant that searching a large region could take a very long time (and
give the appearance that lldb is actually searching for the thing).

The patch fixes this first problem (*) by detecting read errors and
skipping over (using GetMemoryRegionInfo) the unreadable parts of memory
and resuming the search after them. It also reads the memory in bulk (up
to 1MB), which speeds up the search significantly (up to 6x for live
processes, 18x for core files).

(*) The fix does not work on windows yet, because the ReadMemory API
does not return partial results (like it does for other systems). I'm
preparing a separate patch to deal with that.
---
 lldb/source/Target/Process.cpp| 68 +++
 .../memory/find/TestMemoryFind.py | 30 ++-
 .../API/functionalities/memory/find/main.cpp  | 83 +--
 3 files changed, 136 insertions(+), 45 deletions(-)

diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index b2a0f13b9a1549..5d066d264bd3f5 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -114,33 +114,6 @@ class ProcessOptionValueProperties
   }
 };
 
-class ProcessMemoryIterator {
-public:
-  ProcessMemoryIterator(Process &process, lldb::addr_t base)
-  : m_process(process), m_base_addr(base) {}
-
-  bool IsValid() { return m_is_valid; }
-
-  uint8_t operator[](lldb::addr_t offset) {
-if (!IsValid())
-  return 0;
-
-uint8_t retval = 0;
-Status error;
-if (0 == m_process.ReadMemory(m_base_addr + offset, &retval, 1, error)) {
-  m_is_valid = false;
-  return 0;
-}
-
-return retval;
-  }
-
-private:
-  Process &m_process;
-  const lldb::addr_t m_base_addr;
-  bool m_is_valid = true;
-};
-
 static constexpr OptionEnumValueElement g_follow_fork_mode_values[] = {
 {
 eFollowParent,
@@ -3367,21 +3340,48 @@ lldb::addr_t Process::FindInMemory(lldb::addr_t low, 
lldb::addr_t high,
   if (region_size < size)
 return LLDB_INVALID_ADDRESS;
 
+  // See "Boyer-Moore string search algorithm".
   std::vector bad_char_heuristic(256, size);
-  ProcessMemoryIterator iterator(*this, low);
-
   for (size_t idx = 0; idx < size - 1; idx++) {
 decltype(bad_char_heuristic)::size_type bcu_idx = buf[idx];
 bad_char_heuristic[bcu_idx] = size - idx - 1;
   }
-  for (size_t s = 0; s <= (region_size - size);) {
+
+  // Memory we're currently searching through.
+  llvm::SmallVector mem;
+  // Position of the memory buffer.
+  addr_t mem_pos = low;
+  // Maximum number of bytes read (and buffered). We need to read at least
+  // `size` bytes for a successful match.
+  const size_t max_read_size = std::max(size, 0x1);
+
+  for (addr_t s = low; s <= (high - size);) {
+if (s + size > mem.size() + mem_pos) {
+  // We need to read more data. We don't attempt to reuse the data we've
+  // already read (up to `size-1` bytes from `s` to `mem_pos+mem.size()`).
+  // This is fine for patterns much smaller than max_read_size. For very
+  // long patterns we may need to do something more elaborate.
+  mem.resize_for_overwrite(max_read_size);
+  Status error;
+  mem.resize(
+  ReadMemory(s, mem.data(), std::min(mem.size(), high - s), error));
+  mem_pos = s;
+  if (error.Fail() || size > mem.size()) {
+// We didn't read enough data. Skip to the next memory region.
+MemoryRegionInfo info;
+error = GetMemoryRegionInfo(mem_pos + mem.size(), info);
+if (error.Fail())
+  break;
+s = info.GetRange().GetRangeEnd();
+continue;
+  }
+}
 int64_t j = size - 1;
-while (j >= 0 && buf[j] == iterator[s + j])
+while (j >= 0 && buf[j] == mem[s + j - mem_pos])
   j--;
 if (j < 0)
-  return low + s;
-else
-  s += bad_char_heuristic[iterator[s + size - 1]];
+  return s; // We have a match.
+s += bad_char_heuristic[mem[s + size - 1 - mem_pos]];
   }
 
   return LLDB_INVALID_ADDRESS;
diff --git a/lldb/test/API/functionalities/memory/find/TestMemoryFind.py 
b/lldb/test/API/functionalities/memory/find/TestMemoryFind.py
index 09611cc808777d..72acfb3d600701 100644
--- a/lldb/test/API/functionalities/memory/find/TestMemoryFind.py
+++ b/lldb/test/API/functionalities/memory/fin

[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Rahul Joshi via lldb-commits

https://github.com/jurahul updated 
https://github.com/llvm/llvm-project/pull/105745

>From 9ae8a0361b0d26cf29cc4547658baec0c2654c89 Mon Sep 17 00:00:00 2001
From: Rahul Joshi 
Date: Thu, 22 Aug 2024 08:47:02 -0700
Subject: [PATCH] [Support] Detect invalid formatv() calls

- Detect formatv() calls where the number of replacement parameters
  expected after parsing the format string does not match the number
  provides in the formatv() call.
- assert() in debug builds, and fail the formatv() call in release
  builds by just emitting an error message in the stream.
---
 .../Checkers/CheckPlacementNew.cpp|   2 +-
 .../Checkers/StdLibraryFunctionsChecker.cpp   |   2 +-
 .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp|   2 +-
 llvm/include/llvm/Support/FormatVariadic.h|  54 --
 llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp|   3 +-
 .../Orc/CompileOnDemandLayer.cpp  |   8 +-
 llvm/lib/Support/FormatVariadic.cpp   | 172 +++---
 .../tools/llvm-pdbutil/ExplainOutputStyle.cpp |   4 +-
 llvm/unittests/Support/FormatVariadicTest.cpp | 115 +---
 llvm/utils/TableGen/IntrinsicEmitter.cpp  |   4 +-
 .../mlir-linalg-ods-yaml-gen.cpp  |   4 +-
 .../tools/mlir-tblgen/LLVMIRConversionGen.cpp |   2 +-
 mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp   |  13 +-
 mlir/tools/mlir-tblgen/OpFormatGen.cpp|  14 +-
 mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp  |   3 +-
 15 files changed, 253 insertions(+), 149 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
index 99e11a15c08dc2..1b89951397cfb1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
@@ -131,7 +131,7 @@ bool PlacementNewChecker::checkPlaceCapacityIsSufficient(
 "Storage provided to placement new is only {0} bytes, "
 "whereas the allocated array type requires more space for "
 "internal needs",
-SizeOfPlaceCI->getValue(), SizeOfTargetCI->getValue()));
+SizeOfPlaceCI->getValue()));
   else
 Msg = std::string(llvm::formatv(
 "Storage provided to placement new is only {0} bytes, "
diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 8f4bd17afc8581..60c035612dcd44 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1401,7 +1401,7 @@ void StdLibraryFunctionsChecker::checkPostCall(const 
CallEvent &Call,
 ErrnoNote =
 llvm::formatv("After calling '{0}' {1}", FunctionName, ErrnoNote);
 } else {
-  CaseNote = llvm::formatv(Case.getNote().str().c_str(), FunctionName);
+  CaseNote = llvm::formatvv(Case.getNote().str().c_str(), FunctionName);
 }
 const SVal RV = Call.getReturnValue();
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index feb72f6244a18c..cdb266f70f0e3e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -655,7 +655,7 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
 
   if (!ContainsDIEOffset(die_offset)) {
 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-"GetDIE for DIE {0:x16} is outside of its CU {0:x16}", die_offset,
+"GetDIE for DIE {0:x16} is outside of its CU {1:x16}", die_offset,
 GetOffset());
 return DWARFDIE(); // Not found
   }
diff --git a/llvm/include/llvm/Support/FormatVariadic.h 
b/llvm/include/llvm/Support/FormatVariadic.h
index 595f2cf559a428..b42e24646b31b5 100644
--- a/llvm/include/llvm/Support/FormatVariadic.h
+++ b/llvm/include/llvm/Support/FormatVariadic.h
@@ -66,24 +66,24 @@ struct ReplacementItem {
 class formatv_object_base {
 protected:
   StringRef Fmt;
+  bool Validate;
   ArrayRef Adapters;
 
-  static bool consumeFieldLayout(StringRef &Spec, AlignStyle &Where,
- size_t &Align, char &Pad);
-
-  static std::pair
-  splitLiteralAndReplacement(StringRef Fmt);
-
-  formatv_object_base(StringRef Fmt,
+  formatv_object_base(StringRef Fmt, bool Validate,
   ArrayRef Adapters)
-  : Fmt(Fmt), Adapters(Adapters) {}
+  : Fmt(Fmt), Validate(Validate), Adapters(Adapters) {}
 
   formatv_object_base(formatv_object_base const &rhs) = delete;
   formatv_object_base(formatv_object_base &&rhs) = default;
 
 public:
   void format(raw_ostream &S) const {
-for (auto &R : parseFormatString(Fmt)) {
+const auto [Replacements, IsValid] =
+parseFormatString(S, Fmt, Adapters.size(), Validate);
+if (!IsValid)
+  return;
+
+for (const auto &R : Replacements) {
   if (R.Type == ReplacementType::Empty)
 continue;
  

[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Adrian Prantl via lldb-commits


@@ -56,19 +56,41 @@ class Status {
   ///
   /// \param[in] type
   /// The type for \a err.
-  explicit Status(ValueType err,
-  lldb::ErrorType type = lldb::eErrorTypeGeneric);
+  explicit Status(ValueType err, lldb::ErrorType type = 
lldb::eErrorTypeGeneric,
+  llvm::StringRef msg = {});
 
   Status(std::error_code EC);
 
-  explicit Status(const char *format, ...)
-  __attribute__((format(printf, 2, 3)));
+  /// Create a generic error with the message err_str.
+  explicit Status(std::string &&err_str);
+  /// Create a generic error with the message err_str.
+  explicit Status(llvm::StringRef err_str);
+
+  static Status FromErrorString(const char *format) {
+if (format)
+  return Status(std::string(format));
+return Status(std::string("null error"));

adrian-prantl wrote:

Note that Status stores a `std::string` internally and there's a 
`Status(std::string&&)` constructor at work here.

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

> I worry the assert will kill the LLDB library and cause issues. Can we add a 
> temporary setting that can override this in case it does cause crashes? I 
> really don't want LLDB crashing if we can help it. It will be hard to test 
> all of the error code paths that can happen out in the wild

@clayborg When I say assert I had in mind something like this:
```
Status &Status::operator=() {
  assert(IsSuccess() && "dropping an error Status without checking first");
  #if NDEBUG
  if (!IsSuccess())
Debugger::ReportWarning("dropping an error Status without checking first");
  #endif
  ...
```

So it would only "crash" in an asserts build, but otherwise keep working in 
production. Does that address you concern?
I'm also not planning to change the contract of the SBAPI. You'll still be able 
to modify SBError without triggering an assertion. It will check and log 
m_status under the hood.

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

> I like this. I have just two remarks:
> 
> * it might be better to split this into three steps (add new APIs, port to 
> new APIs, remove old APIs), as that will make reverts easier/less disruptive 
> (I don't know how much we can trust pre-commit CI these days, but I wouldn't 
> be surprised if this breaks some platform-specific code).

>From previous experience, I'm convinced that I'm going to break some 
>platform-specific bots with this commit. I like the idea of only reverting the 
>commit that removes the old API while that process is ongoing!

> * since this seems like a perfect opportunity to bikesh^Wdiscuss the names, 
> I'm going to ask if there's any appetite for shortening some of the new 
> factory functions. `Status::FromErrorStringWithFormatv` is a bit of a 
> mouthful, so I was thinking if we could  use something shorter instead 
> (`Status::FromFormatv` or even `Status::Formatv`) ?

I picked these names, because they are in line with the old names, which made 
the regex replacement feasible. Renaming them afterwards is going to be easier.
My 2 cents on the naming: I had `Status::FromFormatv` in a previous iteration 
of this patch and changed my mind, because it doesn't indicate that this is 
going to be an error. What do you think about the slightly shorter 
`Status::ErrorFromFromatv()`?
Or, more radical, and potentially *really confusing* with LLVM code: rename 
`lldb_private::Status` to `lldb_private::Error`. I don't think I'd like that.

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Adrian Prantl via lldb-commits


@@ -15,7 +15,7 @@ def __init__(self, exe_ctx: lldb.SBExecutionContext, args: 
lldb.SBStructuredData
 def read_memory_at_address(
 self, addr: int, size: int, error: lldb.SBError
 ) -> lldb.SBData:
-error.SetErrorString("This is an invalid scripted process!")
+error = Status::FromErrorString("This is an invalid scripted process!")

adrian-prantl wrote:

Thanks!

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 6e44cb3ccb822085cd2f35c63daa60395dda26f2 
37febe79c170b0575051b5fb24a9db3208721b0b --extensions h,cpp -- 
lldb/include/lldb/Core/StructuredDataImpl.h 
lldb/include/lldb/Interpreter/Interfaces/ScriptedInterface.h 
lldb/include/lldb/Interpreter/Interfaces/ScriptedPlatformInterface.h 
lldb/include/lldb/Interpreter/Interfaces/ScriptedProcessInterface.h 
lldb/include/lldb/Interpreter/OptionValue.h 
lldb/include/lldb/Interpreter/ScriptInterpreter.h 
lldb/include/lldb/Target/Process.h lldb/include/lldb/Target/ProcessTrace.h 
lldb/include/lldb/Utility/Status.h lldb/source/API/SBBreakpoint.cpp 
lldb/source/API/SBBreakpointLocation.cpp lldb/source/API/SBBreakpointName.cpp 
lldb/source/API/SBDebugger.cpp lldb/source/API/SBError.cpp 
lldb/source/API/SBFile.cpp lldb/source/API/SBFrame.cpp 
lldb/source/API/SBPlatform.cpp lldb/source/API/SBProcess.cpp 
lldb/source/API/SBStructuredData.cpp lldb/source/API/SBTarget.cpp 
lldb/source/API/SBThread.cpp lldb/source/API/SBTrace.cpp 
lldb/source/API/SBValue.cpp lldb/source/Breakpoint/Breakpoint.cpp 
lldb/source/Breakpoint/BreakpointID.cpp 
lldb/source/Breakpoint/BreakpointLocation.cpp 
lldb/source/Breakpoint/BreakpointOptions.cpp 
lldb/source/Breakpoint/BreakpointPrecondition.cpp 
lldb/source/Breakpoint/BreakpointResolver.cpp 
lldb/source/Breakpoint/BreakpointResolverAddress.cpp 
lldb/source/Breakpoint/BreakpointResolverFileLine.cpp 
lldb/source/Breakpoint/BreakpointResolverFileRegex.cpp 
lldb/source/Breakpoint/BreakpointResolverName.cpp 
lldb/source/Breakpoint/BreakpointResolverScripted.cpp 
lldb/source/Commands/CommandObjectBreakpointCommand.cpp 
lldb/source/Commands/CommandObjectCommands.cpp 
lldb/source/Commands/CommandObjectDisassemble.cpp 
lldb/source/Commands/CommandObjectExpression.cpp 
lldb/source/Commands/CommandObjectFrame.cpp 
lldb/source/Commands/CommandObjectLog.cpp 
lldb/source/Commands/CommandObjectMemory.cpp 
lldb/source/Commands/CommandObjectPlatform.cpp 
lldb/source/Commands/CommandObjectProcess.cpp 
lldb/source/Commands/CommandObjectScripting.cpp 
lldb/source/Commands/CommandObjectSource.cpp 
lldb/source/Commands/CommandObjectTarget.cpp 
lldb/source/Commands/CommandObjectThread.cpp 
lldb/source/Commands/CommandObjectType.cpp 
lldb/source/Commands/CommandObjectWatchpoint.cpp 
lldb/source/Commands/CommandObjectWatchpointCommand.cpp 
lldb/source/Commands/CommandOptionsProcessAttach.cpp 
lldb/source/Commands/CommandOptionsProcessLaunch.cpp 
lldb/source/Core/Communication.cpp lldb/source/Core/Debugger.cpp 
lldb/source/Core/FormatEntity.cpp lldb/source/Core/Module.cpp 
lldb/source/Core/ModuleList.cpp lldb/source/Core/PluginManager.cpp 
lldb/source/Core/SearchFilter.cpp lldb/source/Core/ThreadedCommunication.cpp 
lldb/source/Core/UserSettingsController.cpp lldb/source/Core/Value.cpp 
lldb/source/Core/ValueObject.cpp lldb/source/Core/ValueObjectChild.cpp 
lldb/source/Core/ValueObjectDynamicValue.cpp 
lldb/source/Core/ValueObjectMemory.cpp lldb/source/Core/ValueObjectRegister.cpp 
lldb/source/Core/ValueObjectVTable.cpp lldb/source/Core/ValueObjectVariable.cpp 
lldb/source/Expression/ExpressionParser.cpp 
lldb/source/Expression/IRExecutionUnit.cpp 
lldb/source/Expression/IRInterpreter.cpp lldb/source/Expression/IRMemoryMap.cpp 
lldb/source/Expression/Materializer.cpp 
lldb/source/Expression/UserExpression.cpp 
lldb/source/Expression/UtilityFunction.cpp lldb/source/Host/common/File.cpp 
lldb/source/Host/common/FileCache.cpp lldb/source/Host/common/Host.cpp 
lldb/source/Host/common/LockFileBase.cpp 
lldb/source/Host/common/MonitoringProcessLauncher.cpp 
lldb/source/Host/common/NativeProcessProtocol.cpp 
lldb/source/Host/common/NativeRegisterContext.cpp 
lldb/source/Host/common/ProcessLaunchInfo.cpp 
lldb/source/Host/common/Socket.cpp lldb/source/Host/common/TCPSocket.cpp 
lldb/source/Host/common/UDPSocket.cpp 
lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp 
lldb/source/Host/posix/DomainSocket.cpp 
lldb/source/Host/posix/FileSystemPosix.cpp 
lldb/source/Host/posix/HostProcessPosix.cpp 
lldb/source/Host/posix/HostThreadPosix.cpp 
lldb/source/Host/posix/LockFilePosix.cpp 
lldb/source/Host/posix/MainLoopPosix.cpp lldb/source/Host/posix/PipePosix.cpp 
lldb/source/Host/posix/ProcessLauncherPosixFork.cpp 
lldb/source/Host/windows/ConnectionGenericFileWindows.cpp 
lldb/source/Host/windows/FileSystem.cpp lldb/source/Host/windows/Host.cpp 
lldb/source/Host/windows/MainLoopWindows.cpp 
lldb/source/Interpreter/CommandInterpreter.cpp 
lldb/source/Interpreter/OptionArgParser.cpp 
lldb/source/Interpreter/OptionGroupFormat.cpp 
lldb/source/Interpreter/OptionGroupPlatform.cpp 
lldb/source/Interpreter/OptionGroupPythonClassWithDict.cpp 
lldb/source/Interpreter/OptionGroupValueObjectDisplay.cpp 
lldb/source/Interpreter/OptionGroupVariable.cpp 
lldb/source/Interpreter/Opti

[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-27 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From e90463e8967c2019e220b063ed4ce73cd0172bf3 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/6] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index 1e4a2cbb1133f7..6d446a099efc78 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,7 +45,7 @@ char CPPLanguageRuntime::ID = 0;
 /// A frame recognizer that is installed to hide libc++ implementation
 /// details from the backtrace.
 class LibCXXFrameRecognizer : public StackFrameRecognizer {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-27 Thread Adrian Vogelsgesang via lldb-commits


@@ -305,7 +307,9 @@ def test_frame_recognizer_target_specific(self):
 
 self.expect(
 "frame recognizer list",
-substrs=["recognizer.MyFrameRecognizer, module a.out, symbol bar"],
+substrs=[
+"recognizer.MyFrameRecognizer, module a.out, demangled symbol 
bar"
+],

vogelsgesang wrote:

Unfortunately, I was not able to write such a test case. Note that the `frame 
recognizer add` command does not yet expose a way to match on anything else 
than demangled names. I agree that we should be adding test cases here, as soon 
as `frame recognizer add` supports choosing the symbol mangling.

@adrian-prantl Are you planning to extend `frame recognizer add` accordingly?

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread via lldb-commits

jimingham wrote:



> On Aug 27, 2024, at 8:51 AM, Adrian Prantl ***@***.***> wrote:
> 
> 
> I like this. I have just two remarks:
> 
> it might be better to split this into three steps (add new APIs, port to new 
> APIs, remove old APIs), as that will make reverts easier/less disruptive (I 
> don't know how much we can trust pre-commit CI these days, but I wouldn't be 
> surprised if this breaks some platform-specific code).
> From previous experience, I'm convinced that I'm going to break some 
> platform-specific bots with this commit. I like the idea of only reverting 
> the commit that removes the old API while that process is ongoing!
> 
> since this seems like a perfect opportunity to bikesh^Wdiscuss the names, I'm 
> going to ask if there's any appetite for shortening some of the new factory 
> functions. Status::FromErrorStringWithFormatv is a bit of a mouthful, so I 
> was thinking if we could use something shorter instead (Status::FromFormatv 
> or even Status::Formatv) ?
> I picked these names, because they are in line with the old names, which made 
> the regex replacement feasible. Renaming them afterwards is going to be 
> easier.
> My 2 cents on the naming: I had Status::FromFormatv in a previous iteration 
> of this patch and changed my mind, because it doesn't indicate that this is 
> going to be an error. What do you think about the slightly shorter 
> Status::ErrorFromFromatv()?
> Or, more radical, and potentially really confusing with LLVM code: rename 
> lldb_private::Status to lldb_private::Error. I don't think I'd like that.
> 

Note that lldb::Status WAS lldb::Error for a very long time till LLVM added its 
Error classes, and renamed the lldb ones in doing so.   That's why you see

Status error;

everywhere in lldb.  So going back is unlikely to find favor...

Jim

> —
> Reply to this email directly, view it on GitHub 
> , 
> or unsubscribe 
> .
> You are receiving this because you are on a team that was mentioned.
> 



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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread via lldb-commits

jimingham wrote:

That should of course be lldb_private::Error -> lldb_private::Status...

Jim


> On Aug 27, 2024, at 9:48 AM, Jim Ingham ***@***.***> wrote:
> 
>> 
>> 
>> 
>>> On Aug 27, 2024, at 8:51 AM, Adrian Prantl ***@***.***> wrote:
>>> 
>>> 
>>> I like this. I have just two remarks:
>>> 
>>> it might be better to split this into three steps (add new APIs, port to 
>>> new APIs, remove old APIs), as that will make reverts easier/less 
>>> disruptive (I don't know how much we can trust pre-commit CI these days, 
>>> but I wouldn't be surprised if this breaks some platform-specific code).
>>> From previous experience, I'm convinced that I'm going to break some 
>>> platform-specific bots with this commit. I like the idea of only reverting 
>>> the commit that removes the old API while that process is ongoing!
>>> 
>>> since this seems like a perfect opportunity to bikesh^Wdiscuss the names, 
>>> I'm going to ask if there's any appetite for shortening some of the new 
>>> factory functions. Status::FromErrorStringWithFormatv is a bit of a 
>>> mouthful, so I was thinking if we could use something shorter instead 
>>> (Status::FromFormatv or even Status::Formatv) ?
>>> I picked these names, because they are in line with the old names, which 
>>> made the regex replacement feasible. Renaming them afterwards is going to 
>>> be easier.
>>> My 2 cents on the naming: I had Status::FromFormatv in a previous iteration 
>>> of this patch and changed my mind, because it doesn't indicate that this is 
>>> going to be an error. What do you think about the slightly shorter 
>>> Status::ErrorFromFromatv()?
>>> Or, more radical, and potentially really confusing with LLVM code: rename 
>>> lldb_private::Status to lldb_private::Error. I don't think I'd like that.
>>> 
>> 
>> Note that lldb::Status WAS lldb::Error for a very long time till LLVM added 
>> its Error classes, and renamed the lldb ones in doing so.   That's why you 
>> see
>> 
>> Status error;
>> 
>> everywhere in lldb.  So going back is unlikely to find favor...
>> 
>> Jim
>> 
>>> —
>>> Reply to this email directly, view it on GitHub 
>>> , 
>>> or unsubscribe 
>>> .
>>> You are receiving this because you are on a team that was mentioned.
>>> 
>> 
>> 



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


[Lldb-commits] [lldb] 384d69f - [lldb] Cleanup dyld_process_t after constructing SharedCacheInfo (#106157)

2024-08-27 Thread via lldb-commits

Author: Alex Langford
Date: 2024-08-27T09:59:17-07:00
New Revision: 384d69fcbbd07941e7eb1899435e4d56d0469637

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

LOG: [lldb] Cleanup dyld_process_t after constructing SharedCacheInfo (#106157)

Without calling `dyld_process_dispose`, LLDB will leak the memory
associated with the `dyld_process_t`.

rdar://134738265

Added: 


Modified: 
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm

Removed: 




diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index d27bd1b7426e6c..6e924fdc684cfe 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -650,12 +650,15 @@ static bool ResolveAndVerifyCandidateSupportDir(FileSpec 
&path) {
   if (!dyld_process)
 return false;
 
+  auto cleanup_process_on_exit =
+  llvm::make_scope_exit([&]() { dyld_process_dispose(dyld_process); });
+
   dyld_process_snapshot_t snapshot =
   dyld_process_snapshot_create_for_process(dyld_process, nullptr);
   if (!snapshot)
 return false;
 
-  auto on_exit =
+  auto cleanup_snapshot_on_exit =
   llvm::make_scope_exit([&]() { dyld_process_snapshot_dispose(snapshot); 
});
 
   dyld_shared_cache_t shared_cache =



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


[Lldb-commits] [lldb] [lldb] Cleanup dyld_process_t after constructing SharedCacheInfo (PR #106157)

2024-08-27 Thread Alex Langford via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-27 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From e90463e8967c2019e220b063ed4ce73cd0172bf3 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/7] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index 1e4a2cbb1133f7..6d446a099efc78 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,7 +45,7 @@ char CPPLanguageRuntime::ID = 0;
 /// A frame recognizer that is installed to hide libc++ implementation
 /// details from the backtrace.
 class LibCXXFrameRecognizer : public StackFrameRecognizer {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [lldb] [lldb] unique_ptr-ify some GetUserExpression APIs. (PR #106034)

2024-08-27 Thread Alex Langford via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-27 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/105695

>From e90463e8967c2019e220b063ed4ce73cd0172bf3 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Thu, 22 Aug 2024 10:50:13 +
Subject: [PATCH 1/7] [lldb-dap] Add frame recognizers for libc++ `std::invoke`

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into the `AddRecognizer` became
problematic, as it was evaluated on the demangled name. Those names also
included result types for C++ symbols. For `std::__invoke` the return
type is a huge `decltype(...)`, making the regular expresison really
hard to write.

Instead, I added support for `AddRecognizer` to match on the demangled
names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.
---
 .../lldb/Target/StackFrameRecognizer.h|  8 +++-
 lldb/source/Commands/Options.td   |  2 +-
 .../CPlusPlus/CPPLanguageRuntime.cpp  | 48 ++-
 lldb/source/Target/StackFrameRecognizer.cpp   | 41 ++--
 .../TestStdFunctionRecognizer.py  | 21 +++-
 .../lang/cpp/std-invoke-recognizer/Makefile   |  5 ++
 .../TestStdInvokeRecognizer.py| 31 
 .../lang/cpp/std-invoke-recognizer/main.cpp   | 40 
 8 files changed, 175 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
 create mode 100644 
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
 create mode 100644 lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

diff --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..fe25dbbde745d1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -107,12 +107,14 @@ class StackFrameRecognizerManager {
 public:
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
- bool first_instruction_only = true);
+ bool first_instruction_only = true,
+ Mangled::NamePreference mangling_preference = 
Mangled::ePreferDemangled);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
@@ -143,10 +145,12 @@ class StackFrameRecognizerManager {
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
 bool first_instruction_only;
+Mangled::NamePreference mangling_preference;
   };
 
   std::deque m_recognizers;
   uint16_t m_generation = 0;
+  std::unordered_set m_used_manglings;
 };
 
 /// \class ValueObjectRecognizerSynthesizedValue
diff --git a/lldb/source/Commands/Options.td b/lldb/source/Commands/Options.td
index 9c4dbed6939ba9..df906e9d7c808f 100644
--- a/lldb/source/Commands/Options.td
+++ b/lldb/source/Commands/Options.td
@@ -1049,7 +1049,7 @@ let Command = "thread backtrace" in {
   def thread_backtrace_extended : Option<"extended", "e">, Group<1>,
   Arg<"Boolean">, Desc<"Show the extended backtrace, if available">;
   def thread_backtrace_unfiltered : Option<"unfiltered", "u">, Group<1>,
-  Desc<"Filter out frames according to installed frame recognizers">;
+  Desc<"Do not filter out frames according to installed frame recognizers">;
 }
 
 let Command = "thread step scope" in {
diff --git 
a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp 
b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
index 1e4a2cbb1133f7..6d446a099efc78 100644
--- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
+++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include 
+#include 
 
 #include 
 
@@ -44,7 +45,7 @@ char CPPLanguageRuntime::ID = 0;
 /// A frame recognizer that is installed to hide libc++ implementation
 /// details from the backtrace.
 class LibCXXFrameRecognizer : public StackFrameRecognizer {
-  RegularExpression m_hidden_function_regex;
+  std::array m_hidden_regex;
   RecognizedStackFrameSP m_hidden_frame;
 
   struct LibCXXHiddenFrame : public RecognizedStackFrame {
@@ -53,10 +54,32 @@ class LibCXXFrameRecognizer : public Sta

[Lldb-commits] [clang] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] [polly] python: use raw strings for regex (PR #105990)

2024-08-27 Thread Nikolas Klauser via lldb-commits


@@ -284,7 +284,7 @@ def sync_csv(rows: List[Tuple], from_github: 
List[PaperInfo]) -> List[Tuple]:
 results.append(gh.for_printing())
 continue
 elif paper.status != gh.status:
-print(f"We found a CSV row and a Github issue with different 
statuses:\nrow: {row}\Github issue: {gh}")
+print(rf"We found a CSV row and a Github issue with different 
statuses:\nrow: {row}\Github issue: {gh}")

philnik777 wrote:

This doesn't look intended to me though. The `\G` should probably have been a 
`\nG`.

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

Updated all the non-Darwin plugins. I believe to have addressed all outstanding 
comments now.

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


[Lldb-commits] [lldb] dd060bd - [lldb] Add frame recognizers for libc++ `std::invoke` (#105695)

2024-08-27 Thread via lldb-commits

Author: Adrian Vogelsgesang
Date: 2024-08-27T19:15:42+02:00
New Revision: dd060bdede8edec18ad5ca122e15cc24a821e3fe

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

LOG: [lldb] Add frame recognizers for libc++ `std::invoke` (#105695)

With this commit, we also hide the implementation details of
`std::invoke`. To do so, the `LibCXXFrameRecognizer` got a couple more
regular expressions.

The regular expression passed into `AddRecognizer` became problematic,
as it was evaluated on the demangled name. Those names also included
result types for C++ symbols. For `std::__invoke` the return type is a
huge `decltype(...)`, making the regular expresison really hard to
write.

Instead, I added support to `AddRecognizer` for matching on the
demangled names without result type and argument types.

By hiding the implementation details of `invoke`, also the back traces
for `std::function` become even nicer, because `std::function` is using
`__invoke` internally.

Co-authored-by: Adrian Prantl 

Added: 
lldb/test/API/lang/cpp/std-invoke-recognizer/Makefile
lldb/test/API/lang/cpp/std-invoke-recognizer/TestStdInvokeRecognizer.py
lldb/test/API/lang/cpp/std-invoke-recognizer/main.cpp

Modified: 
lldb/include/lldb/Target/StackFrameRecognizer.h
lldb/source/Commands/CommandObjectFrame.cpp
lldb/source/Commands/Options.td
lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp

lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
lldb/source/Plugins/SystemRuntime/MacOSX/AbortWithPayloadFrameRecognizer.cpp
lldb/source/Target/AssertFrameRecognizer.cpp
lldb/source/Target/StackFrameRecognizer.cpp
lldb/source/Target/VerboseTrapFrameRecognizer.cpp
lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
lldb/test/API/functionalities/completion/TestCompletion.py
lldb/test/API/lang/cpp/std-function-recognizer/TestStdFunctionRecognizer.py
lldb/unittests/Target/StackFrameRecognizerTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Target/StackFrameRecognizer.h 
b/lldb/include/lldb/Target/StackFrameRecognizer.h
index 2f5c5caa6a4561..617b1617d404a1 100644
--- a/lldb/include/lldb/Target/StackFrameRecognizer.h
+++ b/lldb/include/lldb/Target/StackFrameRecognizer.h
@@ -105,19 +105,30 @@ class ScriptedStackFrameRecognizer : public 
StackFrameRecognizer {
 /// Class that provides a registry of known stack frame recognizers.
 class StackFrameRecognizerManager {
 public:
+  /// Add a new recognizer that triggers on a given symbol name.
+  ///
+  /// \param symbol_mangling controls whether the symbol name should be
+  /// compared to the mangled or demangled name.
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  ConstString module, llvm::ArrayRef symbols,
+ Mangled::NamePreference symbol_mangling,
  bool first_instruction_only = true);
 
+  /// Add a new recognizer that triggers on a symbol regex.
+  ///
+  /// \param symbol_mangling controls whether the regex should apply
+  /// to the mangled or demangled name.
   void AddRecognizer(lldb::StackFrameRecognizerSP recognizer,
  lldb::RegularExpressionSP module,
  lldb::RegularExpressionSP symbol,
+ Mangled::NamePreference symbol_mangling,
  bool first_instruction_only = true);
 
   void ForEach(std::function<
void(uint32_t recognizer_id, std::string recognizer_name,
 std::string module, llvm::ArrayRef symbols,
-bool regexp)> const &callback);
+Mangled::NamePreference name_reference, bool regexp)> const
+   &callback);
 
   bool RemoveRecognizerWithID(uint32_t recognizer_id);
 
@@ -142,6 +153,7 @@ class StackFrameRecognizerManager {
 lldb::RegularExpressionSP module_regexp;
 std::vector symbols;
 lldb::RegularExpressionSP symbol_regexp;
+Mangled::NamePreference symbol_mangling;
 bool first_instruction_only;
   };
 

diff  --git a/lldb/source/Commands/CommandObjectFrame.cpp 
b/lldb/source/Commands/CommandObjectFrame.cpp
index 46c75e3dd159c0..ef57582a203b39 100644
--- a/lldb/source/Commands/CommandObjectFrame.cpp
+++ b/lldb/source/Commands/CommandObjectFrame.cpp
@@ -168,8 +168,7 @@ class CommandObjectFrameDiagnose : public 
CommandObjectParsed {
 // We've already handled the case where the value object sp is null, so
 // this is just to make sure future changes don't skip that:
 assert(valobj_sp.get() && "Must have a valid ValueObject to print");
-ValueObjectPrinter printer(*valobj_sp, &result.GetOutputStream(),
-   options);
+ValueObjectPrinter printer(*valobj

[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-27 Thread Adrian Vogelsgesang via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Alex Langford via lldb-commits

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

I haven't reviewed every single file but the ones I did look at look 
straightforward and correct. The changes to `Status` itself I feel positively 
about. I agree with the direction that this takes `Status` in.

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Greg Clayton via lldb-commits

clayborg wrote:

My concerns are addressed, thanks @adrian-prantl 

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Michael Buch via lldb-commits


@@ -37,10 +37,10 @@ class raw_ostream;
 using namespace lldb;
 using namespace lldb_private;
 
-Status::Status() : m_string() {}
+Status::Status() {}
 
-Status::Status(ValueType err, ErrorType type)
-: m_code(err), m_type(type), m_string() {}
+Status::Status(ValueType err, ErrorType type, std::string msg)
+: m_code(err), m_type(type), m_string(msg) {}

Michael137 wrote:

std::move (and below too)

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Jonas Devlieghere via lldb-commits

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

This is great. It's something I've wanted since the first day I started working 
on LLDB. We've made a lot of progress in this direction so it's great to see 
that we've reached a point where we can make this actually happen. 

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


[Lldb-commits] [lldb] [lldb] Don't scan more than 10MB of assembly insns (PR #105890)

2024-08-27 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread Adrian Prantl via lldb-commits

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


[Lldb-commits] [lldb] d1d8edf - [lldb] Add transitional backwards-compatible API to Status

2024-08-27 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-08-27T11:00:08-07:00
New Revision: d1d8edf50449accf7896620afc0249af91354d17

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

LOG: [lldb] Add transitional backwards-compatible API to Status

Added: 


Modified: 
lldb/include/lldb/Utility/Status.h

Removed: 




diff  --git a/lldb/include/lldb/Utility/Status.h 
b/lldb/include/lldb/Utility/Status.h
index b304291ffae00e..3104f1dfc6e4d2 100644
--- a/lldb/include/lldb/Utility/Status.h
+++ b/lldb/include/lldb/Utility/Status.h
@@ -83,6 +83,69 @@ class Status {
 return Status(result, lldb::eErrorTypeExpression, msg);
   }
 
+  
+  // TO BE REMOVED ASAP.
+  // This is transitional to make it easier to iterate with broken bots.
+  
+  LLVM_DEPRECATED("Use Status::FromErrorString() instead", "FromErrorString")
+  explicit Status(const char *format, ...)
+  __attribute__((format(printf, 2, 3))) {
+// Yes, this drops the arguments.
+*this = Status::FromErrorString(format);
+  }
+  template 
+  static LLVM_DEPRECATED("Use Status::FromErrorStringWithFormat() instead",
+ "FromErrorStringWithFormat") Status
+  createWithFormat(const char *format, Args &&...args) {
+return Status::FromErrorStringWithFormat(format,
+ std::forward(args)...);
+  }
+  LLVM_DEPRECATED("Use Status::FromExpressionError() instead",
+  "FromExpressionError")
+  void SetExpressionError(lldb::ExpressionResults results, const char *msg) {
+*this = Status::FromExpressionError(results, msg);
+  }
+  LLVM_DEPRECATED("Use Status::FromExpressionError() instead",
+  "FromExpressionError")
+  int SetExpressionErrorWithFormat(lldb::ExpressionResults results,
+   const char *msg, ...) {
+*this = Status::FromExpressionError(results, msg);
+return 0;
+  }
+  LLVM_DEPRECATED("Use Status::Status() instead", "Status")
+  void SetError(ValueType err, lldb::ErrorType type) {
+Status error(err, lldb::eErrorTypeGeneric);
+*this = error;
+  }
+  LLVM_DEPRECATED("Use Status::FromErrNo() instead", "Status")
+  void SetErrorToErrno() { *this = Status::FromErrno(); }
+  LLVM_DEPRECATED("Use Status() instead", "Status")
+  void SetErrorToGenericError() {
+*this = Status::FromErrorString("generic error");
+  }
+  LLVM_DEPRECATED("Use Status::FromErrorString() instead", "Status")
+  void SetErrorString(llvm::StringRef err_str) {
+*this = Status::FromErrorString(err_str.str().c_str());
+  }
+  LLVM_DEPRECATED("Use Status::FromErrorStringWithFormat() instead", "Status")
+  int SetErrorStringWithFormat(const char *format, ...)
+  __attribute__((format(printf, 2, 3))) {
+*this = Status::FromErrorString(format);
+return 0;
+  }
+  LLVM_DEPRECATED("Use Status::FromErrorString() instead", "Status")
+  int SetErrorStringWithVarArg(const char *format, va_list args) {
+*this = Status::FromErrorString(format);
+return 0;
+  }
+  template 
+  LLVM_DEPRECATED("Use Status::FromErrorStringWithFormatv() instead", "Status")
+  void SetErrorStringWithFormatv(const char *format, Args &&...args) {
+*this =
+Status::FromErrorStringWithFormatv(format, 
std::forward(args)...);
+  }
+  
+
   /// Set the current error to errno.
   ///
   /// Update the error value to be \c errno and update the type to be \c



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


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-27 Thread Adrian Prantl via lldb-commits

adrian-prantl wrote:

Looks like this is failing on the Darwin bot: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/10463/

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


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-27 Thread Adrian Prantl via lldb-commits


@@ -305,7 +307,9 @@ def test_frame_recognizer_target_specific(self):
 
 self.expect(
 "frame recognizer list",
-substrs=["recognizer.MyFrameRecognizer, module a.out, symbol bar"],
+substrs=[
+"recognizer.MyFrameRecognizer, module a.out, demangled symbol 
bar"
+],

adrian-prantl wrote:

> Unfortunately, I was not able to write such a test case. Note that the `frame 
> recognizer add` command does not yet expose a way to match on anything else 
> than demangled names. I agree that we should be adding test cases here, as 
> soon as `frame recognizer add` supports choosing the symbol mangling.
> 
> @adrian-prantl Are you planning to extend `frame recognizer add` accordingly?

It's not on my immediate todo list, but it would be an obvious next step.

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


[Lldb-commits] [lldb] c349ded - [lldb] Add missing namespace

2024-08-27 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-08-27T11:04:54-07:00
New Revision: c349ded7e61f3611ea54fa712e54b16c4c317a6b

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

LOG: [lldb] Add missing namespace

Added: 


Modified: 
lldb/source/Utility/SelectHelper.cpp

Removed: 




diff  --git a/lldb/source/Utility/SelectHelper.cpp 
b/lldb/source/Utility/SelectHelper.cpp
index 0b7c759bae94c4..34c1b62228fdc4 100644
--- a/lldb/source/Utility/SelectHelper.cpp
+++ b/lldb/source/Utility/SelectHelper.cpp
@@ -111,8 +111,8 @@ lldb_private::Status SelectHelper::Select() {
 #if !defined(__APPLE__) && !defined(_WIN32)
 lldbassert(fd < static_cast(FD_SETSIZE));
 if (fd >= static_cast(FD_SETSIZE)) {
-  error =
-  Status::FromErrorStringWithFormat("%i is too large for select()", 
fd);
+  error = lldb_private::Status::FromErrorStringWithFormat(
+  "%i is too large for select()", fd);
   return error;
 }
 #endif



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


[Lldb-commits] [clang] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] [polly] python: use raw strings for regex (PR #105990)

2024-08-27 Thread Paul Zander via lldb-commits


@@ -284,7 +284,7 @@ def sync_csv(rows: List[Tuple], from_github: 
List[PaperInfo]) -> List[Tuple]:
 results.append(gh.for_printing())
 continue
 elif paper.status != gh.status:
-print(f"We found a CSV row and a Github issue with different 
statuses:\nrow: {row}\Github issue: {gh}")
+print(rf"We found a CSV row and a Github issue with different 
statuses:\nrow: {row}\Github issue: {gh}")

negril wrote:

That can be fix if you want me to?

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


[Lldb-commits] [clang] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] [polly] python: use raw strings for regex (PR #105990)

2024-08-27 Thread Paul Zander via lldb-commits

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


[Lldb-commits] [lldb] [lldb] unique_ptr-ify some GetUserExpression APIs. (PR #106034)

2024-08-27 Thread Jonas Devlieghere via lldb-commits

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


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


[Lldb-commits] [clang] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] [polly] python: use raw strings for regex (PR #105990)

2024-08-27 Thread Louis Dionne via lldb-commits


@@ -284,7 +284,7 @@ def sync_csv(rows: List[Tuple], from_github: 
List[PaperInfo]) -> List[Tuple]:
 results.append(gh.for_printing())
 continue
 elif paper.status != gh.status:
-print(f"We found a CSV row and a Github issue with different 
statuses:\nrow: {row}\Github issue: {gh}")
+print(rf"We found a CSV row and a Github issue with different 
statuses:\nrow: {row}\Github issue: {gh}")

ldionne wrote:

Ah, yeah that's the issue. The `\G` is unintended. I'll fix this right now.

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


[Lldb-commits] [clang] [compiler-rt] [libcxx] [lld] [lldb] [llvm] [mlir] [polly] python: use raw strings for regex (PR #105990)

2024-08-27 Thread Louis Dionne via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Turn lldb_private::Status into a value type. (PR #106163)

2024-08-27 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-x86_64-debian-dylib` 
running on `gribozavr4` while building `lldb` at step 5 "build-unified-tree".

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


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

```
Step 5 (build-unified-tree) failure: build (failure)
...
33.001 [1386/50/5533] Building CXX object 
unittests/Analysis/InlineAdvisorPlugin/CMakeFiles/InlineAdvisorPlugin.dir/InlineAdvisorPlugin.cpp.o
33.001 [1386/49/5534] Building CXX object 
unittests/Analysis/InlineOrderPlugin/CMakeFiles/InlineOrderPlugin.dir/InlineOrderPlugin.cpp.o
33.001 [1386/48/5535] Building CXX object 
unittests/Passes/Plugins/DoublerPlugin/CMakeFiles/DoublerPlugin.dir/DoublerPlugin.cpp.o
33.063 [1386/47/5536] Building CXX object 
tools/lldb/tools/lldb-instr/CMakeFiles/lldb-instr.dir/Instrument.cpp.o
33.620 [1386/46/5537] Building CXX object 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/LockFileBase.cpp.o
33.624 [1386/45/5538] Building CXX object 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/HostThread.cpp.o
33.720 [1386/44/5539] Building CXX object 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/posix/LockFilePosix.cpp.o
33.730 [1386/43/5540] Building CXX object 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/posix/HostThreadPosix.cpp.o
33.784 [1386/42/5541] Building CXX object 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/linux/AbstractSocket.cpp.o
33.788 [1386/41/5542] Building CXX object 
tools/lldb/source/Utility/CMakeFiles/lldbUtility.dir/SelectHelper.cpp.o
FAILED: tools/lldb/source/Utility/CMakeFiles/lldbUtility.dir/SelectHelper.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ 
-DGTEST_HAS_RTTI=0 -DHAVE_ROUND -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/source/Utility 
-I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Utility 
-I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/include 
-I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/include 
-I/b/1/llvm-x86_64-debian-dylib/build/include 
-I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/include 
-I/b/1/llvm-x86_64-debian-dylib/llvm-project/llvm/../clang/include 
-I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/../clang/include 
-I/usr/include/libxml2 -I/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source 
-I/b/1/llvm-x86_64-debian-dylib/build/tools/lldb/source -fPIC 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -Wno-deprecated-declarations 
-Wno-unknown-pragmas -Wno-strict-aliasing -Wno-deprecated-register 
-Wno-vla-extension -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti 
-UNDEBUG -std=c++17 -MD -MT 
tools/lldb/source/Utility/CMakeFiles/lldbUtility.dir/SelectHelper.cpp.o -MF 
tools/lldb/source/Utility/CMakeFiles/lldbUtility.dir/SelectHelper.cpp.o.d -o 
tools/lldb/source/Utility/CMakeFiles/lldbUtility.dir/SelectHelper.cpp.o -c 
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Utility/SelectHelper.cpp
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/source/Utility/SelectHelper.cpp:115:11:
 error: use of undeclared identifier 'Status'; did you mean 
'lldb_private::Status'?
  Status::FromErrorStringWithFormat("%i is too large for select()", fd);
  ^~
  lldb_private::Status
/b/1/llvm-x86_64-debian-dylib/llvm-project/lldb/include/lldb/Utility/Status.h:44:7:
 note: 'lldb_private::Status' declared here
class Status {
  ^
1 error generated.
33.834 [1386/40/5543] Building CXX object 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/ThreadLauncher.cpp.o
33.842 [1386/39/5544] Building CXX object 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/PipeBase.cpp.o
33.849 [1386/38/5545] Building CXX object 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/MainLoopBase.cpp.o
33.854 [1386/37/5546] Building CXX object 
tools/lldb/source/Utility/CMakeFiles/lldbUtility.dir/StringExtractorGDBRemote.cpp.o
33.884 [1386/36/5547] Building CXX object 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/posix/DomainSocket.cpp.o
33.959 [1386/35/5548] Building CXX object 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/NativeWatchpointList.cpp.o
34.043 [1386/34/5549] Building CXX object 
tools/lldb/source/Host/CMakeFiles/lldbHost.dir/common/HostProcess.cpp.o
34.055 [1386/33/5550] Building CXX object 
tools/lldb/source/Utility/CMakeFiles/lldbUtility.dir/Status.cpp.o
34.218 [1386/32/5551] Building CXX object 
to

[Lldb-commits] [lldb] 5e64520 - [lldb] Update Windows test to new Status API

2024-08-27 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-08-27T12:28:25-07:00
New Revision: 5e64520dae5dd980bc6db25414edc3a167d8af8f

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

LOG: [lldb] Update Windows test to new Status API

Added: 


Modified: 
lldb/unittests/Utility/StatusTest.cpp

Removed: 




diff  --git a/lldb/unittests/Utility/StatusTest.cpp 
b/lldb/unittests/Utility/StatusTest.cpp
index a7dba702bd0193..d33909ea897275 100644
--- a/lldb/unittests/Utility/StatusTest.cpp
+++ b/lldb/unittests/Utility/StatusTest.cpp
@@ -84,16 +84,16 @@ TEST(StatusTest, ErrorWin32) {
   // formatted messages will be 
diff erent.
   bool skip = wcscmp(L"en-US", name) != 0;
 
-  auto s = Status(ERROR_ACCESS_DENIED, ErrorType::eErrorTypeWin32);
+  Status s = Status(ERROR_ACCESS_DENIED, ErrorType::eErrorTypeWin32);
   EXPECT_TRUE(s.Fail());
   if (!skip)
 EXPECT_STREQ("Access is denied. ", s.AsCString());
 
-  s.SetError(ERROR_IPSEC_IKE_TIMED_OUT, ErrorType::eErrorTypeWin32);
+  s = Status(ERROR_IPSEC_IKE_TIMED_OUT, ErrorType::eErrorTypeWin32);
   if (!skip)
 EXPECT_STREQ("Negotiation timed out ", s.AsCString());
 
-  s.SetError(16000, ErrorType::eErrorTypeWin32);
+  s = Status(16000, ErrorType::eErrorTypeWin32);
   if (!skip)
 EXPECT_STREQ("unknown error", s.AsCString());
 }



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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Add selectable memory regions to SBSaveCore (PR #105442)

2024-08-27 Thread Med Ismail Bennani via lldb-commits

medismailben wrote:

It looks like this broke lldb macOS bots: 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/10450/

@Jlalond can you take a look ? Thanks.

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


[Lldb-commits] [lldb] b24ffa6 - [lldb] Update ProcessLauncherWinows to new Status API

2024-08-27 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-08-27T12:34:54-07:00
New Revision: b24ffa6002424423ee6bd54347db9b0855efbc2a

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

LOG: [lldb] Update ProcessLauncherWinows to new Status API

Added: 


Modified: 
lldb/source/Host/windows/ProcessLauncherWindows.cpp

Removed: 




diff  --git a/lldb/source/Host/windows/ProcessLauncherWindows.cpp 
b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
index baa422c15cae2c..065ba9271ad0df 100644
--- a/lldb/source/Host/windows/ProcessLauncherWindows.cpp
+++ b/lldb/source/Host/windows/ProcessLauncherWindows.cpp
@@ -120,7 +120,7 @@ ProcessLauncherWindows::LaunchProcess(const 
ProcessLaunchInfo &launch_info,
 
   if (!result) {
 // Call GetLastError before we make any other system calls.
-error.SetError(::GetLastError(), eErrorTypeWin32);
+error = Status(::GetLastError(), eErrorTypeWin32);
 // Note that error 50 ("The request is not supported") will occur if you
 // try debug a 64-bit inferior from a 32-bit LLDB.
   }



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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Rahul Joshi via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

CI failed FYI.

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread via lldb-commits

llvmbot wrote:



@llvm/pr-subscribers-debuginfo

@llvm/pr-subscribers-lldb

Author: Rahul Joshi (jurahul)


Changes


- Change formatv() to validate that the number of arguments passed matches 
number of 
  replacement fields in the format string.
- When the format string is a literal, this failure can be easily fixed, but 
when it's dynamically
  generated, it may not be as straightforward.
- So changed existing formatv() to only accept literal strings as a format 
string and enable
  argument count validation for that case only.
- Add a `formatvv` variant that allows non-literal format strings and disables 
argument count
  verification (the additional v will stand for "variable format string").

---

Patch is 39.55 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/105745.diff


15 Files Affected:

- (modified) clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp (+1-1) 
- (modified) clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
(+1-1) 
- (modified) lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp (+1-1) 
- (modified) llvm/include/llvm/Support/FormatVariadic.h (+37-17) 
- (modified) llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp (+1-2) 
- (modified) llvm/lib/ExecutionEngine/Orc/CompileOnDemandLayer.cpp (+4-4) 
- (modified) llvm/lib/Support/FormatVariadic.cpp (+102-70) 
- (modified) llvm/tools/llvm-pdbutil/ExplainOutputStyle.cpp (+2-2) 
- (modified) llvm/unittests/Support/FormatVariadicTest.cpp (+86-29) 
- (modified) llvm/utils/TableGen/IntrinsicEmitter.cpp (+2-2) 
- (modified) mlir/tools/mlir-linalg-ods-gen/mlir-linalg-ods-yaml-gen.cpp (+2-2) 
- (modified) mlir/tools/mlir-tblgen/LLVMIRConversionGen.cpp (+1-1) 
- (modified) mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp (+6-7) 
- (modified) mlir/tools/mlir-tblgen/OpFormatGen.cpp (+6-8) 
- (modified) mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp (+1-2) 


``diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
index 99e11a15c08dc2..1b89951397cfb1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
@@ -131,7 +131,7 @@ bool PlacementNewChecker::checkPlaceCapacityIsSufficient(
 "Storage provided to placement new is only {0} bytes, "
 "whereas the allocated array type requires more space for "
 "internal needs",
-SizeOfPlaceCI->getValue(), SizeOfTargetCI->getValue()));
+SizeOfPlaceCI->getValue()));
   else
 Msg = std::string(llvm::formatv(
 "Storage provided to placement new is only {0} bytes, "
diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 8f4bd17afc8581..60c035612dcd44 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -1401,7 +1401,7 @@ void StdLibraryFunctionsChecker::checkPostCall(const 
CallEvent &Call,
 ErrnoNote =
 llvm::formatv("After calling '{0}' {1}", FunctionName, ErrnoNote);
 } else {
-  CaseNote = llvm::formatv(Case.getNote().str().c_str(), FunctionName);
+  CaseNote = llvm::formatvv(Case.getNote().str().c_str(), FunctionName);
 }
 const SVal RV = Call.getReturnValue();
 
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
index feb72f6244a18c..cdb266f70f0e3e 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp
@@ -655,7 +655,7 @@ DWARFUnit::GetDIE(dw_offset_t die_offset) {
 
   if (!ContainsDIEOffset(die_offset)) {
 GetSymbolFileDWARF().GetObjectFile()->GetModule()->ReportError(
-"GetDIE for DIE {0:x16} is outside of its CU {0:x16}", die_offset,
+"GetDIE for DIE {0:x16} is outside of its CU {1:x16}", die_offset,
 GetOffset());
 return DWARFDIE(); // Not found
   }
diff --git a/llvm/include/llvm/Support/FormatVariadic.h 
b/llvm/include/llvm/Support/FormatVariadic.h
index 595f2cf559a428..b42e24646b31b5 100644
--- a/llvm/include/llvm/Support/FormatVariadic.h
+++ b/llvm/include/llvm/Support/FormatVariadic.h
@@ -66,24 +66,24 @@ struct ReplacementItem {
 class formatv_object_base {
 protected:
   StringRef Fmt;
+  bool Validate;
   ArrayRef Adapters;
 
-  static bool consumeFieldLayout(StringRef &Spec, AlignStyle &Where,
- size_t &Align, char &Pad);
-
-  static std::pair
-  splitLiteralAndReplacement(StringRef Fmt);
-
-  formatv_object_base(StringRef Fmt,
+  formatv_object_base(StringRef Fmt, bool Validate,
   ArrayRef Adapters)
-  : Fmt(Fmt), Adapters(Adapters) {}
+  : Fmt(Fmt), Validate(Validate), Adapters(Adapters) {}
 
   formatv_object_base(formatv_object_base const &rhs) = de

[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Rahul Joshi via lldb-commits

jurahul wrote:

Hi all, this is related to 
https://discourse.llvm.org/t/adding-argument-count-validation-for-formatv/80876/1

I still have formatv() and formatvv() functions in the code, but only a handful 
instances. So, if this looks ok overall, I will go ahead and rename formatvv() 
to formatv_unchecked() (or if there are other better suggestions for that 
version). Also, let me know if it would make sense to split this into 2 
changes, one NFC one that fixes formatv() current uses that are invalid, and 
then the next one that adds validation and changes the handful few that need to 
be to formatvv().

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Rahul Joshi via lldb-commits

jurahul wrote:

> CI failed FYI.

Yeah, it looked like an unrelated failure. Windows CI passed.

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Mehdi Amini via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Mehdi Amini via lldb-commits


@@ -67,92 +68,123 @@ formatv_object_base::parseReplacementItem(StringRef Spec) {
   StringRef Options;
   size_t Index = 0;
   RepString = RepString.trim();
-  if (RepString.consumeInteger(0, Index)) {
-assert(false && "Invalid replacement sequence index!");
-return ReplacementItem{};
-  }
+  if (RepString.consumeInteger(0, Index))
+return "Invalid replacement sequence index!";
   RepString = RepString.trim();
   if (RepString.consume_front(",")) {
 if (!consumeFieldLayout(RepString, Where, Align, Pad))
-  assert(false && "Invalid replacement field layout specification!");
+  return "Invalid replacement field layout specification!";
   }
   RepString = RepString.trim();
   if (RepString.consume_front(":")) {
 Options = RepString.trim();
 RepString = StringRef();
   }
   RepString = RepString.trim();
-  if (!RepString.empty()) {
-assert(false && "Unexpected characters found in replacement string!");
-  }
-
+  if (!RepString.empty())
+return "Unexpected character found in replacement string!";
   return ReplacementItem{Spec, Index, Align, Where, Pad, Options};
 }
 
-std::pair
-formatv_object_base::splitLiteralAndReplacement(StringRef Fmt) {
-  while (!Fmt.empty()) {
-// Everything up until the first brace is a literal.
-if (Fmt.front() != '{') {
-  std::size_t BO = Fmt.find_first_of('{');
-  return std::make_pair(ReplacementItem{Fmt.substr(0, BO)}, 
Fmt.substr(BO));
-}
-
-StringRef Braces = Fmt.take_while([](char C) { return C == '{'; });
-// If there is more than one brace, then some of them are escaped.  Treat
-// these as replacements.
-if (Braces.size() > 1) {
-  size_t NumEscapedBraces = Braces.size() / 2;
-  StringRef Middle = Fmt.take_front(NumEscapedBraces);
-  StringRef Right = Fmt.drop_front(NumEscapedBraces * 2);
-  return std::make_pair(ReplacementItem{Middle}, Right);
-}
-// An unterminated open brace is undefined. Assert to indicate that this is
-// undefined and that we consider it an error. When asserts are disabled,
-// build a replacement item with an error message.
-std::size_t BC = Fmt.find_first_of('}');
-if (BC == StringRef::npos) {
-  assert(
-  false &&
-  "Unterminated brace sequence. Escape with {{ for a literal brace.");
-  return std::make_pair(
-  ReplacementItem{"Unterminated brace sequence. Escape with {{ for a "
-  "literal brace."},
-  StringRef());
-}
-
-// Even if there is a closing brace, if there is another open brace before
-// this closing brace, treat this portion as literal, and try again with 
the
-// next one.
-std::size_t BO2 = Fmt.find_first_of('{', 1);
-if (BO2 < BC)
-  return std::make_pair(ReplacementItem{Fmt.substr(0, BO2)},
-Fmt.substr(BO2));
-
-StringRef Spec = Fmt.slice(1, BC);
-StringRef Right = Fmt.substr(BC + 1);
-
-auto RI = parseReplacementItem(Spec);
-if (RI)
-  return std::make_pair(*RI, Right);
+static std::variant, StringRef>
+splitLiteralAndReplacement(StringRef Fmt) {
+  // Everything up until the first brace is a literal.
+  if (Fmt.front() != '{') {
+std::size_t BO = Fmt.find_first_of('{');
+return std::make_pair(ReplacementItem(Fmt.substr(0, BO)), Fmt.substr(BO));
+  }
 
-// If there was an error parsing the replacement item, treat it as an
-// invalid replacement spec, and just continue.
-Fmt = Fmt.drop_front(BC + 1);
+  StringRef Braces = Fmt.take_while([](char C) { return C == '{'; });
+  // If there is more than one brace, then some of them are escaped.  Treat
+  // these as replacements.
+  if (Braces.size() > 1) {
+size_t NumEscapedBraces = Braces.size() / 2;
+StringRef Middle = Fmt.take_front(NumEscapedBraces);
+StringRef Right = Fmt.drop_front(NumEscapedBraces * 2);
+return std::make_pair(ReplacementItem(Middle), Right);
   }
-  return std::make_pair(ReplacementItem{Fmt}, StringRef());
+  // An unterminated open brace is undefined. Assert to indicate that this is
+  // undefined and that we consider it an error. When asserts are disabled,
+  // build a replacement item with an error message.
+  std::size_t BC = Fmt.find_first_of('}');
+  if (BC == StringRef::npos)
+return "Unterminated brace sequence. Escape with {{ for a literal brace.";
+
+  // Even if there is a closing brace, if there is another open brace before
+  // this closing brace, treat this portion as literal, and try again with the
+  // next one.
+  std::size_t BO2 = Fmt.find_first_of('{', 1);
+  if (BO2 < BC)
+return std::make_pair(ReplacementItem{Fmt.substr(0, BO2)}, 
Fmt.substr(BO2));
+
+  StringRef Spec = Fmt.slice(1, BC);
+  StringRef Right = Fmt.substr(BC + 1);
+
+  auto RI = parseReplacementItem(Spec);
+  if (const StringRef *ErrMsg = std::get_if<1>(&RI))
+return *ErrMsg;
+
+  return std::make_pair(std::get<0>(RI), Right);
 }
 
-SmallVector
-format

[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Mehdi Amini via lldb-commits

https://github.com/joker-eph commented:

Thanks, I'm wondering about the cost of this: what does it do to some 
compile-time tests with clang for example?

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Rahul Joshi via lldb-commits


@@ -67,92 +68,123 @@ formatv_object_base::parseReplacementItem(StringRef Spec) {
   StringRef Options;
   size_t Index = 0;
   RepString = RepString.trim();
-  if (RepString.consumeInteger(0, Index)) {
-assert(false && "Invalid replacement sequence index!");
-return ReplacementItem{};
-  }
+  if (RepString.consumeInteger(0, Index))
+return "Invalid replacement sequence index!";
   RepString = RepString.trim();
   if (RepString.consume_front(",")) {
 if (!consumeFieldLayout(RepString, Where, Align, Pad))
-  assert(false && "Invalid replacement field layout specification!");
+  return "Invalid replacement field layout specification!";
   }
   RepString = RepString.trim();
   if (RepString.consume_front(":")) {
 Options = RepString.trim();
 RepString = StringRef();
   }
   RepString = RepString.trim();
-  if (!RepString.empty()) {
-assert(false && "Unexpected characters found in replacement string!");
-  }
-
+  if (!RepString.empty())
+return "Unexpected character found in replacement string!";
   return ReplacementItem{Spec, Index, Align, Where, Pad, Options};
 }
 
-std::pair
-formatv_object_base::splitLiteralAndReplacement(StringRef Fmt) {
-  while (!Fmt.empty()) {
-// Everything up until the first brace is a literal.
-if (Fmt.front() != '{') {
-  std::size_t BO = Fmt.find_first_of('{');
-  return std::make_pair(ReplacementItem{Fmt.substr(0, BO)}, 
Fmt.substr(BO));
-}
-
-StringRef Braces = Fmt.take_while([](char C) { return C == '{'; });
-// If there is more than one brace, then some of them are escaped.  Treat
-// these as replacements.
-if (Braces.size() > 1) {
-  size_t NumEscapedBraces = Braces.size() / 2;
-  StringRef Middle = Fmt.take_front(NumEscapedBraces);
-  StringRef Right = Fmt.drop_front(NumEscapedBraces * 2);
-  return std::make_pair(ReplacementItem{Middle}, Right);
-}
-// An unterminated open brace is undefined. Assert to indicate that this is
-// undefined and that we consider it an error. When asserts are disabled,
-// build a replacement item with an error message.
-std::size_t BC = Fmt.find_first_of('}');
-if (BC == StringRef::npos) {
-  assert(
-  false &&
-  "Unterminated brace sequence. Escape with {{ for a literal brace.");
-  return std::make_pair(
-  ReplacementItem{"Unterminated brace sequence. Escape with {{ for a "
-  "literal brace."},
-  StringRef());
-}
-
-// Even if there is a closing brace, if there is another open brace before
-// this closing brace, treat this portion as literal, and try again with 
the
-// next one.
-std::size_t BO2 = Fmt.find_first_of('{', 1);
-if (BO2 < BC)
-  return std::make_pair(ReplacementItem{Fmt.substr(0, BO2)},
-Fmt.substr(BO2));
-
-StringRef Spec = Fmt.slice(1, BC);
-StringRef Right = Fmt.substr(BC + 1);
-
-auto RI = parseReplacementItem(Spec);
-if (RI)
-  return std::make_pair(*RI, Right);
+static std::variant, StringRef>
+splitLiteralAndReplacement(StringRef Fmt) {
+  // Everything up until the first brace is a literal.
+  if (Fmt.front() != '{') {
+std::size_t BO = Fmt.find_first_of('{');
+return std::make_pair(ReplacementItem(Fmt.substr(0, BO)), Fmt.substr(BO));
+  }
 
-// If there was an error parsing the replacement item, treat it as an
-// invalid replacement spec, and just continue.
-Fmt = Fmt.drop_front(BC + 1);
+  StringRef Braces = Fmt.take_while([](char C) { return C == '{'; });
+  // If there is more than one brace, then some of them are escaped.  Treat
+  // these as replacements.
+  if (Braces.size() > 1) {
+size_t NumEscapedBraces = Braces.size() / 2;
+StringRef Middle = Fmt.take_front(NumEscapedBraces);
+StringRef Right = Fmt.drop_front(NumEscapedBraces * 2);
+return std::make_pair(ReplacementItem(Middle), Right);
   }
-  return std::make_pair(ReplacementItem{Fmt}, StringRef());
+  // An unterminated open brace is undefined. Assert to indicate that this is
+  // undefined and that we consider it an error. When asserts are disabled,
+  // build a replacement item with an error message.
+  std::size_t BC = Fmt.find_first_of('}');
+  if (BC == StringRef::npos)
+return "Unterminated brace sequence. Escape with {{ for a literal brace.";
+
+  // Even if there is a closing brace, if there is another open brace before
+  // this closing brace, treat this portion as literal, and try again with the
+  // next one.
+  std::size_t BO2 = Fmt.find_first_of('{', 1);
+  if (BO2 < BC)
+return std::make_pair(ReplacementItem{Fmt.substr(0, BO2)}, 
Fmt.substr(BO2));
+
+  StringRef Spec = Fmt.slice(1, BC);
+  StringRef Right = Fmt.substr(BC + 1);
+
+  auto RI = parseReplacementItem(Spec);
+  if (const StringRef *ErrMsg = std::get_if<1>(&RI))
+return *ErrMsg;
+
+  return std::make_pair(std::get<0>(RI), Right);
 }
 
-SmallVector
-format

[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Rahul Joshi via lldb-commits

jurahul wrote:

> compile-time tests with clang for example

I can check. How do I run them?

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


[Lldb-commits] [lldb] [LLDB][SBSaveCore] Add selectable memory regions to SBSaveCore (PR #105442)

2024-08-27 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

@medismailben Ack

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Mehdi Amini via lldb-commits


@@ -67,92 +68,123 @@ formatv_object_base::parseReplacementItem(StringRef Spec) {
   StringRef Options;
   size_t Index = 0;
   RepString = RepString.trim();
-  if (RepString.consumeInteger(0, Index)) {
-assert(false && "Invalid replacement sequence index!");
-return ReplacementItem{};
-  }
+  if (RepString.consumeInteger(0, Index))
+return "Invalid replacement sequence index!";
   RepString = RepString.trim();
   if (RepString.consume_front(",")) {
 if (!consumeFieldLayout(RepString, Where, Align, Pad))
-  assert(false && "Invalid replacement field layout specification!");
+  return "Invalid replacement field layout specification!";
   }
   RepString = RepString.trim();
   if (RepString.consume_front(":")) {
 Options = RepString.trim();
 RepString = StringRef();
   }
   RepString = RepString.trim();
-  if (!RepString.empty()) {
-assert(false && "Unexpected characters found in replacement string!");
-  }
-
+  if (!RepString.empty())
+return "Unexpected character found in replacement string!";
   return ReplacementItem{Spec, Index, Align, Where, Pad, Options};
 }
 
-std::pair
-formatv_object_base::splitLiteralAndReplacement(StringRef Fmt) {
-  while (!Fmt.empty()) {
-// Everything up until the first brace is a literal.
-if (Fmt.front() != '{') {
-  std::size_t BO = Fmt.find_first_of('{');
-  return std::make_pair(ReplacementItem{Fmt.substr(0, BO)}, 
Fmt.substr(BO));
-}
-
-StringRef Braces = Fmt.take_while([](char C) { return C == '{'; });
-// If there is more than one brace, then some of them are escaped.  Treat
-// these as replacements.
-if (Braces.size() > 1) {
-  size_t NumEscapedBraces = Braces.size() / 2;
-  StringRef Middle = Fmt.take_front(NumEscapedBraces);
-  StringRef Right = Fmt.drop_front(NumEscapedBraces * 2);
-  return std::make_pair(ReplacementItem{Middle}, Right);
-}
-// An unterminated open brace is undefined. Assert to indicate that this is
-// undefined and that we consider it an error. When asserts are disabled,
-// build a replacement item with an error message.
-std::size_t BC = Fmt.find_first_of('}');
-if (BC == StringRef::npos) {
-  assert(
-  false &&
-  "Unterminated brace sequence. Escape with {{ for a literal brace.");
-  return std::make_pair(
-  ReplacementItem{"Unterminated brace sequence. Escape with {{ for a "
-  "literal brace."},
-  StringRef());
-}
-
-// Even if there is a closing brace, if there is another open brace before
-// this closing brace, treat this portion as literal, and try again with 
the
-// next one.
-std::size_t BO2 = Fmt.find_first_of('{', 1);
-if (BO2 < BC)
-  return std::make_pair(ReplacementItem{Fmt.substr(0, BO2)},
-Fmt.substr(BO2));
-
-StringRef Spec = Fmt.slice(1, BC);
-StringRef Right = Fmt.substr(BC + 1);
-
-auto RI = parseReplacementItem(Spec);
-if (RI)
-  return std::make_pair(*RI, Right);
+static std::variant, StringRef>
+splitLiteralAndReplacement(StringRef Fmt) {
+  // Everything up until the first brace is a literal.
+  if (Fmt.front() != '{') {
+std::size_t BO = Fmt.find_first_of('{');
+return std::make_pair(ReplacementItem(Fmt.substr(0, BO)), Fmt.substr(BO));
+  }
 
-// If there was an error parsing the replacement item, treat it as an
-// invalid replacement spec, and just continue.
-Fmt = Fmt.drop_front(BC + 1);
+  StringRef Braces = Fmt.take_while([](char C) { return C == '{'; });
+  // If there is more than one brace, then some of them are escaped.  Treat
+  // these as replacements.
+  if (Braces.size() > 1) {
+size_t NumEscapedBraces = Braces.size() / 2;
+StringRef Middle = Fmt.take_front(NumEscapedBraces);
+StringRef Right = Fmt.drop_front(NumEscapedBraces * 2);
+return std::make_pair(ReplacementItem(Middle), Right);
   }
-  return std::make_pair(ReplacementItem{Fmt}, StringRef());
+  // An unterminated open brace is undefined. Assert to indicate that this is
+  // undefined and that we consider it an error. When asserts are disabled,
+  // build a replacement item with an error message.
+  std::size_t BC = Fmt.find_first_of('}');
+  if (BC == StringRef::npos)
+return "Unterminated brace sequence. Escape with {{ for a literal brace.";
+
+  // Even if there is a closing brace, if there is another open brace before
+  // this closing brace, treat this portion as literal, and try again with the
+  // next one.
+  std::size_t BO2 = Fmt.find_first_of('{', 1);
+  if (BO2 < BC)
+return std::make_pair(ReplacementItem{Fmt.substr(0, BO2)}, 
Fmt.substr(BO2));
+
+  StringRef Spec = Fmt.slice(1, BC);
+  StringRef Right = Fmt.substr(BC + 1);
+
+  auto RI = parseReplacementItem(Spec);
+  if (const StringRef *ErrMsg = std::get_if<1>(&RI))
+return *ErrMsg;
+
+  return std::make_pair(std::get<0>(RI), Right);
 }
 
-SmallVector
-format

[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Rahul Joshi via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Rahul Joshi via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Fix test expectation in `TestFrameRecognizer.py` (PR #106281)

2024-08-27 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang created 
https://github.com/llvm/llvm-project/pull/106281

None

>From 2fdc99f2e42ac7bc12449e420ff653fb963cee24 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Tue, 27 Aug 2024 20:14:36 +
Subject: [PATCH] [lldb] Fix test expectation in `TestFrameRecognizer.py`

---
 lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py 
b/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
index e25df2b6cdc245..0621fdbc669193 100644
--- a/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
+++ b/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
@@ -58,7 +58,7 @@ def test_frame_recognizer_1(self):
 self.expect(
 "frame recognizer list",
 substrs=[
-"1: recognizer.MyOtherFrameRecognizer, module a.out, demangled 
symbol bar (regexp)"
+"1: recognizer.MyOtherFrameRecognizer, module a.out, demangled 
symbol regex bar"
 ],
 )
 self.expect(

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


[Lldb-commits] [lldb] [lldb] Fix test expectation in `TestFrameRecognizer.py` (PR #106281)

2024-08-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Adrian Vogelsgesang (vogelsgesang)


Changes



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


1 Files Affected:

- (modified) lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py 
(+1-1) 


``diff
diff --git a/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py 
b/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
index e25df2b6cdc245..0621fdbc669193 100644
--- a/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
+++ b/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
@@ -58,7 +58,7 @@ def test_frame_recognizer_1(self):
 self.expect(
 "frame recognizer list",
 substrs=[
-"1: recognizer.MyOtherFrameRecognizer, module a.out, demangled 
symbol bar (regexp)"
+"1: recognizer.MyOtherFrameRecognizer, module a.out, demangled 
symbol regex bar"
 ],
 )
 self.expect(

``




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


[Lldb-commits] [lldb] [lldb] Add frame recognizers for libc++ `std::invoke` (PR #105695)

2024-08-27 Thread Adrian Vogelsgesang via lldb-commits

vogelsgesang wrote:

fixed in #106281

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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Rahul Joshi via lldb-commits

jurahul wrote:

> > compile-time tests with clang for example
> 
> I can check. How do I run them?

I am wondering if running mlir-tblgen is a better benchmark, given that 
formatv() is widely used there (as opposed to clang), in case this measurement 
has to be done manually.

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


[Lldb-commits] [lldb] [lldb] Fix test expectation in `TestFrameRecognizer.py` (PR #106281)

2024-08-27 Thread Adrian Vogelsgesang via lldb-commits

https://github.com/vogelsgesang updated 
https://github.com/llvm/llvm-project/pull/106281

>From b32e85a07ab0e6dc55d28706d50eb84345575bc6 Mon Sep 17 00:00:00 2001
From: Adrian Vogelsgesang 
Date: Tue, 27 Aug 2024 20:14:36 +
Subject: [PATCH] [lldb] Fix test expectation in `TestFrameRecognizer.py`

---
 .../test/API/commands/frame/recognizer/TestFrameRecognizer.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py 
b/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
index e25df2b6cdc245..24d6a67c0ccd48 100644
--- a/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
+++ b/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
@@ -58,7 +58,7 @@ def test_frame_recognizer_1(self):
 self.expect(
 "frame recognizer list",
 substrs=[
-"1: recognizer.MyOtherFrameRecognizer, module a.out, demangled 
symbol bar (regexp)"
+"1: recognizer.MyOtherFrameRecognizer, module a.out, demangled 
symbol regex bar"
 ],
 )
 self.expect(
@@ -81,7 +81,7 @@ def test_frame_recognizer_1(self):
 self.expect(
 "frame recognizer list",
 substrs=[
-"1: recognizer.MyOtherFrameRecognizer, module a.out, demangled 
symbol regexp bar"
+"1: recognizer.MyOtherFrameRecognizer, module a.out, demangled 
symbol regex bar"
 ],
 )
 self.expect(

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


[Lldb-commits] [lldb] [lldb] Fix test expectation in `TestFrameRecognizer.py` (PR #106281)

2024-08-27 Thread Adrian Vogelsgesang via lldb-commits

vogelsgesang wrote:

@adrian-prantl It seems I overlooked this test expectation. This hopefully 
fixes the build issue in 
https://green.lab.llvm.org/job/llvm.org/view/LLDB/job/as-lldb-cmake/10463/ . 
Unfortunately, i was not able to run this test locally, it is marked as 
"unsupported" for some reason

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


[Lldb-commits] [lldb] [lldb] Fix test expectation in `TestFrameRecognizer.py` (PR #106281)

2024-08-27 Thread Michael Buch via lldb-commits

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


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


[Lldb-commits] [clang] [lldb] [llvm] [mlir] [Support] Validate number of arguments passed to formatv() (PR #105745)

2024-08-27 Thread Mehdi Amini via lldb-commits

joker-eph wrote:

Possible, let's try it there then

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


[Lldb-commits] [lldb] fc51797 - [lldb] Fix test expectation in `TestFrameRecognizer.py` (#106281)

2024-08-27 Thread via lldb-commits

Author: Adrian Vogelsgesang
Date: 2024-08-27T22:59:14+02:00
New Revision: fc517973c299d879f0795d37500a7db1f4d63588

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

LOG: [lldb] Fix test expectation in `TestFrameRecognizer.py` (#106281)

Added: 


Modified: 
lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py

Removed: 




diff  --git a/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py 
b/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
index e25df2b6cdc245..24d6a67c0ccd48 100644
--- a/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
+++ b/lldb/test/API/commands/frame/recognizer/TestFrameRecognizer.py
@@ -58,7 +58,7 @@ def test_frame_recognizer_1(self):
 self.expect(
 "frame recognizer list",
 substrs=[
-"1: recognizer.MyOtherFrameRecognizer, module a.out, demangled 
symbol bar (regexp)"
+"1: recognizer.MyOtherFrameRecognizer, module a.out, demangled 
symbol regex bar"
 ],
 )
 self.expect(
@@ -81,7 +81,7 @@ def test_frame_recognizer_1(self):
 self.expect(
 "frame recognizer list",
 substrs=[
-"1: recognizer.MyOtherFrameRecognizer, module a.out, demangled 
symbol regexp bar"
+"1: recognizer.MyOtherFrameRecognizer, module a.out, demangled 
symbol regex bar"
 ],
 )
 self.expect(



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


[Lldb-commits] [lldb] [lldb] Fix test expectation in `TestFrameRecognizer.py` (PR #106281)

2024-08-27 Thread Adrian Vogelsgesang via lldb-commits

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


[Lldb-commits] [lldb] Revert "[LLDB][SBSaveCore] Add selectable memory regions to SBSaveCor… (PR #106293)

2024-08-27 Thread Jacob Lalonde via lldb-commits

https://github.com/Jlalond created 
https://github.com/llvm/llvm-project/pull/106293

Reverts #105442. Due to `TestSkinnyCoreFailing` and root causing of the failure 
will likely take longer than EOD.

>From b0caffa2d427ea94e90186e32125452ab4e1dd1e Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Tue, 27 Aug 2024 14:18:47 -0700
Subject: [PATCH] Revert "[LLDB][SBSaveCore] Add selectable memory regions to
 SBSaveCore (#105442)"

This reverts commit d517b224117f760e6a7299b267256e3240c04edb.
---
 lldb/include/lldb/API/SBMemoryRegionInfo.h|   2 +-
 lldb/include/lldb/API/SBSaveCoreOptions.h |  11 --
 lldb/include/lldb/Symbol/SaveCoreOptions.h|  11 +-
 lldb/include/lldb/Target/Process.h|   5 +-
 lldb/include/lldb/Utility/RangeMap.h  |   2 -
 lldb/include/lldb/lldb-enumerations.h |   1 -
 lldb/include/lldb/lldb-forward.h  |   1 -
 lldb/include/lldb/lldb-private-interfaces.h   |   1 +
 lldb/source/API/SBSaveCoreOptions.cpp |  11 --
 lldb/source/Commands/CommandObjectProcess.cpp |   1 -
 .../ObjectFile/Mach-O/ObjectFileMachO.cpp |   4 +-
 .../ObjectFile/Mach-O/ObjectFileMachO.h   |   1 -
 .../Minidump/MinidumpFileBuilder.cpp  |  33 ++--
 .../ObjectFile/Minidump/MinidumpFileBuilder.h |   9 +-
 .../ObjectFile/Minidump/ObjectFileMinidump.h  |   1 -
 .../ObjectFile/PECOFF/ObjectFilePECOFF.cpp|   1 -
 .../ObjectFile/PECOFF/ObjectFilePECOFF.h  |   1 -
 lldb/source/Symbol/SaveCoreOptions.cpp|  14 --
 lldb/source/Target/Process.cpp|  70 +---
 .../TestProcessSaveCoreMinidump.py| 158 +-
 20 files changed, 33 insertions(+), 305 deletions(-)

diff --git a/lldb/include/lldb/API/SBMemoryRegionInfo.h 
b/lldb/include/lldb/API/SBMemoryRegionInfo.h
index f9a5dc993d7cb6..be55de4ead1fa8 100644
--- a/lldb/include/lldb/API/SBMemoryRegionInfo.h
+++ b/lldb/include/lldb/API/SBMemoryRegionInfo.h
@@ -120,7 +120,7 @@ class LLDB_API SBMemoryRegionInfo {
 private:
   friend class SBProcess;
   friend class SBMemoryRegionInfoList;
-  friend class SBSaveCoreOptions;
+
   friend class lldb_private::ScriptInterpreter;
 
   lldb_private::MemoryRegionInfo &ref();
diff --git a/lldb/include/lldb/API/SBSaveCoreOptions.h 
b/lldb/include/lldb/API/SBSaveCoreOptions.h
index c076d3ce6f7575..ba48ba5eaea5a0 100644
--- a/lldb/include/lldb/API/SBSaveCoreOptions.h
+++ b/lldb/include/lldb/API/SBSaveCoreOptions.h
@@ -80,17 +80,6 @@ class LLDB_API SBSaveCoreOptions {
   /// \return True if the thread was removed, false if it was not in the list.
   bool RemoveThread(lldb::SBThread thread);
 
-  /// Add a memory region to save in the core file.
-  ///
-  /// \param region The memory region to save.
-  /// \returns An empty SBError upon success, or an error if the region is
-  /// invalid.
-  /// \note Ranges that overlapped will be unioned into a single region, this
-  /// also supercedes stack minification. Specifying full regions and a
-  /// non-custom core style will include the specified regions and union them
-  /// with all style specific regions.
-  SBError AddMemoryRegionToSave(const SBMemoryRegionInfo ®ion);
-
   /// Reset all options.
   void Clear();
 
diff --git a/lldb/include/lldb/Symbol/SaveCoreOptions.h 
b/lldb/include/lldb/Symbol/SaveCoreOptions.h
index d90d08026016dc..f4fed4676fa4ae 100644
--- a/lldb/include/lldb/Symbol/SaveCoreOptions.h
+++ b/lldb/include/lldb/Symbol/SaveCoreOptions.h
@@ -10,15 +10,13 @@
 #define LLDB_SOURCE_PLUGINS_OBJECTFILE_SaveCoreOPTIONS_H
 
 #include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/RangeMap.h"
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-types.h"
 
 #include 
-#include 
 #include 
 #include 
 
-using MemoryRanges = lldb_private::RangeVector;
-
 namespace lldb_private {
 
 class SaveCoreOptions {
@@ -40,12 +38,8 @@ class SaveCoreOptions {
   Status AddThread(lldb::ThreadSP thread_sp);
   bool RemoveThread(lldb::ThreadSP thread_sp);
   bool ShouldThreadBeSaved(lldb::tid_t tid) const;
-  bool HasSpecifiedThreads() const;
 
   Status EnsureValidConfiguration(lldb::ProcessSP process_sp) const;
-  const MemoryRanges &GetCoreFileMemoryRanges() const;
-
-  void AddMemoryRegionToSave(const lldb_private::MemoryRegionInfo ®ion);
 
   void Clear();
 
@@ -57,7 +51,6 @@ class SaveCoreOptions {
   std::optional m_style;
   lldb::ProcessSP m_process_sp;
   std::unordered_set m_threads_to_save;
-  MemoryRanges m_regions_to_save;
 };
 } // namespace lldb_private
 
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 6506f8f9c16167..a7de991104434d 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -35,7 +35,6 @@
 #include "lldb/Host/ProcessLaunchInfo.h"
 #include "lldb/Host/ProcessRunLock.h"
 #include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/SaveCoreOptions.h"
 #include "lldb/Target/ExecutionContextScope.h"
 #include "lldb/Target/InstrumentationRuntime.h"
 #include "lldb/Target/Memory.h"
@@ 

[Lldb-commits] [lldb] Revert "[LLDB][SBSaveCore] Add selectable memory regions to SBSaveCor… (PR #106293)

2024-08-27 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)


Changes

Reverts #105442. Due to `TestSkinnyCoreFailing` and root causing of the 
failure will likely take longer than EOD.

---

Patch is 29.32 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/106293.diff


20 Files Affected:

- (modified) lldb/include/lldb/API/SBMemoryRegionInfo.h (+1-1) 
- (modified) lldb/include/lldb/API/SBSaveCoreOptions.h (-11) 
- (modified) lldb/include/lldb/Symbol/SaveCoreOptions.h (+2-9) 
- (modified) lldb/include/lldb/Target/Process.h (+1-4) 
- (modified) lldb/include/lldb/Utility/RangeMap.h (-2) 
- (modified) lldb/include/lldb/lldb-enumerations.h (-1) 
- (modified) lldb/include/lldb/lldb-forward.h (-1) 
- (modified) lldb/include/lldb/lldb-private-interfaces.h (+1) 
- (modified) lldb/source/API/SBSaveCoreOptions.cpp (-11) 
- (modified) lldb/source/Commands/CommandObjectProcess.cpp (-1) 
- (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (+1-3) 
- (modified) lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (-1) 
- (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
(+13-20) 
- (modified) lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
(+4-5) 
- (modified) lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h (-1) 
- (modified) lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp (-1) 
- (modified) lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h (-1) 
- (modified) lldb/source/Symbol/SaveCoreOptions.cpp (-14) 
- (modified) lldb/source/Target/Process.cpp (+8-62) 
- (modified) 
lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
 (+2-156) 


``diff
diff --git a/lldb/include/lldb/API/SBMemoryRegionInfo.h 
b/lldb/include/lldb/API/SBMemoryRegionInfo.h
index f9a5dc993d7cb6..be55de4ead1fa8 100644
--- a/lldb/include/lldb/API/SBMemoryRegionInfo.h
+++ b/lldb/include/lldb/API/SBMemoryRegionInfo.h
@@ -120,7 +120,7 @@ class LLDB_API SBMemoryRegionInfo {
 private:
   friend class SBProcess;
   friend class SBMemoryRegionInfoList;
-  friend class SBSaveCoreOptions;
+
   friend class lldb_private::ScriptInterpreter;
 
   lldb_private::MemoryRegionInfo &ref();
diff --git a/lldb/include/lldb/API/SBSaveCoreOptions.h 
b/lldb/include/lldb/API/SBSaveCoreOptions.h
index c076d3ce6f7575..ba48ba5eaea5a0 100644
--- a/lldb/include/lldb/API/SBSaveCoreOptions.h
+++ b/lldb/include/lldb/API/SBSaveCoreOptions.h
@@ -80,17 +80,6 @@ class LLDB_API SBSaveCoreOptions {
   /// \return True if the thread was removed, false if it was not in the list.
   bool RemoveThread(lldb::SBThread thread);
 
-  /// Add a memory region to save in the core file.
-  ///
-  /// \param region The memory region to save.
-  /// \returns An empty SBError upon success, or an error if the region is
-  /// invalid.
-  /// \note Ranges that overlapped will be unioned into a single region, this
-  /// also supercedes stack minification. Specifying full regions and a
-  /// non-custom core style will include the specified regions and union them
-  /// with all style specific regions.
-  SBError AddMemoryRegionToSave(const SBMemoryRegionInfo ®ion);
-
   /// Reset all options.
   void Clear();
 
diff --git a/lldb/include/lldb/Symbol/SaveCoreOptions.h 
b/lldb/include/lldb/Symbol/SaveCoreOptions.h
index d90d08026016dc..f4fed4676fa4ae 100644
--- a/lldb/include/lldb/Symbol/SaveCoreOptions.h
+++ b/lldb/include/lldb/Symbol/SaveCoreOptions.h
@@ -10,15 +10,13 @@
 #define LLDB_SOURCE_PLUGINS_OBJECTFILE_SaveCoreOPTIONS_H
 
 #include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/RangeMap.h"
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-types.h"
 
 #include 
-#include 
 #include 
 #include 
 
-using MemoryRanges = lldb_private::RangeVector;
-
 namespace lldb_private {
 
 class SaveCoreOptions {
@@ -40,12 +38,8 @@ class SaveCoreOptions {
   Status AddThread(lldb::ThreadSP thread_sp);
   bool RemoveThread(lldb::ThreadSP thread_sp);
   bool ShouldThreadBeSaved(lldb::tid_t tid) const;
-  bool HasSpecifiedThreads() const;
 
   Status EnsureValidConfiguration(lldb::ProcessSP process_sp) const;
-  const MemoryRanges &GetCoreFileMemoryRanges() const;
-
-  void AddMemoryRegionToSave(const lldb_private::MemoryRegionInfo ®ion);
 
   void Clear();
 
@@ -57,7 +51,6 @@ class SaveCoreOptions {
   std::optional m_style;
   lldb::ProcessSP m_process_sp;
   std::unordered_set m_threads_to_save;
-  MemoryRanges m_regions_to_save;
 };
 } // namespace lldb_private
 
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 6506f8f9c16167..a7de991104434d 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -35,7 +35,6 @@
 #include "lldb/Host/ProcessLaunchInfo.h"
 #include "lldb/Host/ProcessRunLock.h"
 #include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/SaveCoreOptions.h"
 #include "lldb/Target/ExecutionContextScope.h"
 #include "lldb/Target/In

[Lldb-commits] [lldb] b959532 - Revert "[LLDB][SBSaveCore] Add selectable memory regions to SBSaveCor… (#106293)

2024-08-27 Thread via lldb-commits

Author: Jacob Lalonde
Date: 2024-08-27T14:23:00-07:00
New Revision: b9595324846a96dd3443359a62c70cec5aa352b8

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

LOG: Revert "[LLDB][SBSaveCore] Add selectable memory regions to SBSaveCor… 
(#106293)

Reverts #105442. Due to `TestSkinnyCoreFailing` and root causing of the
failure will likely take longer than EOD.

Added: 


Modified: 
lldb/include/lldb/API/SBMemoryRegionInfo.h
lldb/include/lldb/API/SBSaveCoreOptions.h
lldb/include/lldb/Symbol/SaveCoreOptions.h
lldb/include/lldb/Target/Process.h
lldb/include/lldb/Utility/RangeMap.h
lldb/include/lldb/lldb-enumerations.h
lldb/include/lldb/lldb-forward.h
lldb/include/lldb/lldb-private-interfaces.h
lldb/source/API/SBSaveCoreOptions.cpp
lldb/source/Commands/CommandObjectProcess.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h
lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h
lldb/source/Symbol/SaveCoreOptions.cpp
lldb/source/Target/Process.cpp

lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py

Removed: 




diff  --git a/lldb/include/lldb/API/SBMemoryRegionInfo.h 
b/lldb/include/lldb/API/SBMemoryRegionInfo.h
index f9a5dc993d7cb6..be55de4ead1fa8 100644
--- a/lldb/include/lldb/API/SBMemoryRegionInfo.h
+++ b/lldb/include/lldb/API/SBMemoryRegionInfo.h
@@ -120,7 +120,7 @@ class LLDB_API SBMemoryRegionInfo {
 private:
   friend class SBProcess;
   friend class SBMemoryRegionInfoList;
-  friend class SBSaveCoreOptions;
+
   friend class lldb_private::ScriptInterpreter;
 
   lldb_private::MemoryRegionInfo &ref();

diff  --git a/lldb/include/lldb/API/SBSaveCoreOptions.h 
b/lldb/include/lldb/API/SBSaveCoreOptions.h
index c076d3ce6f7575..ba48ba5eaea5a0 100644
--- a/lldb/include/lldb/API/SBSaveCoreOptions.h
+++ b/lldb/include/lldb/API/SBSaveCoreOptions.h
@@ -80,17 +80,6 @@ class LLDB_API SBSaveCoreOptions {
   /// \return True if the thread was removed, false if it was not in the list.
   bool RemoveThread(lldb::SBThread thread);
 
-  /// Add a memory region to save in the core file.
-  ///
-  /// \param region The memory region to save.
-  /// \returns An empty SBError upon success, or an error if the region is
-  /// invalid.
-  /// \note Ranges that overlapped will be unioned into a single region, this
-  /// also supercedes stack minification. Specifying full regions and a
-  /// non-custom core style will include the specified regions and union them
-  /// with all style specific regions.
-  SBError AddMemoryRegionToSave(const SBMemoryRegionInfo ®ion);
-
   /// Reset all options.
   void Clear();
 

diff  --git a/lldb/include/lldb/Symbol/SaveCoreOptions.h 
b/lldb/include/lldb/Symbol/SaveCoreOptions.h
index d90d08026016dc..f4fed4676fa4ae 100644
--- a/lldb/include/lldb/Symbol/SaveCoreOptions.h
+++ b/lldb/include/lldb/Symbol/SaveCoreOptions.h
@@ -10,15 +10,13 @@
 #define LLDB_SOURCE_PLUGINS_OBJECTFILE_SaveCoreOPTIONS_H
 
 #include "lldb/Utility/FileSpec.h"
-#include "lldb/Utility/RangeMap.h"
+#include "lldb/lldb-forward.h"
+#include "lldb/lldb-types.h"
 
 #include 
-#include 
 #include 
 #include 
 
-using MemoryRanges = lldb_private::RangeVector;
-
 namespace lldb_private {
 
 class SaveCoreOptions {
@@ -40,12 +38,8 @@ class SaveCoreOptions {
   Status AddThread(lldb::ThreadSP thread_sp);
   bool RemoveThread(lldb::ThreadSP thread_sp);
   bool ShouldThreadBeSaved(lldb::tid_t tid) const;
-  bool HasSpecifiedThreads() const;
 
   Status EnsureValidConfiguration(lldb::ProcessSP process_sp) const;
-  const MemoryRanges &GetCoreFileMemoryRanges() const;
-
-  void AddMemoryRegionToSave(const lldb_private::MemoryRegionInfo ®ion);
 
   void Clear();
 
@@ -57,7 +51,6 @@ class SaveCoreOptions {
   std::optional m_style;
   lldb::ProcessSP m_process_sp;
   std::unordered_set m_threads_to_save;
-  MemoryRanges m_regions_to_save;
 };
 } // namespace lldb_private
 

diff  --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index 6506f8f9c16167..a7de991104434d 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -35,7 +35,6 @@
 #include "lldb/Host/ProcessLaunchInfo.h"
 #include "lldb/Host/ProcessRunLock.h"
 #include "lldb/Symbol/ObjectFile.h"
-#include "lldb/Symbol/SaveCoreOptions.h"
 #include "lldb/Target/ExecutionContextScope.h"
 #include "lldb/Target/InstrumentationRuntime.h"
 #include "lldb/Target/Memory.h"
@@ -7

[Lldb-commits] [lldb] Revert "[LLDB][SBSaveCore] Add selectable memory regions to SBSaveCor… (PR #106293)

2024-08-27 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [lldb] Revert "[LLDB][SBSaveCore] Add selectable memory regions to SBSaveCor… (PR #106293)

2024-08-27 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
4ea2c73886c407d47215484ab6c983ac6189dd14...b0caffa2d427ea94e90186e32125452ab4e1dd1e
 
lldb/test/API/functionalities/process_save_core_minidump/TestProcessSaveCoreMinidump.py
``





View the diff from darker here.


``diff
--- TestProcessSaveCoreMinidump.py  2024-08-27 21:18:47.00 +
+++ TestProcessSaveCoreMinidump.py  2024-08-27 21:24:03.152814 +
@@ -281,22 +281,27 @@
 thread = process.GetThreadAtIndex(thread_idx)
 thread_id = thread.GetThreadID()
 expected_threads.append(thread_id)
 stacks_to_sp_map[thread_id] = thread.GetFrameAtIndex(0).GetSP()
 
-
 # This is almost identical to the single thread test case because
 # minidump defaults to stacks only, so we want to see if the
 # default options work as expected.
 options = lldb.SBSaveCoreOptions()
 default_value_spec = lldb.SBFileSpec(default_value_file)
 options.SetOutputFile(default_value_spec)
 options.SetPluginName("minidump")
 error = process.SaveCore(options)
 self.assertTrue(error.Success())
 
-self.verify_core_file(default_value_file, expected_pid, 
expected_modules, expected_threads, stacks_to_sp_map)
+self.verify_core_file(
+default_value_file,
+expected_pid,
+expected_modules,
+expected_threads,
+stacks_to_sp_map,
+)
 
 finally:
 self.assertTrue(self.dbg.DeleteTarget(target))
 if os.path.isfile(default_value_file):
 os.unlink(default_value_file)

``




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


[Lldb-commits] [lldb] Revert "[LLDB][SBSaveCore] Add selectable memory regions to SBSaveCor… (PR #106293)

2024-08-27 Thread via lldb-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 4ea2c73886c407d47215484ab6c983ac6189dd14 
b0caffa2d427ea94e90186e32125452ab4e1dd1e --extensions cpp,h -- 
lldb/include/lldb/API/SBMemoryRegionInfo.h 
lldb/include/lldb/API/SBSaveCoreOptions.h 
lldb/include/lldb/Symbol/SaveCoreOptions.h lldb/include/lldb/Target/Process.h 
lldb/include/lldb/Utility/RangeMap.h lldb/include/lldb/lldb-enumerations.h 
lldb/include/lldb/lldb-forward.h lldb/include/lldb/lldb-private-interfaces.h 
lldb/source/API/SBSaveCoreOptions.cpp 
lldb/source/Commands/CommandObjectProcess.cpp 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp 
lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h 
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.cpp 
lldb/source/Plugins/ObjectFile/Minidump/MinidumpFileBuilder.h 
lldb/source/Plugins/ObjectFile/Minidump/ObjectFileMinidump.h 
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp 
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.h 
lldb/source/Symbol/SaveCoreOptions.cpp lldb/source/Target/Process.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index ae64f6f261..bda83c91c7 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -6607,7 +6607,7 @@ static void GetCoreFileSaveRangesFull(Process &process,
   std::set &stack_ends) {
 
   // Don't add only dirty pages, add full regions.
-const bool try_dirty_pages = false;
+  const bool try_dirty_pages = false;
   for (const auto ®ion : regions)
 if (stack_ends.count(region.GetRange().GetRangeEnd()) == 0)
   AddRegion(region, try_dirty_pages, ranges);

``




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


[Lldb-commits] [lldb] ff2baf0 - Revert "[lldb] Add transitional backwards-compatible API to Status"

2024-08-27 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-08-27T14:40:29-07:00
New Revision: ff2baf0360372a3762218b6db4beaf7117a4

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

LOG: Revert "[lldb] Add transitional backwards-compatible API to Status"

This reverts commit d1d8edf50449accf7896620afc0249af91354d17.

Added: 


Modified: 
lldb/include/lldb/Utility/Status.h

Removed: 




diff  --git a/lldb/include/lldb/Utility/Status.h 
b/lldb/include/lldb/Utility/Status.h
index 3104f1dfc6e4d2..b304291ffae00e 100644
--- a/lldb/include/lldb/Utility/Status.h
+++ b/lldb/include/lldb/Utility/Status.h
@@ -83,69 +83,6 @@ class Status {
 return Status(result, lldb::eErrorTypeExpression, msg);
   }
 
-  
-  // TO BE REMOVED ASAP.
-  // This is transitional to make it easier to iterate with broken bots.
-  
-  LLVM_DEPRECATED("Use Status::FromErrorString() instead", "FromErrorString")
-  explicit Status(const char *format, ...)
-  __attribute__((format(printf, 2, 3))) {
-// Yes, this drops the arguments.
-*this = Status::FromErrorString(format);
-  }
-  template 
-  static LLVM_DEPRECATED("Use Status::FromErrorStringWithFormat() instead",
- "FromErrorStringWithFormat") Status
-  createWithFormat(const char *format, Args &&...args) {
-return Status::FromErrorStringWithFormat(format,
- std::forward(args)...);
-  }
-  LLVM_DEPRECATED("Use Status::FromExpressionError() instead",
-  "FromExpressionError")
-  void SetExpressionError(lldb::ExpressionResults results, const char *msg) {
-*this = Status::FromExpressionError(results, msg);
-  }
-  LLVM_DEPRECATED("Use Status::FromExpressionError() instead",
-  "FromExpressionError")
-  int SetExpressionErrorWithFormat(lldb::ExpressionResults results,
-   const char *msg, ...) {
-*this = Status::FromExpressionError(results, msg);
-return 0;
-  }
-  LLVM_DEPRECATED("Use Status::Status() instead", "Status")
-  void SetError(ValueType err, lldb::ErrorType type) {
-Status error(err, lldb::eErrorTypeGeneric);
-*this = error;
-  }
-  LLVM_DEPRECATED("Use Status::FromErrNo() instead", "Status")
-  void SetErrorToErrno() { *this = Status::FromErrno(); }
-  LLVM_DEPRECATED("Use Status() instead", "Status")
-  void SetErrorToGenericError() {
-*this = Status::FromErrorString("generic error");
-  }
-  LLVM_DEPRECATED("Use Status::FromErrorString() instead", "Status")
-  void SetErrorString(llvm::StringRef err_str) {
-*this = Status::FromErrorString(err_str.str().c_str());
-  }
-  LLVM_DEPRECATED("Use Status::FromErrorStringWithFormat() instead", "Status")
-  int SetErrorStringWithFormat(const char *format, ...)
-  __attribute__((format(printf, 2, 3))) {
-*this = Status::FromErrorString(format);
-return 0;
-  }
-  LLVM_DEPRECATED("Use Status::FromErrorString() instead", "Status")
-  int SetErrorStringWithVarArg(const char *format, va_list args) {
-*this = Status::FromErrorString(format);
-return 0;
-  }
-  template 
-  LLVM_DEPRECATED("Use Status::FromErrorStringWithFormatv() instead", "Status")
-  void SetErrorStringWithFormatv(const char *format, Args &&...args) {
-*this =
-Status::FromErrorStringWithFormatv(format, 
std::forward(args)...);
-  }
-  
-
   /// Set the current error to errno.
   ///
   /// Update the error value to be \c errno and update the type to be \c



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


[Lldb-commits] [lldb] 67eb727 - [lldb] Update NativeProcessLinux to new Status API

2024-08-27 Thread Adrian Prantl via lldb-commits

Author: Adrian Prantl
Date: 2024-08-27T14:48:16-07:00
New Revision: 67eb72725d1e1c7e214c8f1feded99b152b76470

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

LOG: [lldb] Update NativeProcessLinux to new Status API

Added: 


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

Removed: 




diff  --git a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp 
b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
index 92fd2fcfe20c03..cb95da9fc72363 100644
--- a/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/NativeProcessLinux.cpp
@@ -203,12 +203,12 @@ static Status EnsureFDFlags(int fd, int flags) {
 
   int status = fcntl(fd, F_GETFL);
   if (status == -1) {
-error.SetErrorToErrno();
+error = Status::FromErrno();
 return error;
   }
 
   if (fcntl(fd, F_SETFL, status | flags) == -1) {
-error.SetErrorToErrno();
+error = Status::FromErrno();
 return error;
   }
 
@@ -1078,7 +1078,7 @@ Status NativeProcessLinux::Halt() {
   Status error;
 
   if (kill(GetID(), SIGSTOP) != 0)
-error.SetErrorToErrno();
+error = Status::FromErrno();
 
   return error;
 }
@@ -1114,7 +1114,7 @@ Status NativeProcessLinux::Signal(int signo) {
Host::GetSignalAsCString(signo), GetID());
 
   if (kill(GetID(), signo))
-error.SetErrorToErrno();
+error = Status::FromErrno();
 
   return error;
 }
@@ -1191,7 +1191,7 @@ Status NativeProcessLinux::Kill() {
   }
 
   if (kill(GetID(), SIGKILL) != 0) {
-error.SetErrorToErrno();
+error = Status::FromErrno();
 return error;
   }
 
@@ -2006,7 +2006,7 @@ Status NativeProcessLinux::PtraceWrapper(int req, 
lldb::pid_t pid, void *addr,
  addr, data);
 
   if (ret == -1)
-error.SetErrorToErrno();
+error = Status::FromErrno();
 
   if (result)
 *result = ret;



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


[Lldb-commits] [lldb] 3280292 - [lldb] Don't scan more than 10MB of assembly insns (#105890)

2024-08-27 Thread via lldb-commits

Author: Jason Molenda
Date: 2024-08-27T14:50:46-07:00
New Revision: 328029242136950204ce8bf953eb592bff946d30

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

LOG: [lldb] Don't scan more than 10MB of assembly insns (#105890)

For supported architectures, lldb will do a static scan of the assembly
instructions of a function to detect stack/frame pointer changes,
register stores and loads, so we can retrieve register values for the
caller stack frames. We trust that the function address range reflects
the actual function range, but in a stripped binary or other unusual
environment, we can end up scanning all of the text as a single
"function" which is (1) incorrect and useless, but more importantly (2)
slow.

Cap the max size we will profile to 10MB of instructions. There will
surely be functions longer than this with no unwind info, and we will
miss the final epilogue or mid-function epilogues past the first 10MB,
but I think this will be unusual, and the failure more to missing the
epilogue is that the user will need to step out an extra time or two as
the StackID is not correctly calculated mid-epilogue. I think this is a
good tradeoff of behaviors.

rdar://134391577

Added: 


Modified: 
lldb/source/Symbol/FuncUnwinders.cpp

Removed: 




diff  --git a/lldb/source/Symbol/FuncUnwinders.cpp 
b/lldb/source/Symbol/FuncUnwinders.cpp
index d67c0a828eb350..228d9a1072deca 100644
--- a/lldb/source/Symbol/FuncUnwinders.cpp
+++ b/lldb/source/Symbol/FuncUnwinders.cpp
@@ -334,12 +334,22 @@ UnwindPlanSP FuncUnwinders::GetAssemblyUnwindPlan(Target 
&target,
 
   m_tried_unwind_plan_assembly = true;
 
+  // Don't analyze more than 10 megabytes of instructions,
+  // if a function is legitimately larger than that, we'll
+  // miss the epilogue instructions, but guard against a
+  // bogusly large function and analyzing large amounts of
+  // non-instruction data.
+  AddressRange range = m_range;
+  const addr_t func_size =
+  std::min(range.GetByteSize(), (addr_t)1024 * 10 * 10);
+  range.SetByteSize(func_size);
+
   UnwindAssemblySP assembly_profiler_sp(GetUnwindAssemblyProfiler(target));
   if (assembly_profiler_sp) {
 m_unwind_plan_assembly_sp =
 std::make_shared(lldb::eRegisterKindGeneric);
 if (!assembly_profiler_sp->GetNonCallSiteUnwindPlanFromAssembly(
-m_range, thread, *m_unwind_plan_assembly_sp)) {
+range, thread, *m_unwind_plan_assembly_sp)) {
   m_unwind_plan_assembly_sp.reset();
 }
   }



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


[Lldb-commits] [lldb] [lldb] Don't scan more than 10MB of assembly insns (PR #105890)

2024-08-27 Thread Jason Molenda via lldb-commits

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


  1   2   >