[Lldb-commits] [lldb] [lldb] IRMemoryMap zero address mapping fix (PR #99045)

2024-07-19 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

I think we should change these checks to look for an explicitly inaccessible 
memory region, like 

```
   if (region_info.GetReadable() != MemoryRegionInfo::OptionalBool::eNo &&
region_info.GetWritable() != MemoryRegionInfo::OptionalBool::eNo &&
region_info.GetExecutable() !=
MemoryRegionInfo::OptionalBool::eNo) {
   // This region is inaccessible, if it is large enough, use this 
address.
   if (ret + size < region_info.GetRange().GetRangeEnd())
return ret;
   else 
 ret = region_info.GetRange().GetRangeEnd();
 // keep searching
```

and I also do think there is value in adding a special case for address 0.  
Even if we have an inaddressable memory block at address 0 which should be 
eligible for shadowing with lldb's host memory, using that is a poor choice 
because people crash at address 0 all the time and we don't want references to 
that address finding the IRMemoryMap host side memory values.

```
} else if (ret == 0) {
   // Don't put our host-side memory block at virtual address 0 even if 
it
   // seems eligible, we don't want to confuse things when a program 
   // crashes accessing that address, a common way of crashing.
   ret = region_info.GetRange().GetRangeEnd();
```



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


[Lldb-commits] [lldb] [llvm] [lldb][RISCV] function calls support in lldb expressions (PR #99336)

2024-07-19 Thread Jason Molenda via lldb-commits


@@ -0,0 +1,58 @@
+//===--- DirectToIndirectFCR.h - RISC-V specific pass 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#pragma once
+
+#include "lldb/lldb-types.h"
+
+#include "llvm/IR/Instructions.h"
+#include "llvm/Pass.h"
+
+namespace lldb_private {
+
+class ExecutionContext;
+
+// During the lldb expression execution lldb wraps a user expression, jittes
+// fabricated code and then puts it into the stack memory. Thus, if user tried

jasonmolenda wrote:

I don't think this is quite true.  lldb asks the remote stub to allocate memory 
with read+write permissions for storing the arguments, and read+execute 
permissions for the jitted code, e.g. 
```
(lldb) p (int)isdigit('1')
 <  13> send packet: $_M1000,rx#83
 <  13> read packet: $18000#00
 <  13> send packet: $_M1000,rw#82
 <  13> read packet: $1c000#00
```

It would be surprising (to me) if the stub returned memory regions on the 
stack, because lldb is allowed to reuse these regions throughout the debug 
session, and we can't have the inferior process overwriting them.

You are correct that the allocated regions may be too far from the function(s) 
they'll need to call, and the same problem you describe below could exist.  I 
don't mean to focus on the "stack memory" part of this, but I think it will 
confuse people when they read it.

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


[Lldb-commits] [lldb] [llvm] [lldb][RISCV] function calls support in lldb expressions (PR #99336)

2024-07-19 Thread Jason Molenda via lldb-commits


@@ -0,0 +1,58 @@
+//===--- DirectToIndirectFCR.h - RISC-V specific pass 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#pragma once
+
+#include "lldb/lldb-types.h"
+
+#include "llvm/IR/Instructions.h"
+#include "llvm/Pass.h"
+
+namespace lldb_private {
+
+class ExecutionContext;
+
+// During the lldb expression execution lldb wraps a user expression, jittes
+// fabricated code and then puts it into the stack memory. Thus, if user tried
+// to make a function call there will be a jump from a stack address to a code
+// sections's address. RISC-V Architecture doesn't have a large code model yet
+// and can make only a +-2GiB jumps, but in 64-bit architecture a distance
+// between stack addresses and code sections's addresses is longer. Therefore,
+// relocations resolver obtains an invalid address. To avoid such problem, this
+// pass should be used. It replaces function calls with appropriate function's
+// addresses explicitly. By doing so it removes relocations related to function
+// calls. This pass should be cosidered as temprorary solution until a large
+// code model will be approved.
+class DirectToIndirectFCR : public llvm::FunctionPass {

jasonmolenda wrote:

It's a minor detail, and I never work on the llvm side of the codebase so this 
is probably just my own ignorance, but: I have no idea what DirectToIndirectFCR 
means, beyond the explanation above.  I'm sure to people more familiar with 
llvm/clang this is clear.

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


[Lldb-commits] [lldb] [lldb][test] Add ABI library to Makefile.rules link flags (PR #99589)

2024-07-19 Thread Pavel Labath via lldb-commits

https://github.com/labath commented:

Libc++ supports a [large 
number](https://github.com/llvm/llvm-project/blob/6235698f47828747d3b1b0418e547e2e4ff9138f/libcxx/cmake/Modules/HandleLibCXXABI.cmake#L85)
 of configurations when in comes to the ABI library.

I think the most common are: shared-libcxx+shared-libcxxabi (where this change 
should be a no-op) and static-libcxx+static-libcxxabi (where this flag is 
required to build).

However, I also found evidence of configurations which embed the abi library 
into libcxx (which would break with this flag, as `-lc++abi` will find nothing, 
or the wrong library), or link the c++ library to the gnu abi library 
(libsupc++, where this flag would cause duplicate definitions or general 
weirdness).

If noone is using these configurations, then I think this patch is fine. If 
not, we will have to do something more elaborate. I suspect it's safe, but lets 
wait a while before committing to give people a chance to notice this.

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


[Lldb-commits] [lldb] [lldb] SHT_NOBITS sections type (PR #99044)

2024-07-19 Thread Pavel Labath via lldb-commits

labath wrote:

You're welcome. BTW, are you able to push the merge button, or do you need 
someone to do that for you?

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


[Lldb-commits] [lldb] [LLDB][test] Improve SHELL detection on Windows in Makefile.rules (PR #99532)

2024-07-19 Thread Pavel Labath via lldb-commits

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

lgtm

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


[Lldb-commits] [lldb] a27037b - [lldb] Forward-declare lldb-private::SaveCoreOptions

2024-07-19 Thread Pavel Labath via lldb-commits

Author: Pavel Labath
Date: 2024-07-19T11:37:29+02:00
New Revision: a27037becd1bdea568e2f970d4b85fa5e02f3b08

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

LOG: [lldb] Forward-declare lldb-private::SaveCoreOptions

to avoid including private headers from the API headers.

This fixes API tests which link against the lldb library.

Added: 


Modified: 
lldb/include/lldb/API/SBSaveCoreOptions.h
lldb/include/lldb/lldb-forward.h

Removed: 




diff  --git a/lldb/include/lldb/API/SBSaveCoreOptions.h 
b/lldb/include/lldb/API/SBSaveCoreOptions.h
index b8659bf128a78..e77496bd3a4a0 100644
--- a/lldb/include/lldb/API/SBSaveCoreOptions.h
+++ b/lldb/include/lldb/API/SBSaveCoreOptions.h
@@ -10,7 +10,6 @@
 #define LLDB_API_SBSAVECOREOPTIONS_H
 
 #include "lldb/API/SBDefines.h"
-#include "lldb/Symbol/SaveCoreOptions.h"
 
 namespace lldb {
 

diff  --git a/lldb/include/lldb/lldb-forward.h 
b/lldb/include/lldb/lldb-forward.h
index 9c946eaa19f0b..1024501e05bca 100644
--- a/lldb/include/lldb/lldb-forward.h
+++ b/lldb/include/lldb/lldb-forward.h
@@ -182,6 +182,7 @@ class RegisterTypeBuilder;
 class RegisterValue;
 class RegularExpression;
 class RichManglingContext;
+class SaveCoreOptions;
 class Scalar;
 class ScriptInterpreter;
 class ScriptInterpreterLocker;



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


[Lldb-commits] [lldb] [LLDB][test] Drop OS/HOST_OS detection code from Makefile.rules (PR #99535)

2024-07-19 Thread Pavel Labath via lldb-commits

labath wrote:

:partying_face: 

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


[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)

2024-07-19 Thread Pavel Labath via lldb-commits


@@ -263,9 +280,9 @@ CFLAGS += $(NO_LIMIT_DEBUG_INFO_FLAGS) $(ARCH_CFLAGS)
 
 # Use this one if you want to build one part of the result without debug 
information:
 ifeq "$(OS)" "Darwin"
-   CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) 
$(ARCH_CFLAGS) $(CFLAGS_EXTRAS) -isysroot "$(SDKROOT)"
+   CFLAGS_NO_DEBUG = -O0 $(ARCHFLAG) $(ARCH) $(FRAMEWORK_INCLUDES) 
$(ARCH_CFLAGS) $(CFLAGS_EXTRAS) $(SYSROOT_FLAGS)

labath wrote:

Right. I forgot about that quirk...

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


[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)

2024-07-19 Thread Pavel Labath via lldb-commits

labath wrote:

> > It may be better to split this into smaller patches, given the fragility of 
> > this code. (Basically, one patch for each of your bullet points).
> 
> I was thinking about that, but for me it looked like path_wrapper thing and 
> cross-compilation/sdkroot fixes should have been sent in the same commit 
> since each of them is insufficient for setting this configuration up on 
> Windows.

I understand. In terms of raw LOC, this patch isn't really big, but it has some 
fragile and potentially controversial parts, so I think it'd be easier to 
handle it in parts. Thanks for splitting it up.

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


[Lldb-commits] [lldb] [LLDB][test] Update Makefile.rules to support Windows host+Linux target (PR #99266)

2024-07-19 Thread Pavel Labath via lldb-commits

labath wrote:

> > What exactly does it help with? Given that you're canonicalizing to a 
> > forward slash, does that mean that some of the tools you use don't accept 
> > backslashes (perhaps because they come from cygwin or the like)?
> 
> As far as I understand, MinGW make, on which Chocolatey build is based, 
> prefers \ or / slashes.

I don't understand this sentence. Are you saying it prefers forward slashes or 
backward slashes (or uniform slashes)?

> Also, some include/library paths passed to clang seem to be 
> ignored/incorrectly processed, when they have mixed path separators like 
> C:\\foo/bar

This is interesting. I'm surprised that errors are coming from llvm tools, as 
the llvm path libraries treat forward and backward slashes (on windows) as 
equivalent at a very low level. Could you try to reduce this to a issue to 
figure out which specific slash in the command is causing the error? I want to 
make sure we're not working around a bug here...

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


[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBSaveCoreOptions Object, and SBProcess::SaveCore() overload (PR #98403)

2024-07-19 Thread Pavel Labath via lldb-commits

labath wrote:

Were those the same failures that were showing up on the buildbots? If not it 
could just be that there's an issue with your build configuration.

In this case, the fix was pretty simple (see 
a27037becd1bdea568e2f970d4b85fa5e02f3b08), but generally, if don't know what's 
the problem and you get a clear signal that this is a real failure and not a 
fluke (three builtbots going red at the same time is definitely sufficient 
signal), it's best to revert and figure out the problem later.

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


[Lldb-commits] [lldb] 243af2f - [LLDB][test] Improve SHELL detection on Windows in Makefile.rules (#99532)

2024-07-19 Thread via lldb-commits

Author: Vladislav Dzhidzhoev
Date: 2024-07-19T13:08:07+02:00
New Revision: 243af2ff217f65ef291232faa60779b86e01a967

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

LOG: [LLDB][test] Improve SHELL detection on Windows in Makefile.rules (#99532)

In MinGW make, the `%windir%` variable has a lowercase name `$(windir)`
when launched from cmd.exe, and `$(WINDIR)` name when launched from
MSYS2, since MSYS2 represents standard Windows environment variables
names in upper case.

This commit makes Makefile.rules consider both run variants.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 597aa94566c24..be3ad684dd736 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -55,8 +55,10 @@ LLDB_BASE_DIR := $(THIS_FILE_DIR)/../../../../../
 # Also reset BUILDDIR value because "pwd" returns cygwin or msys path
 # which needs to be converted to windows path.
 #--
-ifeq "$(OS)" "Windows_NT"
-   SHELL = $(WINDIR)\system32\cmd.exe
+ifeq "$(HOST_OS)" "Windows_NT"
+   # MinGW make gets $(windir) variable if launched from cmd.exe
+   # and $(WINDIR) if launched from MSYS2.
+   SHELL := $(or $(windir),$(WINDIR),C:\WINDOWS)\system32\cmd.exe
BUILDDIR := $(shell echo %cd%)
 endif
 



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


[Lldb-commits] [lldb] [LLDB][test] Improve SHELL detection on Windows in Makefile.rules (PR #99532)

2024-07-19 Thread Vladislav Dzhidzhoev via lldb-commits

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


[Lldb-commits] [lldb] [lldb] SHT_NOBITS sections type (PR #99044)

2024-07-19 Thread Pavel Labath via lldb-commits

labath wrote:

sure thing.

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


[Lldb-commits] [lldb] fdfc491 - [lldb] SHT_NOBITS sections type (#99044)

2024-07-19 Thread via lldb-commits

Author: dlav-sc
Date: 2024-07-19T13:22:18+02:00
New Revision: fdfc49186318727653cf6b13686bb77cfed60e33

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

LOG: [lldb] SHT_NOBITS sections type (#99044)

.sbss section was recognized as eSectionTypeOther, but has to be
eSectionTypeZeroFill.

Fixed tests for RISCV target:

TestClassLoadingViaMemberTypedef.TestCase

TestClassTemplateNonTypeParameterPack.TestCaseClassTemplateNonTypeParameterPack
TestThreadSelectionBug.TestThreadSelectionBug
lldbsuite.test.lldbtest.TestOffsetof
lldbsuite.test.lldbtest.TestOffsetofCpp
TestTargetDumpTypeSystem.TestCase
TestCPP11EnumTypes.CPP11EnumTypesTestCase
TestCppIsTypeComplete.TestCase
TestExprCrash.ExprCrashTestCase
TestDebugIndexCache.DebugIndexCacheTestcase

Added: 


Modified: 
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp

Removed: 




diff  --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp 
b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 51bd34e95c77d..890db5c274814 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -1696,7 +1696,6 @@ static SectionType GetSectionTypeFromName(llvm::StringRef 
Name) {
   return llvm::StringSwitch(Name)
   .Case(".ARM.exidx", eSectionTypeARMexidx)
   .Case(".ARM.extab", eSectionTypeARMextab)
-  .Cases(".bss", ".tbss", eSectionTypeZeroFill)
   .Case(".ctf", eSectionTypeDebug)
   .Cases(".data", ".tdata", eSectionTypeData)
   .Case(".eh_frame", eSectionTypeEHFrame)
@@ -1713,6 +1712,10 @@ SectionType ObjectFileELF::GetSectionType(const 
ELFSectionHeaderInfo &H) const {
 if (H.sh_flags & SHF_EXECINSTR)
   return eSectionTypeCode;
 break;
+  case SHT_NOBITS:
+if (H.sh_flags & SHF_ALLOC)
+  return eSectionTypeZeroFill;
+break;
   case SHT_SYMTAB:
 return eSectionTypeELFSymbolTable;
   case SHT_DYNSYM:



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


[Lldb-commits] [lldb] [lldb] SHT_NOBITS sections type (PR #99044)

2024-07-19 Thread Pavel Labath via lldb-commits

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


[Lldb-commits] [lldb] [lldb] SHT_NOBITS sections type (PR #99044)

2024-07-19 Thread via lldb-commits

github-actions[bot] wrote:



@dlav-sc 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/99044
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBSaveCoreOptions Object, and SBProcess::SaveCore() overload (PR #98403)

2024-07-19 Thread Leandro Lupori via lldb-commits

luporl wrote:

lldb-aarch64-windows is still failing: 
https://lab.llvm.org/buildbot/#/builders/141/builds/912

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


[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBSaveCoreOptions Object, and SBProcess::SaveCore() overload (PR #98403)

2024-07-19 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

> Were those the same failures that were showing up on the buildbots? If not it 
> could just be that there's an issue with your build configuration.
> 
> In this case, the fix was pretty simple (see 
> [a27037b](https://github.com/llvm/llvm-project/commit/a27037becd1bdea568e2f970d4b85fa5e02f3b08)),
>  but generally, if don't know what's the problem and you get a clear signal 
> that this is a real failure and not a fluke (three builtbots going red at the 
> same time is definitely sufficient signal), it's best to revert and figure 
> out the problem later.

Hey @labath appreciate the advice, and the help on forward fixing the issue!

@luporl I will look into Windows today.

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


[Lldb-commits] [clang] [lldb] [clang] Split ObjectFilePCHContainerReader from ObjectFilePCHContainerWriter (PR #99599)

2024-07-19 Thread Jan Svoboda via lldb-commits

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

LGTM sans the missing newline at the end of file and file headers not aligned 
to 80 columns.

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


[Lldb-commits] [clang] [lldb] [clang] Split ObjectFilePCHContainerReader from ObjectFilePCHContainerWriter (PR #99599)

2024-07-19 Thread Ben Langmuir via lldb-commits

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

LGTM other than what Jan already mentioned, thanks!

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben created 
https://github.com/llvm/llvm-project/pull/99673

This patch introduces a new method to the dynamic loader plugin, to fetch its 
`start` symbol.

This can be useful to resolve the `start` symbol address for instance.

>From 2e3064b3f1af9ea5b4930cf3fd87c9f48f462804 Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Fri, 19 Jul 2024 10:25:07 -0700
Subject: [PATCH] [lldb/Target] Add GetStartSymbol method to DynamicLoader
 plugins

This patch introduces a new method to the dynamic loader plugin, to
fetch its `start` symbol.

This can be useful to resolve the `start` symbol address for instance.

Signed-off-by: Med Ismail Bennani 
---
 lldb/include/lldb/Target/DynamicLoader.h  |  8 +++-
 .../MacOSX-DYLD/DynamicLoaderDarwin.cpp   | 15 +++
 .../MacOSX-DYLD/DynamicLoaderDarwin.h |  2 ++
 3 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/Target/DynamicLoader.h 
b/lldb/include/lldb/Target/DynamicLoader.h
index e508d192d2759..4ce3e053c5b1a 100644
--- a/lldb/include/lldb/Target/DynamicLoader.h
+++ b/lldb/include/lldb/Target/DynamicLoader.h
@@ -10,9 +10,11 @@
 #define LLDB_TARGET_DYNAMICLOADER_H
 
 #include "lldb/Core/PluginInterface.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/UUID.h"
+#include "lldb/Utility/UnimplementedError.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private-enumerations.h"
@@ -24,7 +26,6 @@ namespace lldb_private {
 class ModuleList;
 class Process;
 class SectionList;
-class Symbol;
 class SymbolContext;
 class SymbolContextList;
 class Thread;
@@ -329,6 +330,11 @@ class DynamicLoader : public PluginInterface {
   /// safe to call certain APIs or SPIs.
   virtual bool IsFullyInitialized() { return true; }
 
+  /// Return the `start` function \b symbol in the dynamic loader module.
+  virtual llvm::Expected GetStartSymbol() {
+return llvm::make_error();
+  }
+
 protected:
   // Utility methods for derived classes
 
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 0e17d57fa9c4f..f4a61fd02d93c 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -609,6 +609,21 @@ void 
DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(
   }
 }
 
+llvm::Expected DynamicLoaderDarwin::GetStartSymbol() {
+  ModuleSP dyld_sp = GetDYLDModule();
+  if (!dyld_sp)
+return llvm::createStringError(
+"Couldn't retrieve DYLD module. Cannot get `start` symbol.");
+
+  const Symbol *symbol =
+  dyld_sp->FindFirstSymbolWithNameAndType(ConstString("_dyld_start"));
+  if (!symbol)
+return llvm::createStringError(
+"Cannot find `start` symbol in DYLD module.");
+
+  return *symbol;
+}
+
 void DynamicLoaderDarwin::SetDYLDModule(lldb::ModuleSP &dyld_module_sp) {
   m_dyld_module_wp = dyld_module_sp;
 }
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
index 8f9a29c94173f..0cdaaf6532972 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
@@ -67,6 +67,8 @@ class DynamicLoaderDarwin : public 
lldb_private::DynamicLoader {
   // Clear method for classes derived from this one
   virtual void DoClear() = 0;
 
+  llvm::Expected GetStartSymbol() override;
+
   void SetDYLDModule(lldb::ModuleSP &dyld_module_sp);
 
   lldb::ModuleSP GetDYLDModule();

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Med Ismail Bennani (medismailben)


Changes

This patch introduces a new method to the dynamic loader plugin, to fetch its 
`start` symbol.

This can be useful to resolve the `start` symbol address for instance.

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


3 Files Affected:

- (modified) lldb/include/lldb/Target/DynamicLoader.h (+7-1) 
- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (+15) 
- (modified) 
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h (+2) 


``diff
diff --git a/lldb/include/lldb/Target/DynamicLoader.h 
b/lldb/include/lldb/Target/DynamicLoader.h
index e508d192d2759..4ce3e053c5b1a 100644
--- a/lldb/include/lldb/Target/DynamicLoader.h
+++ b/lldb/include/lldb/Target/DynamicLoader.h
@@ -10,9 +10,11 @@
 #define LLDB_TARGET_DYNAMICLOADER_H
 
 #include "lldb/Core/PluginInterface.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/UUID.h"
+#include "lldb/Utility/UnimplementedError.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private-enumerations.h"
@@ -24,7 +26,6 @@ namespace lldb_private {
 class ModuleList;
 class Process;
 class SectionList;
-class Symbol;
 class SymbolContext;
 class SymbolContextList;
 class Thread;
@@ -329,6 +330,11 @@ class DynamicLoader : public PluginInterface {
   /// safe to call certain APIs or SPIs.
   virtual bool IsFullyInitialized() { return true; }
 
+  /// Return the `start` function \b symbol in the dynamic loader module.
+  virtual llvm::Expected GetStartSymbol() {
+return llvm::make_error();
+  }
+
 protected:
   // Utility methods for derived classes
 
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 0e17d57fa9c4f..f4a61fd02d93c 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -609,6 +609,21 @@ void 
DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(
   }
 }
 
+llvm::Expected DynamicLoaderDarwin::GetStartSymbol() {
+  ModuleSP dyld_sp = GetDYLDModule();
+  if (!dyld_sp)
+return llvm::createStringError(
+"Couldn't retrieve DYLD module. Cannot get `start` symbol.");
+
+  const Symbol *symbol =
+  dyld_sp->FindFirstSymbolWithNameAndType(ConstString("_dyld_start"));
+  if (!symbol)
+return llvm::createStringError(
+"Cannot find `start` symbol in DYLD module.");
+
+  return *symbol;
+}
+
 void DynamicLoaderDarwin::SetDYLDModule(lldb::ModuleSP &dyld_module_sp) {
   m_dyld_module_wp = dyld_module_sp;
 }
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
index 8f9a29c94173f..0cdaaf6532972 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
@@ -67,6 +67,8 @@ class DynamicLoaderDarwin : public 
lldb_private::DynamicLoader {
   // Clear method for classes derived from this one
   virtual void DoClear() = 0;
 
+  llvm::Expected GetStartSymbol() override;
+
   void SetDYLDModule(lldb::ModuleSP &dyld_module_sp);
 
   lldb::ModuleSP GetDYLDModule();

``




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


[Lldb-commits] [lldb] [llvm] [lldb][RISCV] function calls support in lldb expressions (PR #99336)

2024-07-19 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,194 @@
+//===--- DirectToIndirectFCR.cpp - RISC-V specific pass 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/InstIterator.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/Value.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Transforms/Utils/BasicBlockUtils.h"
+
+#include "Plugins/Architecture/RISCV/DirectToIndirectFCR.h"
+
+#include "lldb/Core/Architecture.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Symbol/Symtab.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+
+#include 
+
+using namespace llvm;
+using namespace lldb_private;
+
+namespace {
+std::string GetValueTypeStr(const llvm::Type *value_ty) {
+  assert(value_ty);
+  std::string str_type;
+  llvm::raw_string_ostream rso(str_type);
+  value_ty->print(rso);
+  return rso.str();
+}
+
+template  void LogMessage(const char *msg, Args &&...args) {
+  Log *log = GetLog(LLDBLog::Expressions);
+  LLDB_LOG(log, msg, std::forward(args)...);
+}
+} // namespace
+
+bool DirectToIndirectFCR::canBeReplaced(const llvm::CallInst *ci) {
+  assert(ci);
+  auto *return_value_ty = ci->getType();
+  if (!(return_value_ty->isIntegerTy() || return_value_ty->isVoidTy())) {
+LogMessage("DirectToIndirectFCR: function {0} has unsupported "
+   "return type ({1})\n",
+   ci->getCalledFunction()->getName(),
+   GetValueTypeStr(return_value_ty));
+return false;
+  }
+
+  const auto *arg = llvm::find_if_not(ci->args(), [](const auto &arg) {
+const auto *type = arg->getType();
+return type->isIntegerTy();
+  });
+
+  if (arg != ci->arg_end()) {
+LogMessage("DirectToIndirectFCR: argument {0} of {1} function "
+   "has unsupported type ({2})\n",
+   (*arg)->getName(), ci->getCalledFunction()->getName(),
+   GetValueTypeStr((*arg)->getType()));
+return false;
+  }
+  return true;
+}
+
+std::vector
+DirectToIndirectFCR::getFunctionArgsAsValues(const llvm::CallInst *ci) {
+  assert(ci);
+  std::vector args{};
+  llvm::transform(ci->args(), std::back_inserter(args),
+  [](const auto &arg) { return arg.get(); });
+  return args;
+}
+
+std::optional
+DirectToIndirectFCR::getFunctionAddress(const llvm::CallInst *ci) const {
+  auto *target = m_exe_ctx.GetTargetPtr();
+  const auto &lldb_module_sp = target->GetExecutableModule();
+  const auto &symtab = lldb_module_sp->GetSymtab();
+  const llvm::StringRef name = ci->getCalledFunction()->getName();
+
+  // eSymbolTypeCode: we try to find function
+  // eDebugNo: not a debug symbol
+  // eVisibilityExtern: function from extern module

JDevlieghere wrote:

Either make these named constant variables or use inline comment in the 
function call (e.g, `/*argument_name=*/value`)

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


[Lldb-commits] [lldb] [llvm] [lldb][RISCV] function calls support in lldb expressions (PR #99336)

2024-07-19 Thread Jonas Devlieghere via lldb-commits


@@ -163,11 +166,83 @@ TotalArgsSizeInWords(bool is_rv64,
   return total_size;
 }
 
+static bool UpdateRegister(RegisterContext *reg_ctx,
+   const lldb::RegisterKind reg_kind,
+   const uint32_t reg_num, const addr_t value) {
+  Log *log = GetLog(LLDBLog::Expressions);
+
+  const RegisterInfo *reg_info = reg_ctx->GetRegisterInfo(reg_kind, reg_num);
+
+  LLDB_LOG(log, "Writing %s: 0x%" PRIx64, reg_info->name,
+   static_cast(value));
+  if (!reg_ctx->WriteRegisterFromUnsigned(reg_info, value)) {
+LLDB_LOG(log, "Writing %s: failed", reg_info->name);

JDevlieghere wrote:

You'll want to use `LLDB_LOGF` for printf-style formatters. `LLDB_LOG` (sans F) 
uses llvm's [formatv](https://llvm.org/doxygen/FormatVariadic_8h_source.html) 
formatters. 

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


[Lldb-commits] [lldb] [llvm] [lldb][RISCV] function calls support in lldb expressions (PR #99336)

2024-07-19 Thread Jonas Devlieghere via lldb-commits


@@ -0,0 +1,194 @@
+//===--- DirectToIndirectFCR.cpp - RISC-V specific pass 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/IR/Constants.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/IRBuilder.h"
+#include "llvm/IR/InstIterator.h"
+#include "llvm/IR/Instructions.h"
+#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/Module.h"
+#include "llvm/IR/Value.h"
+#include "llvm/InitializePasses.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Transforms/Utils/BasicBlockUtils.h"
+
+#include "Plugins/Architecture/RISCV/DirectToIndirectFCR.h"
+
+#include "lldb/Core/Architecture.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Symbol/Symtab.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+#include "lldb/Utility/ConstString.h"
+#include "lldb/Utility/LLDBLog.h"
+#include "lldb/Utility/Log.h"
+
+#include 
+
+using namespace llvm;
+using namespace lldb_private;
+
+namespace {
+std::string GetValueTypeStr(const llvm::Type *value_ty) {
+  assert(value_ty);
+  std::string str_type;
+  llvm::raw_string_ostream rso(str_type);
+  value_ty->print(rso);
+  return rso.str();
+}
+
+template  void LogMessage(const char *msg, Args &&...args) {
+  Log *log = GetLog(LLDBLog::Expressions);
+  LLDB_LOG(log, msg, std::forward(args)...);
+}

JDevlieghere wrote:

I don't think this helper makes a lot of sense:

 - The goal is to get the log once (which is "expensive") and then have the 
macro just do a pointer check. 
 -  This also breaks the line attribution which is why that's a macro in the 
first place. 

Please use the LOG macros directly. 

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Alex Langford via lldb-commits

https://github.com/bulbazord commented:

Looks fine to me, but you probably want @jasonmolenda to sign off to be sure.

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Jason Molenda via lldb-commits


@@ -329,6 +330,11 @@ class DynamicLoader : public PluginInterface {
   /// safe to call certain APIs or SPIs.
   virtual bool IsFullyInitialized() { return true; }
 
+  /// Return the `start` function \b symbol in the dynamic loader module.
+  virtual llvm::Expected GetStartSymbol() {

jasonmolenda wrote:

Should this be an llvm::Expected?  It's only going to be defined for 
DynamicLoaderDarwin today.  If some generic code wanted to use this, where it 
may not be applicable or defined for another DynamicLoader plugin, it'll need 
to consume the UnimplementedError.  Given the optionality of it, a 
std::optional seems more natural to me maybe?

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Jason Molenda via lldb-commits


@@ -329,6 +330,11 @@ class DynamicLoader : public PluginInterface {
   /// safe to call certain APIs or SPIs.
   virtual bool IsFullyInitialized() { return true; }
 
+  /// Return the `start` function \b symbol in the dynamic loader module.

jasonmolenda wrote:

The meaning of this is clear in a Darwin environment, but I wonder if we should 
explain it a little more, like "This is the symbol the process will begin 
executing with `process launch --stop-at-entry`".  I don't feel strongly about 
this.

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


[Lldb-commits] [lldb] [lldb][debuginfod] Fix the DebugInfoD PR that caused issues when working with stripped binaries (PR #99362)

2024-07-19 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/99362

>From b3fe99591b7bc6dad2e9cc46bd4fc2c2f87d1eff Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Mon, 25 Mar 2024 08:23:47 -0700
Subject: [PATCH 1/2] Trying to deal with Linux AArch64 test failures :/

Reapply "DebugInfoD tests + fixing issues exposed by tests (#85693)"

This reverts commit 7fc2fbb3f1961e0ad0722c2d749ddd6264195a1c.

Switched to using LLDB to get UUID at @clayborg's suggestion

Disable tests on non-x86 Linux platforms, as they appear to fail on AArch64/Arm 
buildbots

Moved the @skipIf to each test, off of the class itself

Added CURL dependency to lit configuration 'stuff'

Fixed comments in the tests

Fix stupid formatter issue

Updated to respond to (very late) code review feedback

Fixed the script to acquire the UUID without creating a target

Updated tests to not run on Mac/Windows

Added LLVM_ENABLE_CURL to the config.h.cmake to work in test's @skipIf thing

Attempting to prefer llvm-dwp over gnu's dwp

Disabled the DWP tests

Missed disabling the baseline test for DWP stuff
---
 lldb/include/lldb/Host/Config.h.cmake |   2 +
 .../Python/lldbsuite/test/decorators.py   |   4 +
 .../Python/lldbsuite/test/make/Makefile.rules |  34 +++
 lldb/source/API/SBDebugger.cpp|  13 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  38 ++--
 .../Plugins/SymbolLocator/CMakeLists.txt  |   7 +-
 .../SymbolVendor/ELF/SymbolVendorELF.cpp  |  29 ++-
 lldb/test/API/debuginfod/Normal/Makefile  |  19 ++
 .../API/debuginfod/Normal/TestDebuginfod.py   | 186 +
 lldb/test/API/debuginfod/Normal/main.c|   7 +
 lldb/test/API/debuginfod/SplitDWARF/Makefile  |  23 ++
 .../SplitDWARF/TestDebuginfodDWP.py   | 196 ++
 lldb/test/API/debuginfod/SplitDWARF/main.c|   7 +
 13 files changed, 544 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/debuginfod/Normal/Makefile
 create mode 100644 lldb/test/API/debuginfod/Normal/TestDebuginfod.py
 create mode 100644 lldb/test/API/debuginfod/Normal/main.c
 create mode 100644 lldb/test/API/debuginfod/SplitDWARF/Makefile
 create mode 100644 lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py
 create mode 100644 lldb/test/API/debuginfod/SplitDWARF/main.c

diff --git a/lldb/include/lldb/Host/Config.h.cmake 
b/lldb/include/lldb/Host/Config.h.cmake
index 3defa454f6d42..9e538534086a2 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -33,6 +33,8 @@
 
 #cmakedefine01 LLDB_ENABLE_LZMA
 
+#cmakedefine01 LLVM_ENABLE_CURL
+
 #cmakedefine01 LLDB_ENABLE_CURSES
 
 #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index ecc7b81035f11..0e8ca159efd55 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1053,6 +1053,10 @@ def _get_bool_config_skip_if_decorator(key):
 return unittest.skipIf(not have, "requires " + key)
 
 
+def skipIfCurlSupportMissing(func):
+return _get_bool_config_skip_if_decorator("curl")(func)
+
+
 def skipIfCursesSupportMissing(func):
 return _get_bool_config_skip_if_decorator("curses")(func)
 
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index be3ad684dd736..7ecfa8aac520b 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -190,6 +190,12 @@ else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif
+
+   ifeq "$(MAKE_DWP)" "YES"
+   MAKE_DWO := YES
+   DWP_NAME = $(EXE).dwp
+   DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
+   endif
 endif
 
 LIMIT_DEBUG_INFO_FLAGS =
@@ -338,6 +344,17 @@ ifneq "$(OS)" "Darwin"
 
OBJCOPY ?= $(call replace_cc_with,objcopy)
ARCHIVER ?= $(call replace_cc_with,ar)
+   # Look for llvm-dwp or gnu dwp
+   DWP ?= $(call replace_cc_with,llvm-dwp)
+   ifeq ($(wildcard $(DWP)),)
+   DWP = $(call replace_cc_with,dwp)
+   ifeq ($(wildcard $(DWP)),)
+   DWP = $(shell command -v llvm-dwp 2> /dev/null)
+   ifeq ($(wildcard $(DWP)),)
+   DWP = $(shell command -v dwp 2> /dev/null)
+   endif
+   endif
+   endif
override AR = $(ARCHIVER)
 endif
 
@@ -508,6 +525,10 @@ ifneq "$(CXX)" ""
endif
 endif
 
+ifeq "$(GEN_GNU_BUILD_ID)" "YES"
+   LDFLAGS += -Wl,--build-id
+endif
+
 #--
 # DYLIB_ONLY variable can be used to skip the building of a.out.
 # See the sections below regarding dSYM file as well as the building of
@@ -546,11 +567,18 @@ else
 endif
 else
 ifeq "$(SP

[Lldb-commits] [lldb] [LLDB] [CMake] added static libraries and LLDB packaging (PR #98829)

2024-07-19 Thread Jonas Devlieghere via lldb-commits

https://github.com/JDevlieghere requested changes to this pull request.

This PR does two things that are orthogonal, therefore they should be separate 
PRs. Please omit the whitespace changes (those can be addressed separately as 
well). Also, please make sure to have a self contained PR description/commit 
message. Linking back to the issue this is fixing is great for context, but 
developers should be able to make some sense of a change by looking at the 
commit message. 

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Med Ismail Bennani via lldb-commits


@@ -329,6 +330,11 @@ class DynamicLoader : public PluginInterface {
   /// safe to call certain APIs or SPIs.
   virtual bool IsFullyInitialized() { return true; }
 
+  /// Return the `start` function \b symbol in the dynamic loader module.
+  virtual llvm::Expected GetStartSymbol() {

medismailben wrote:

In my understanding, every dynamic loader should have an equivalent to a start 
symbol, that's why I went with `Expected` instead of `optional`. I believe that 
long term, each dynamic loader plugin would have to implement this method for 
their own platform and only the base class would have the `UnimplementedError`.

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Jason Molenda via lldb-commits


@@ -329,6 +330,11 @@ class DynamicLoader : public PluginInterface {
   /// safe to call certain APIs or SPIs.
   virtual bool IsFullyInitialized() { return true; }
 
+  /// Return the `start` function \b symbol in the dynamic loader module.
+  virtual llvm::Expected GetStartSymbol() {

jasonmolenda wrote:

I would DEFINITELY not bank on this assumption.  The world of environments a 
debugger needs to support is vast.

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/99673

>From 16ef7297eef25d329631fd62d126bf7a7be24c4d Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Fri, 19 Jul 2024 11:08:39 -0700
Subject: [PATCH] [lldb/Target] Add GetStartSymbol method to DynamicLoader
 plugins

This patch introduces a new method to the dynamic loader plugin, to
fetch its `start` symbol.

This can be useful to resolve the `start` symbol address for instance.

Signed-off-by: Med Ismail Bennani 
---
 lldb/include/lldb/Target/DynamicLoader.h  | 10 +-
 .../MacOSX-DYLD/DynamicLoaderDarwin.cpp   | 20 +++
 .../MacOSX-DYLD/DynamicLoaderDarwin.h |  2 ++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/Target/DynamicLoader.h 
b/lldb/include/lldb/Target/DynamicLoader.h
index e508d192d2759..fd3b3924c2725 100644
--- a/lldb/include/lldb/Target/DynamicLoader.h
+++ b/lldb/include/lldb/Target/DynamicLoader.h
@@ -10,9 +10,11 @@
 #define LLDB_TARGET_DYNAMICLOADER_H
 
 #include "lldb/Core/PluginInterface.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/UUID.h"
+#include "lldb/Utility/UnimplementedError.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private-enumerations.h"
@@ -24,7 +26,6 @@ namespace lldb_private {
 class ModuleList;
 class Process;
 class SectionList;
-class Symbol;
 class SymbolContext;
 class SymbolContextList;
 class Thread;
@@ -329,6 +330,13 @@ class DynamicLoader : public PluginInterface {
   /// safe to call certain APIs or SPIs.
   virtual bool IsFullyInitialized() { return true; }
 
+  /// Return the `start` function \b symbol in the dynamic loader module.
+  /// This is the symbol the process will begin executing with
+  /// `process launch --stop-at-entry`.
+  virtual std::optional GetStartSymbol() {
+return std::nullopt;
+  }
+
 protected:
   // Utility methods for derived classes
 
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 0e17d57fa9c4f..5c6331735bde8 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -609,6 +609,26 @@ void 
DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(
   }
 }
 
+std::optional DynamicLoaderDarwin::GetStartSymbol() {
+  Log *log = GetLog(LLDBLog::DynamicLoader);
+
+  auto log_err = [log](llvm::StringLiteral err_msg) -> std::nullopt_t {
+LLDB_LOGV(log, "{}", err_msg);
+return std::nullopt;
+  };
+
+  ModuleSP dyld_sp = GetDYLDModule();
+  if (!dyld_sp)
+return log_err("Couldn't retrieve DYLD module. Cannot get `start` 
symbol.");
+
+  const Symbol *symbol =
+  dyld_sp->FindFirstSymbolWithNameAndType(ConstString("_dyld_start"));
+  if (!symbol)
+return log_err("Cannot find `start` symbol in DYLD module.");
+
+  return *symbol;
+}
+
 void DynamicLoaderDarwin::SetDYLDModule(lldb::ModuleSP &dyld_module_sp) {
   m_dyld_module_wp = dyld_module_sp;
 }
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
index 8f9a29c94173f..4ac55fdf6f3af 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
@@ -67,6 +67,8 @@ class DynamicLoaderDarwin : public 
lldb_private::DynamicLoader {
   // Clear method for classes derived from this one
   virtual void DoClear() = 0;
 
+  std::optional GetStartSymbol() override;
+
   void SetDYLDModule(lldb::ModuleSP &dyld_module_sp);
 
   lldb::ModuleSP GetDYLDModule();

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Jason Molenda via lldb-commits

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Jason Molenda via lldb-commits

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

LGTM.

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Jason Molenda via lldb-commits


@@ -10,9 +10,11 @@
 #define LLDB_TARGET_DYNAMICLOADER_H
 
 #include "lldb/Core/PluginInterface.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/UUID.h"
+#include "lldb/Utility/UnimplementedError.h"

jasonmolenda wrote:

We can remove this header file include now.

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Med Ismail Bennani via lldb-commits


@@ -10,9 +10,11 @@
 #define LLDB_TARGET_DYNAMICLOADER_H
 
 #include "lldb/Core/PluginInterface.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/UUID.h"
+#include "lldb/Utility/UnimplementedError.h"

medismailben wrote:

Yup!

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Med Ismail Bennani via lldb-commits


@@ -10,9 +10,11 @@
 #define LLDB_TARGET_DYNAMICLOADER_H
 
 #include "lldb/Core/PluginInterface.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/UUID.h"
+#include "lldb/Utility/UnimplementedError.h"

medismailben wrote:

```suggestion
```

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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben updated 
https://github.com/llvm/llvm-project/pull/99673

>From 16ef7297eef25d329631fd62d126bf7a7be24c4d Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Fri, 19 Jul 2024 11:08:39 -0700
Subject: [PATCH 1/2] [lldb/Target] Add GetStartSymbol method to DynamicLoader
 plugins

This patch introduces a new method to the dynamic loader plugin, to
fetch its `start` symbol.

This can be useful to resolve the `start` symbol address for instance.

Signed-off-by: Med Ismail Bennani 
---
 lldb/include/lldb/Target/DynamicLoader.h  | 10 +-
 .../MacOSX-DYLD/DynamicLoaderDarwin.cpp   | 20 +++
 .../MacOSX-DYLD/DynamicLoaderDarwin.h |  2 ++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/Target/DynamicLoader.h 
b/lldb/include/lldb/Target/DynamicLoader.h
index e508d192d2759..fd3b3924c2725 100644
--- a/lldb/include/lldb/Target/DynamicLoader.h
+++ b/lldb/include/lldb/Target/DynamicLoader.h
@@ -10,9 +10,11 @@
 #define LLDB_TARGET_DYNAMICLOADER_H
 
 #include "lldb/Core/PluginInterface.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/UUID.h"
+#include "lldb/Utility/UnimplementedError.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private-enumerations.h"
@@ -24,7 +26,6 @@ namespace lldb_private {
 class ModuleList;
 class Process;
 class SectionList;
-class Symbol;
 class SymbolContext;
 class SymbolContextList;
 class Thread;
@@ -329,6 +330,13 @@ class DynamicLoader : public PluginInterface {
   /// safe to call certain APIs or SPIs.
   virtual bool IsFullyInitialized() { return true; }
 
+  /// Return the `start` function \b symbol in the dynamic loader module.
+  /// This is the symbol the process will begin executing with
+  /// `process launch --stop-at-entry`.
+  virtual std::optional GetStartSymbol() {
+return std::nullopt;
+  }
+
 protected:
   // Utility methods for derived classes
 
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 0e17d57fa9c4f..5c6331735bde8 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -609,6 +609,26 @@ void 
DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(
   }
 }
 
+std::optional DynamicLoaderDarwin::GetStartSymbol() {
+  Log *log = GetLog(LLDBLog::DynamicLoader);
+
+  auto log_err = [log](llvm::StringLiteral err_msg) -> std::nullopt_t {
+LLDB_LOGV(log, "{}", err_msg);
+return std::nullopt;
+  };
+
+  ModuleSP dyld_sp = GetDYLDModule();
+  if (!dyld_sp)
+return log_err("Couldn't retrieve DYLD module. Cannot get `start` 
symbol.");
+
+  const Symbol *symbol =
+  dyld_sp->FindFirstSymbolWithNameAndType(ConstString("_dyld_start"));
+  if (!symbol)
+return log_err("Cannot find `start` symbol in DYLD module.");
+
+  return *symbol;
+}
+
 void DynamicLoaderDarwin::SetDYLDModule(lldb::ModuleSP &dyld_module_sp) {
   m_dyld_module_wp = dyld_module_sp;
 }
diff --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
index 8f9a29c94173f..4ac55fdf6f3af 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
@@ -67,6 +67,8 @@ class DynamicLoaderDarwin : public 
lldb_private::DynamicLoader {
   // Clear method for classes derived from this one
   virtual void DoClear() = 0;
 
+  std::optional GetStartSymbol() override;
+
   void SetDYLDModule(lldb::ModuleSP &dyld_module_sp);
 
   lldb::ModuleSP GetDYLDModule();

>From b1184ba2ef7b98b97f55b5337472b597b2e4732c Mon Sep 17 00:00:00 2001
From: Med Ismail Bennani 
Date: Fri, 19 Jul 2024 11:39:20 -0700
Subject: [PATCH 2/2] Remove unused header

---
 lldb/include/lldb/Target/DynamicLoader.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/lldb/include/lldb/Target/DynamicLoader.h 
b/lldb/include/lldb/Target/DynamicLoader.h
index fd3b3924c2725..15384245194b0 100644
--- a/lldb/include/lldb/Target/DynamicLoader.h
+++ b/lldb/include/lldb/Target/DynamicLoader.h
@@ -14,7 +14,6 @@
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/UUID.h"
-#include "lldb/Utility/UnimplementedError.h"
 #include "lldb/lldb-defines.h"
 #include "lldb/lldb-forward.h"
 #include "lldb/lldb-private-enumerations.h"

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


[Lldb-commits] [lldb] a96c906 - [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (#99673)

2024-07-19 Thread via lldb-commits

Author: Med Ismail Bennani
Date: 2024-07-19T11:39:56-07:00
New Revision: a96c906102e8d0284c7a402eac4fa1ad9ab3e871

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

LOG: [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (#99673)

This patch introduces a new method to the dynamic loader plugin, to
fetch its `start` symbol.

This can be useful to resolve the `start` symbol address for instance.

Signed-off-by: Med Ismail Bennani 

Added: 


Modified: 
lldb/include/lldb/Target/DynamicLoader.h
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h

Removed: 




diff  --git a/lldb/include/lldb/Target/DynamicLoader.h 
b/lldb/include/lldb/Target/DynamicLoader.h
index e508d192d2759..15384245194b0 100644
--- a/lldb/include/lldb/Target/DynamicLoader.h
+++ b/lldb/include/lldb/Target/DynamicLoader.h
@@ -10,6 +10,7 @@
 #define LLDB_TARGET_DYNAMICLOADER_H
 
 #include "lldb/Core/PluginInterface.h"
+#include "lldb/Symbol/Symbol.h"
 #include "lldb/Utility/FileSpec.h"
 #include "lldb/Utility/Status.h"
 #include "lldb/Utility/UUID.h"
@@ -24,7 +25,6 @@ namespace lldb_private {
 class ModuleList;
 class Process;
 class SectionList;
-class Symbol;
 class SymbolContext;
 class SymbolContextList;
 class Thread;
@@ -329,6 +329,13 @@ class DynamicLoader : public PluginInterface {
   /// safe to call certain APIs or SPIs.
   virtual bool IsFullyInitialized() { return true; }
 
+  /// Return the `start` function \b symbol in the dynamic loader module.
+  /// This is the symbol the process will begin executing with
+  /// `process launch --stop-at-entry`.
+  virtual std::optional GetStartSymbol() {
+return std::nullopt;
+  }
+
 protected:
   // Utility methods for derived classes
 

diff  --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
index 0e17d57fa9c4f..5c6331735bde8 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
@@ -609,6 +609,26 @@ void 
DynamicLoaderDarwin::UpdateDYLDImageInfoFromNewImageInfo(
   }
 }
 
+std::optional DynamicLoaderDarwin::GetStartSymbol() {
+  Log *log = GetLog(LLDBLog::DynamicLoader);
+
+  auto log_err = [log](llvm::StringLiteral err_msg) -> std::nullopt_t {
+LLDB_LOGV(log, "{}", err_msg);
+return std::nullopt;
+  };
+
+  ModuleSP dyld_sp = GetDYLDModule();
+  if (!dyld_sp)
+return log_err("Couldn't retrieve DYLD module. Cannot get `start` 
symbol.");
+
+  const Symbol *symbol =
+  dyld_sp->FindFirstSymbolWithNameAndType(ConstString("_dyld_start"));
+  if (!symbol)
+return log_err("Cannot find `start` symbol in DYLD module.");
+
+  return *symbol;
+}
+
 void DynamicLoaderDarwin::SetDYLDModule(lldb::ModuleSP &dyld_module_sp) {
   m_dyld_module_wp = dyld_module_sp;
 }

diff  --git 
a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h 
b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
index 8f9a29c94173f..4ac55fdf6f3af 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h
@@ -67,6 +67,8 @@ class DynamicLoaderDarwin : public 
lldb_private::DynamicLoader {
   // Clear method for classes derived from this one
   virtual void DoClear() = 0;
 
+  std::optional GetStartSymbol() override;
+
   void SetDYLDModule(lldb::ModuleSP &dyld_module_sp);
 
   lldb::ModuleSP GetDYLDModule();



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


[Lldb-commits] [lldb] [lldb/Target] Add GetStartSymbol method to DynamicLoader plugins (PR #99673)

2024-07-19 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-19 Thread via lldb-commits


@@ -577,15 +577,18 @@ StopInfoSP 
StopInfoMachException::CreateStopReasonWithMachException(
 
   ProcessSP process_sp(thread.GetProcess());
   RegisterContextSP reg_ctx_sp(thread.GetRegisterContext());
-  BreakpointSiteSP bp_site_sp;
-  addr_t pc = LLDB_INVALID_ADDRESS;
-  if (reg_ctx_sp) {
-pc = reg_ctx_sp->GetPC();
-BreakpointSiteSP bp_site_sp =
-process_sp->GetBreakpointSiteList().FindByAddress(pc);
-if (bp_site_sp && bp_site_sp->IsEnabled())
-  thread.SetThreadStoppedAtUnexecutedBP(pc);
-  }
+  // Caveat: with x86 KDP if we've hit a breakpoint, the pc we
+  // receive is past the breakpoint instruction.
+  // If we have a breakpoint at 0x100 (on a 1-byte original instruction)
+  // and at 0x101, we hit the 0x100 breakpoint and the pc is

jimingham wrote:

and at 0x101 -> and are stopped at 0x101

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


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-19 Thread via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-19 Thread via lldb-commits


@@ -577,15 +577,18 @@ StopInfoSP 
StopInfoMachException::CreateStopReasonWithMachException(
 
   ProcessSP process_sp(thread.GetProcess());
   RegisterContextSP reg_ctx_sp(thread.GetRegisterContext());
-  BreakpointSiteSP bp_site_sp;
-  addr_t pc = LLDB_INVALID_ADDRESS;
-  if (reg_ctx_sp) {
-pc = reg_ctx_sp->GetPC();
-BreakpointSiteSP bp_site_sp =
-process_sp->GetBreakpointSiteList().FindByAddress(pc);
-if (bp_site_sp && bp_site_sp->IsEnabled())
-  thread.SetThreadStoppedAtUnexecutedBP(pc);
-  }
+  // Caveat: with x86 KDP if we've hit a breakpoint, the pc we
+  // receive is past the breakpoint instruction.
+  // If we have a breakpoint at 0x100 (on a 1-byte original instruction)

jimingham wrote:

This construction tripped me up, though the content is clear.  I'd either say:

If we have breakpoints at ...

or 

If we have a breakpoint at... and ONE at 0x101

(not capitalized, I just did that so you could see the change.

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


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-19 Thread via lldb-commits

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

I had a couple trivial comment comments (and you didn't fix one typo).  But 
this LGTM as well.

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


[Lldb-commits] [lldb] [LLDB][SBSaveCoreOptions] Fix TestProcessSaveCore (PR #99692)

2024-07-19 Thread Jacob Lalonde via lldb-commits

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

In #98403 some of the tests were transitioned to the new 
`SBProcess::SaveCore(SBSaveCoreOptions)` API, but were not detected in testing. 
This patch addresses that.

>From f4c7fcb17855dc5f4f51dce791e05adfff0666e6 Mon Sep 17 00:00:00 2001
From: Jacob Lalonde 
Date: Fri, 19 Jul 2024 12:40:58 -0700
Subject: [PATCH] add lldb. to new options type and sbfilespec to fix test on
 windows

---
 .../functionalities/process_save_core/TestProcessSaveCore.py  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py 
b/lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py
index 07d06bdc116ec..8573d15733927 100644
--- a/lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py
+++ b/lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py
@@ -20,8 +20,8 @@ def test_cannot_save_core_unless_process_stopped(self):
 target = self.dbg.CreateTarget(exe)
 process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
 self.assertNotEqual(process.GetState(), lldb.eStateStopped)
-options = SBSaveCoreOptions()
-options.SetOutputFile(SBFileSpec(core))
+options = lldb.SBSaveCoreOptions()
+options.SetOutputFile(lldb.SBFileSpec(core))
 error = process.SaveCore(core)
 self.assertTrue(error.Fail())
 

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


[Lldb-commits] [lldb] [LLDB][SBSaveCoreOptions] Fix TestProcessSaveCore (PR #99692)

2024-07-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Jacob Lalonde (Jlalond)


Changes

In #98403 some of the tests were transitioned to the new 
`SBProcess::SaveCore(SBSaveCoreOptions)` API, but were not detected in testing. 
This patch addresses that.

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


1 Files Affected:

- (modified) 
lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py (+2-2) 


``diff
diff --git 
a/lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py 
b/lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py
index 07d06bdc116ec..8573d15733927 100644
--- a/lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py
+++ b/lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py
@@ -20,8 +20,8 @@ def test_cannot_save_core_unless_process_stopped(self):
 target = self.dbg.CreateTarget(exe)
 process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
 self.assertNotEqual(process.GetState(), lldb.eStateStopped)
-options = SBSaveCoreOptions()
-options.SetOutputFile(SBFileSpec(core))
+options = lldb.SBSaveCoreOptions()
+options.SetOutputFile(lldb.SBFileSpec(core))
 error = process.SaveCore(core)
 self.assertTrue(error.Fail())
 

``




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


[Lldb-commits] [lldb] [LLDB][SBSaveCoreOptions] Fix TestProcessSaveCore (PR #99692)

2024-07-19 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

@luporl FYI this fixes the test

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


[Lldb-commits] [lldb] [lldb][debuginfod] Fix the DebugInfoD PR that caused issues when working with stripped binaries (PR #99362)

2024-07-19 Thread Kevin Frei via lldb-commits

https://github.com/kevinfrei updated 
https://github.com/llvm/llvm-project/pull/99362

>From f498534a60636a6b8ee06f27dcd04a5074537180 Mon Sep 17 00:00:00 2001
From: Kevin Frei 
Date: Mon, 25 Mar 2024 08:23:47 -0700
Subject: [PATCH 1/2] Trying to deal with Linux AArch64 test failures :/

Reapply "DebugInfoD tests + fixing issues exposed by tests (#85693)"

This reverts commit 7fc2fbb3f1961e0ad0722c2d749ddd6264195a1c.

Switched to using LLDB to get UUID at @clayborg's suggestion

Disable tests on non-x86 Linux platforms, as they appear to fail on AArch64/Arm 
buildbots

Moved the @skipIf to each test, off of the class itself

Added CURL dependency to lit configuration 'stuff'

Fixed comments in the tests

Fix stupid formatter issue

Updated to respond to (very late) code review feedback

Fixed the script to acquire the UUID without creating a target

Updated tests to not run on Mac/Windows

Added LLVM_ENABLE_CURL to the config.h.cmake to work in test's @skipIf thing

Attempting to prefer llvm-dwp over gnu's dwp

Disabled the DWP tests

Missed disabling the baseline test for DWP stuff
---
 lldb/include/lldb/Host/Config.h.cmake |   2 +
 .../Python/lldbsuite/test/decorators.py   |   4 +
 .../Python/lldbsuite/test/make/Makefile.rules |  34 +++
 lldb/source/API/SBDebugger.cpp|  13 +-
 .../SymbolFile/DWARF/SymbolFileDWARF.cpp  |  38 ++--
 .../Plugins/SymbolLocator/CMakeLists.txt  |   7 +-
 .../SymbolVendor/ELF/SymbolVendorELF.cpp  |  29 ++-
 lldb/test/API/debuginfod/Normal/Makefile  |  19 ++
 .../API/debuginfod/Normal/TestDebuginfod.py   | 186 +
 lldb/test/API/debuginfod/Normal/main.c|   7 +
 lldb/test/API/debuginfod/SplitDWARF/Makefile  |  23 ++
 .../SplitDWARF/TestDebuginfodDWP.py   | 196 ++
 lldb/test/API/debuginfod/SplitDWARF/main.c|   7 +
 13 files changed, 544 insertions(+), 21 deletions(-)
 create mode 100644 lldb/test/API/debuginfod/Normal/Makefile
 create mode 100644 lldb/test/API/debuginfod/Normal/TestDebuginfod.py
 create mode 100644 lldb/test/API/debuginfod/Normal/main.c
 create mode 100644 lldb/test/API/debuginfod/SplitDWARF/Makefile
 create mode 100644 lldb/test/API/debuginfod/SplitDWARF/TestDebuginfodDWP.py
 create mode 100644 lldb/test/API/debuginfod/SplitDWARF/main.c

diff --git a/lldb/include/lldb/Host/Config.h.cmake 
b/lldb/include/lldb/Host/Config.h.cmake
index 3defa454f6d42..9e538534086a2 100644
--- a/lldb/include/lldb/Host/Config.h.cmake
+++ b/lldb/include/lldb/Host/Config.h.cmake
@@ -33,6 +33,8 @@
 
 #cmakedefine01 LLDB_ENABLE_LZMA
 
+#cmakedefine01 LLVM_ENABLE_CURL
+
 #cmakedefine01 LLDB_ENABLE_CURSES
 
 #cmakedefine01 CURSES_HAVE_NCURSES_CURSES_H
diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index ecc7b81035f11..0e8ca159efd55 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -1053,6 +1053,10 @@ def _get_bool_config_skip_if_decorator(key):
 return unittest.skipIf(not have, "requires " + key)
 
 
+def skipIfCurlSupportMissing(func):
+return _get_bool_config_skip_if_decorator("curl")(func)
+
+
 def skipIfCursesSupportMissing(func):
 return _get_bool_config_skip_if_decorator("curses")(func)
 
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules 
b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index be3ad684dd736..7ecfa8aac520b 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -190,6 +190,12 @@ else
ifeq "$(SPLIT_DEBUG_SYMBOLS)" "YES"
DSYM = $(EXE).debug
endif
+
+   ifeq "$(MAKE_DWP)" "YES"
+   MAKE_DWO := YES
+   DWP_NAME = $(EXE).dwp
+   DYLIB_DWP_NAME = $(DYLIB_NAME).dwp
+   endif
 endif
 
 LIMIT_DEBUG_INFO_FLAGS =
@@ -338,6 +344,17 @@ ifneq "$(OS)" "Darwin"
 
OBJCOPY ?= $(call replace_cc_with,objcopy)
ARCHIVER ?= $(call replace_cc_with,ar)
+   # Look for llvm-dwp or gnu dwp
+   DWP ?= $(call replace_cc_with,llvm-dwp)
+   ifeq ($(wildcard $(DWP)),)
+   DWP = $(call replace_cc_with,dwp)
+   ifeq ($(wildcard $(DWP)),)
+   DWP = $(shell command -v llvm-dwp 2> /dev/null)
+   ifeq ($(wildcard $(DWP)),)
+   DWP = $(shell command -v dwp 2> /dev/null)
+   endif
+   endif
+   endif
override AR = $(ARCHIVER)
 endif
 
@@ -508,6 +525,10 @@ ifneq "$(CXX)" ""
endif
 endif
 
+ifeq "$(GEN_GNU_BUILD_ID)" "YES"
+   LDFLAGS += -Wl,--build-id
+endif
+
 #--
 # DYLIB_ONLY variable can be used to skip the building of a.out.
 # See the sections below regarding dSYM file as well as the building of
@@ -546,11 +567,18 @@ else
 endif
 else
 ifeq "$(SP

[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libcxx] [lld] [lldb] [llvm] [BOLT] Match functions with call graph (PR #98125)

2024-07-19 Thread Shaw Young via lldb-commits

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


[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [flang] [libc] [libcxx] [lld] [lldb] [llvm] [BOLT] Match functions with call graph (PR #98125)

2024-07-19 Thread Shaw Young via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-19 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/96260

>From 9b541e6a035635e26c6a24eca022de8552fa4c17 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Thu, 20 Jun 2024 17:53:17 -0700
Subject: [PATCH 1/8] [lldb] Change lldb's breakpoint handling behavior

lldb today has two rules:  When a thread stops at a BreakpointSite,
we set the thread's StopReason to be "breakpoint hit" (regardless
if we've actually hit the breakpoint, or if we've merely stopped
*at* the breakpoint instruction/point and haven't tripped it yet).
And second, when resuming a process, any thread sitting at a
BreakpointSite is silently stepped over the BreakpointSite -- because
we've already flagged the breakpoint hit when we stopped there
originally.

In this patch, I change lldb to only set a thread's stop reason to
breakpoint-hit when we've actually executed the instruction/triggered
the breakpoint.  When we resume, we only silently step past a
BreakpointSite that we've registered as hit.  We preserve this state
across inferior function calls that the user may do while stopped,
etc.

Also, when a user adds a new breakpoint at $pc while stopped, or
changes $pc to be the address of a BreakpointSite, we will silently
step past that breakpoint when the process resumes.  This is purely
a UX call, I don't think there's any person who wants to set a
breakpoint at $pc and then hit it immediately on resuming.

One non-intuitive UX from this change, but I'm convinced it is
necessary:  If you're stopped at a BreakpointSite that has not yet
executed, you `stepi`, you will hit the breakpoint and the pc will
not yet advance.  This thread has not completed its stepi, and the
thread plan is still on the stack.  If you then `continue` the
thread, lldb will now stop and say, "instruction step completed",
one instruction past the BreakpointSite.  You can continue a second
time to resume execution.  I discussed this with Jim, and trying
to paper over this behavior will lead to more complicated scenarios
behaving non-intuitively.  And mostly it's the testsuite that was
trying to instruction step past a breakpoint and getting thrown off
-- and I changed those tests to expect the new behavior.

The bugs driving this change are all from lldb dropping the real
stop reason for a thread and setting it to breakpoint-hit when that
was not the case.  Jim hit one where we have an aarch64 watchpoint
that triggers one instruction before a BreakpointSite.  On this
arch we are notified of the watchpoint hit after the instruction
has been unrolled -- we disable the watchpoint, instruction step,
re-enable the watchpoint and collect the new value.  But now we're
on a BreakpointSite so the watchpoint-hit stop reason is lost.

Another was reported by ZequanWu in
https://discourse.llvm.org/t/lldb-unable-to-break-at-start/78282
we attach to/launch a process with the pc at a BreakpointSite and
misbehave.  Caroline Tice mentioned it is also a problem they've
had with putting a breakpoint on _dl_debug_state.

The change to each Process plugin that does execution control
is that

1. If we've stopped at a BreakpointSite (whether we hit it or not),
we call Thread::SetThreadStoppedAtBreakpointSite(pc) to record the
state at the point when the thread stopped.  (so we can detect
newly-added breakpoints, or when the pc is changed to an instruction
that is a BreakpointSite)

2. When we have actually hit a breakpoint, and it is enabled for
this thread, we call Thread::SetThreadHitBreakpointAtAddr(pc) so
we know that it should be silently stepped past when we resume
execution.

When resuming, we silently step over a breakpoint if we've hit it,
or if it is newly added (or the pc was changed to an existing
BreakpointSite).

The biggest set of changes is to StopInfoMachException where we
translate a Mach Exception into a stop reason.  The Mach exception
codes differ in a few places depending on the target (unambiguously),
and I didn't want to duplicate the new code for each target so I've
tested what mach exceptions we get for each action on each target,
and reorganized StopInfoMachException::CreateStopReasonWithMachException
to document these possible values, and handle them without specializing
based on the target arch.

rdar://123942164
---
 lldb/include/lldb/Target/Thread.h |  29 ++
 .../Process/Utility/StopInfoMachException.cpp | 296 +++---
 .../Process/Windows/Common/ProcessWindows.cpp |  16 +-
 .../Process/gdb-remote/ProcessGDBRemote.cpp   | 118 +++
 .../Process/scripted/ScriptedThread.cpp   |   9 +
 lldb/source/Target/Thread.cpp |  17 +-
 .../TestConsecutiveBreakpoints.py |  26 +-
 .../TestStepOverBreakpoint.py |   6 +-
 8 files changed, 235 insertions(+), 282 deletions(-)

diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index c17bddf4d98b8..1e1aead896018 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread

[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-19 Thread Jason Molenda via lldb-commits

https://github.com/jasonmolenda updated 
https://github.com/llvm/llvm-project/pull/96260

>From 9b541e6a035635e26c6a24eca022de8552fa4c17 Mon Sep 17 00:00:00 2001
From: Jason Molenda 
Date: Thu, 20 Jun 2024 17:53:17 -0700
Subject: [PATCH 1/8] [lldb] Change lldb's breakpoint handling behavior

lldb today has two rules:  When a thread stops at a BreakpointSite,
we set the thread's StopReason to be "breakpoint hit" (regardless
if we've actually hit the breakpoint, or if we've merely stopped
*at* the breakpoint instruction/point and haven't tripped it yet).
And second, when resuming a process, any thread sitting at a
BreakpointSite is silently stepped over the BreakpointSite -- because
we've already flagged the breakpoint hit when we stopped there
originally.

In this patch, I change lldb to only set a thread's stop reason to
breakpoint-hit when we've actually executed the instruction/triggered
the breakpoint.  When we resume, we only silently step past a
BreakpointSite that we've registered as hit.  We preserve this state
across inferior function calls that the user may do while stopped,
etc.

Also, when a user adds a new breakpoint at $pc while stopped, or
changes $pc to be the address of a BreakpointSite, we will silently
step past that breakpoint when the process resumes.  This is purely
a UX call, I don't think there's any person who wants to set a
breakpoint at $pc and then hit it immediately on resuming.

One non-intuitive UX from this change, but I'm convinced it is
necessary:  If you're stopped at a BreakpointSite that has not yet
executed, you `stepi`, you will hit the breakpoint and the pc will
not yet advance.  This thread has not completed its stepi, and the
thread plan is still on the stack.  If you then `continue` the
thread, lldb will now stop and say, "instruction step completed",
one instruction past the BreakpointSite.  You can continue a second
time to resume execution.  I discussed this with Jim, and trying
to paper over this behavior will lead to more complicated scenarios
behaving non-intuitively.  And mostly it's the testsuite that was
trying to instruction step past a breakpoint and getting thrown off
-- and I changed those tests to expect the new behavior.

The bugs driving this change are all from lldb dropping the real
stop reason for a thread and setting it to breakpoint-hit when that
was not the case.  Jim hit one where we have an aarch64 watchpoint
that triggers one instruction before a BreakpointSite.  On this
arch we are notified of the watchpoint hit after the instruction
has been unrolled -- we disable the watchpoint, instruction step,
re-enable the watchpoint and collect the new value.  But now we're
on a BreakpointSite so the watchpoint-hit stop reason is lost.

Another was reported by ZequanWu in
https://discourse.llvm.org/t/lldb-unable-to-break-at-start/78282
we attach to/launch a process with the pc at a BreakpointSite and
misbehave.  Caroline Tice mentioned it is also a problem they've
had with putting a breakpoint on _dl_debug_state.

The change to each Process plugin that does execution control
is that

1. If we've stopped at a BreakpointSite (whether we hit it or not),
we call Thread::SetThreadStoppedAtBreakpointSite(pc) to record the
state at the point when the thread stopped.  (so we can detect
newly-added breakpoints, or when the pc is changed to an instruction
that is a BreakpointSite)

2. When we have actually hit a breakpoint, and it is enabled for
this thread, we call Thread::SetThreadHitBreakpointAtAddr(pc) so
we know that it should be silently stepped past when we resume
execution.

When resuming, we silently step over a breakpoint if we've hit it,
or if it is newly added (or the pc was changed to an existing
BreakpointSite).

The biggest set of changes is to StopInfoMachException where we
translate a Mach Exception into a stop reason.  The Mach exception
codes differ in a few places depending on the target (unambiguously),
and I didn't want to duplicate the new code for each target so I've
tested what mach exceptions we get for each action on each target,
and reorganized StopInfoMachException::CreateStopReasonWithMachException
to document these possible values, and handle them without specializing
based on the target arch.

rdar://123942164
---
 lldb/include/lldb/Target/Thread.h |  29 ++
 .../Process/Utility/StopInfoMachException.cpp | 296 +++---
 .../Process/Windows/Common/ProcessWindows.cpp |  16 +-
 .../Process/gdb-remote/ProcessGDBRemote.cpp   | 118 +++
 .../Process/scripted/ScriptedThread.cpp   |   9 +
 lldb/source/Target/Thread.cpp |  17 +-
 .../TestConsecutiveBreakpoints.py |  26 +-
 .../TestStepOverBreakpoint.py |   6 +-
 8 files changed, 235 insertions(+), 282 deletions(-)

diff --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index c17bddf4d98b8..1e1aead896018 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread

[Lldb-commits] [lldb] [LLDB][SaveCore] Add SBSaveCoreOptions Object, and SBProcess::SaveCore() overload (PR #98403)

2024-07-19 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

Addressed Windows issue in #99692

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


[Lldb-commits] [lldb] [LLDB][SBSaveCoreOptions] Fix TestProcessSaveCore (PR #99692)

2024-07-19 Thread Jacob Lalonde via lldb-commits

Jlalond wrote:

@labath Would you mind looking at this? Simple fix that got missed because it's 
a Window's only test

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


[Lldb-commits] [lldb] [LLDB][SBSaveCoreOptions] Fix TestProcessSaveCore (PR #99692)

2024-07-19 Thread Greg Clayton via lldb-commits

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


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


[Lldb-commits] [lldb] fada922 - [LLDB][SBSaveCoreOptions] Fix TestProcessSaveCore (#99692)

2024-07-19 Thread via lldb-commits

Author: Jacob Lalonde
Date: 2024-07-19T15:49:22-07:00
New Revision: fada9227325b3eaa0bdc09a486f29a7f08b7b3fb

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

LOG: [LLDB][SBSaveCoreOptions] Fix TestProcessSaveCore (#99692)

In #98403 some of the tests were transitioned to the new
`SBProcess::SaveCore(SBSaveCoreOptions)` API, but were not detected in
testing. This patch addresses that.

Added: 


Modified: 
lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py

Removed: 




diff  --git 
a/lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py 
b/lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py
index 07d06bdc116ec..8573d15733927 100644
--- a/lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py
+++ b/lldb/test/API/functionalities/process_save_core/TestProcessSaveCore.py
@@ -20,8 +20,8 @@ def test_cannot_save_core_unless_process_stopped(self):
 target = self.dbg.CreateTarget(exe)
 process = target.LaunchSimple(None, None, 
self.get_process_working_directory())
 self.assertNotEqual(process.GetState(), lldb.eStateStopped)
-options = SBSaveCoreOptions()
-options.SetOutputFile(SBFileSpec(core))
+options = lldb.SBSaveCoreOptions()
+options.SetOutputFile(lldb.SBFileSpec(core))
 error = process.SaveCore(core)
 self.assertTrue(error.Fail())
 



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


[Lldb-commits] [lldb] [LLDB][SBSaveCoreOptions] Fix TestProcessSaveCore (PR #99692)

2024-07-19 Thread Jacob Lalonde via lldb-commits

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


[Lldb-commits] [clang] [lldb] [llvm] [BOLT][DWARF][NFC] Split processUnitDIE into two lambdas (PR #99225)

2024-07-19 Thread Sayhaan Siddiqui via lldb-commits

https://github.com/sayhaan updated 
https://github.com/llvm/llvm-project/pull/99225

>From f07d79ccb57075ee75783cb4bd5cba4b4ca6af80 Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Tue, 1 Jun 2021 11:37:41 -0700
Subject: [PATCH 1/3] Rebase: [Facebook] Add clang driver options to test debug
 info and BOLT

Summary:
This is an essential piece of infrastructure for us to be
continuously testing debug info with BOLT. We can't only make changes
to a test repo because we need to change debuginfo tests to call BOLT,
hence, this diff needs to sit in our opensource repo. But when upstreaming
to LLVM, this should be kept BOLT-only outside of LLVM. When upstreaming,
we need to git diff and check all folders that are being modified by our
commits and discard this one (and leave as an internal diff).

To test BOLT in debuginfo tests, configure it with -DLLVM_TEST_BOLT=ON.
Then run check-lldb and check-debuginfo.

Manual rebase conflict history:
https://phabricator.intern.facebook.com/D29205224
https://phabricator.intern.facebook.com/D29564078
https://phabricator.intern.facebook.com/D33289118
https://phabricator.intern.facebook.com/D34957174
https://phabricator.intern.facebook.com/D35317341

Test Plan:
tested locally
Configured with:
-DLLVM_ENABLE_PROJECTS="clang;lld;lldb;compiler-rt;bolt;debuginfo-tests"
-DLLVM_TEST_BOLT=ON
Ran test suite with:
ninja check-debuginfo
ninja check-lldb

Reviewers: maks, #llvm-bolt

Reviewed By: maks

Subscribers: ayermolo, phabricatorlinter

Differential Revision: https://phabricator.intern.facebook.com/D46256657

Tasks: T92898286
---
 clang/include/clang/Driver/Options.td  |  4 
 clang/lib/Driver/ToolChains/Gnu.cpp| 29 ++
 cross-project-tests/lit.cfg.py | 14 -
 cross-project-tests/lit.site.cfg.py.in |  4 
 lldb/test/API/lit.cfg.py   |  5 +
 lldb/test/API/lit.site.cfg.py.in   |  8 +++
 lldb/test/Shell/helper/toolchain.py|  5 +
 lldb/test/Shell/lit.site.cfg.py.in |  9 
 llvm/CMakeLists.txt|  4 
 9 files changed, 81 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9c6cebd77ff0a..8ccbc4b372ba3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5553,6 +5553,10 @@ def pg : Flag<["-"], "pg">, HelpText<"Enable mcount 
instrumentation">,
   MarshallingInfoFlag>;
 def pipe : Flag<["-", "--"], "pipe">,
   HelpText<"Use pipes between commands, when possible">;
+// Facebook T92898286
+def post_link_optimize : Flag<["--"], "post-link-optimize">,
+  HelpText<"Apply post-link optimizations using BOLT">;
+// End Facebook T92898286
 def prebind__all__twolevel__modules : Flag<["-"], 
"prebind_all_twolevel_modules">;
 def prebind : Flag<["-"], "prebind">;
 def preload : Flag<["-"], "preload">;
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 52c2ee90b1b28..ff20deb9c4f86 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -672,12 +672,41 @@ void tools::gnutools::Linker::ConstructJob(Compilation 
&C, const JobAction &JA,
 }
   }
 
+  // Facebook T92898286
+  if (Args.hasArg(options::OPT_post_link_optimize))
+CmdArgs.push_back("-q");
+  // End Facebook T92898286
+
   Args.AddAllArgs(CmdArgs, options::OPT_T);
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
  ResponseFileSupport::AtFileCurCP(),
  Exec, CmdArgs, Inputs, Output));
+  // Facebook T92898286
+  if (!Args.hasArg(options::OPT_post_link_optimize) || !Output.isFilename())
+return;
+
+  const char *MvExec = Args.MakeArgString(ToolChain.GetProgramPath("mv"));
+  ArgStringList MoveCmdArgs;
+  MoveCmdArgs.push_back(Output.getFilename());
+  const char *PreBoltBin =
+  Args.MakeArgString(Twine(Output.getFilename()) + ".pre-bolt");
+  MoveCmdArgs.push_back(PreBoltBin);
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ MvExec, MoveCmdArgs, std::nullopt));
+
+  ArgStringList BoltCmdArgs;
+  const char *BoltExec =
+  Args.MakeArgString(ToolChain.GetProgramPath("llvm-bolt"));
+  BoltCmdArgs.push_back(PreBoltBin);
+  BoltCmdArgs.push_back("-reorder-blocks=reverse");
+  BoltCmdArgs.push_back("-update-debug-sections");
+  BoltCmdArgs.push_back("-o");
+  BoltCmdArgs.push_back(Output.getFilename());
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ BoltExec, BoltCmdArgs, std::nullopt));
+  // End Facebook T92898286
 }
 
 void tools::gnutools::Assembler::ConstructJob(Compilation &C,
diff --git a/cross-project-tests/lit.cfg.py b/cross-project-tests/lit.cfg.py
index 774c4eaf4d976..619634578dfe6 100644
--- a/cross-project-tests/lit.cfg.py
+++ b/c

[Lldb-commits] [lldb] [lldb][Windows] Fixed Host::Kill() (PR #99721)

2024-07-19 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/99721

HostProcessWindows::Terminate() correctly uses m_process which type is 
process_t (HANDLE) to call ::TerminateProcess(). But Host::Kill() uses a cast 
from pid, which is wrong.

>From 0712380a0ef60fae0a3035ac1e572bf9b1ea3bae Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sat, 20 Jul 2024 03:48:12 +0400
Subject: [PATCH] [lldb][Windows] Fixed Host::Kill()

HostProcessWindows::Terminate() correctly uses m_process which type is 
process_t (HANDLE) to call ::TerminateProcess().
But Host::Kill() uses a cast from pid, which is wrong.
---
 lldb/source/Host/windows/Host.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lldb/source/Host/windows/Host.cpp 
b/lldb/source/Host/windows/Host.cpp
index 6908f0003eaf7..642092f61d924 100644
--- a/lldb/source/Host/windows/Host.cpp
+++ b/lldb/source/Host/windows/Host.cpp
@@ -103,7 +103,9 @@ lldb::thread_t Host::GetCurrentThread() {
 }
 
 void Host::Kill(lldb::pid_t pid, int signo) {
-  TerminateProcess((HANDLE)pid, 1);
+  AutoHandle handle(::OpenProcess(PROCESS_TERMINATE, FALSE, pid), nullptr);
+  if (handle.IsValid())
+::TerminateProcess(handle.get(), 1);
 }
 
 const char *Host::GetSignalAsCString(int signo) { return NULL; }

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


[Lldb-commits] [lldb] [lldb][Windows] Fixed Host::Kill() (PR #99721)

2024-07-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

HostProcessWindows::Terminate() correctly uses m_process which type is 
process_t (HANDLE) to call ::TerminateProcess(). But Host::Kill() uses a cast 
from pid, which is wrong.

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


1 Files Affected:

- (modified) lldb/source/Host/windows/Host.cpp (+3-1) 


``diff
diff --git a/lldb/source/Host/windows/Host.cpp 
b/lldb/source/Host/windows/Host.cpp
index 6908f0003eaf7..642092f61d924 100644
--- a/lldb/source/Host/windows/Host.cpp
+++ b/lldb/source/Host/windows/Host.cpp
@@ -103,7 +103,9 @@ lldb::thread_t Host::GetCurrentThread() {
 }
 
 void Host::Kill(lldb::pid_t pid, int signo) {
-  TerminateProcess((HANDLE)pid, 1);
+  AutoHandle handle(::OpenProcess(PROCESS_TERMINATE, FALSE, pid), nullptr);
+  if (handle.IsValid())
+::TerminateProcess(handle.get(), 1);
 }
 
 const char *Host::GetSignalAsCString(int signo) { return NULL; }

``




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


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-19 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

The pre-merge linux-x86 test builds both failed in TestConcurrentVFork.py after 
I updated the branch to current main.  I don't know if there's a bot issue or a 
main issue.  I tried repoing on aarch64 ubuntu; that test is skipped on aarch64 
but I removed the skips and it runs without fails in my VM.  I'm going to try 
landing this and see what happens; will revert if bots blow up.  I've tried to 
test all the combinations I have access to here, and Aleksandr's testing on 
windows has been invaluable, but it's still possible it'll need a little 
reworking.

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


[Lldb-commits] [clang] [lldb] [llvm] [BOLT][DWARF][NFC] Split processUnitDIE into two lambdas (PR #99225)

2024-07-19 Thread Sayhaan Siddiqui via lldb-commits

https://github.com/sayhaan updated 
https://github.com/llvm/llvm-project/pull/99225

>From f07d79ccb57075ee75783cb4bd5cba4b4ca6af80 Mon Sep 17 00:00:00 2001
From: Amir Ayupov 
Date: Tue, 1 Jun 2021 11:37:41 -0700
Subject: [PATCH 1/4] Rebase: [Facebook] Add clang driver options to test debug
 info and BOLT

Summary:
This is an essential piece of infrastructure for us to be
continuously testing debug info with BOLT. We can't only make changes
to a test repo because we need to change debuginfo tests to call BOLT,
hence, this diff needs to sit in our opensource repo. But when upstreaming
to LLVM, this should be kept BOLT-only outside of LLVM. When upstreaming,
we need to git diff and check all folders that are being modified by our
commits and discard this one (and leave as an internal diff).

To test BOLT in debuginfo tests, configure it with -DLLVM_TEST_BOLT=ON.
Then run check-lldb and check-debuginfo.

Manual rebase conflict history:
https://phabricator.intern.facebook.com/D29205224
https://phabricator.intern.facebook.com/D29564078
https://phabricator.intern.facebook.com/D33289118
https://phabricator.intern.facebook.com/D34957174
https://phabricator.intern.facebook.com/D35317341

Test Plan:
tested locally
Configured with:
-DLLVM_ENABLE_PROJECTS="clang;lld;lldb;compiler-rt;bolt;debuginfo-tests"
-DLLVM_TEST_BOLT=ON
Ran test suite with:
ninja check-debuginfo
ninja check-lldb

Reviewers: maks, #llvm-bolt

Reviewed By: maks

Subscribers: ayermolo, phabricatorlinter

Differential Revision: https://phabricator.intern.facebook.com/D46256657

Tasks: T92898286
---
 clang/include/clang/Driver/Options.td  |  4 
 clang/lib/Driver/ToolChains/Gnu.cpp| 29 ++
 cross-project-tests/lit.cfg.py | 14 -
 cross-project-tests/lit.site.cfg.py.in |  4 
 lldb/test/API/lit.cfg.py   |  5 +
 lldb/test/API/lit.site.cfg.py.in   |  8 +++
 lldb/test/Shell/helper/toolchain.py|  5 +
 lldb/test/Shell/lit.site.cfg.py.in |  9 
 llvm/CMakeLists.txt|  4 
 9 files changed, 81 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9c6cebd77ff0a..8ccbc4b372ba3 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5553,6 +5553,10 @@ def pg : Flag<["-"], "pg">, HelpText<"Enable mcount 
instrumentation">,
   MarshallingInfoFlag>;
 def pipe : Flag<["-", "--"], "pipe">,
   HelpText<"Use pipes between commands, when possible">;
+// Facebook T92898286
+def post_link_optimize : Flag<["--"], "post-link-optimize">,
+  HelpText<"Apply post-link optimizations using BOLT">;
+// End Facebook T92898286
 def prebind__all__twolevel__modules : Flag<["-"], 
"prebind_all_twolevel_modules">;
 def prebind : Flag<["-"], "prebind">;
 def preload : Flag<["-"], "preload">;
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 52c2ee90b1b28..ff20deb9c4f86 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -672,12 +672,41 @@ void tools::gnutools::Linker::ConstructJob(Compilation 
&C, const JobAction &JA,
 }
   }
 
+  // Facebook T92898286
+  if (Args.hasArg(options::OPT_post_link_optimize))
+CmdArgs.push_back("-q");
+  // End Facebook T92898286
+
   Args.AddAllArgs(CmdArgs, options::OPT_T);
 
   const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
   C.addCommand(std::make_unique(JA, *this,
  ResponseFileSupport::AtFileCurCP(),
  Exec, CmdArgs, Inputs, Output));
+  // Facebook T92898286
+  if (!Args.hasArg(options::OPT_post_link_optimize) || !Output.isFilename())
+return;
+
+  const char *MvExec = Args.MakeArgString(ToolChain.GetProgramPath("mv"));
+  ArgStringList MoveCmdArgs;
+  MoveCmdArgs.push_back(Output.getFilename());
+  const char *PreBoltBin =
+  Args.MakeArgString(Twine(Output.getFilename()) + ".pre-bolt");
+  MoveCmdArgs.push_back(PreBoltBin);
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ MvExec, MoveCmdArgs, std::nullopt));
+
+  ArgStringList BoltCmdArgs;
+  const char *BoltExec =
+  Args.MakeArgString(ToolChain.GetProgramPath("llvm-bolt"));
+  BoltCmdArgs.push_back(PreBoltBin);
+  BoltCmdArgs.push_back("-reorder-blocks=reverse");
+  BoltCmdArgs.push_back("-update-debug-sections");
+  BoltCmdArgs.push_back("-o");
+  BoltCmdArgs.push_back(Output.getFilename());
+  C.addCommand(std::make_unique(JA, *this, 
ResponseFileSupport::None(),
+ BoltExec, BoltCmdArgs, std::nullopt));
+  // End Facebook T92898286
 }
 
 void tools::gnutools::Assembler::ConstructJob(Compilation &C,
diff --git a/cross-project-tests/lit.cfg.py b/cross-project-tests/lit.cfg.py
index 774c4eaf4d976..619634578dfe6 100644
--- a/cross-project-tests/lit.cfg.py
+++ b/c

[Lldb-commits] [lldb] 05f0e86 - [lldb] Change lldb's breakpoint handling behavior (#96260)

2024-07-19 Thread via lldb-commits

Author: Jason Molenda
Date: 2024-07-19T17:26:13-07:00
New Revision: 05f0e86cc895181b3d2210458c78938f83353002

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

LOG: [lldb] Change lldb's breakpoint handling behavior (#96260)

lldb today has two rules: When a thread stops at a BreakpointSite, we
set the thread's StopReason to be "breakpoint hit" (regardless if we've
actually hit the breakpoint, or if we've merely stopped *at* the
breakpoint instruction/point and haven't tripped it yet). And second,
when resuming a process, any thread sitting at a BreakpointSite is
silently stepped over the BreakpointSite -- because we've already
flagged the breakpoint hit when we stopped there originally.

In this patch, I change lldb to only set a thread's stop reason to
breakpoint-hit when we've actually executed the instruction/triggered
the breakpoint. When we resume, we only silently step past a
BreakpointSite that we've registered as hit. We preserve this state
across inferior function calls that the user may do while stopped, etc.

Also, when a user adds a new breakpoint at $pc while stopped, or changes
$pc to be the address of a BreakpointSite, we will silently step past
that breakpoint when the process resumes. This is purely a UX call, I
don't think there's any person who wants to set a breakpoint at $pc and
then hit it immediately on resuming.

One non-intuitive UX from this change, but I'm convinced it is
necessary: If you're stopped at a BreakpointSite that has not yet
executed, you `stepi`, you will hit the breakpoint and the pc will not
yet advance. This thread has not completed its stepi, and the thread
plan is still on the stack. If you then `continue` the thread, lldb will
now stop and say, "instruction step completed", one instruction past the
BreakpointSite. You can continue a second time to resume execution. I
discussed this with Jim, and trying to paper over this behavior will
lead to more complicated scenarios behaving non-intuitively. And mostly
it's the testsuite that was trying to instruction step past a breakpoint
and getting thrown off -- and I changed those tests to expect the new
behavior.

The bugs driving this change are all from lldb dropping the real stop
reason for a thread and setting it to breakpoint-hit when that was not
the case. Jim hit one where we have an aarch64 watchpoint that triggers
one instruction before a BreakpointSite. On this arch we are notified of
the watchpoint hit after the instruction has been unrolled -- we disable
the watchpoint, instruction step, re-enable the watchpoint and collect
the new value. But now we're on a BreakpointSite so the watchpoint-hit
stop reason is lost.

Another was reported by ZequanWu in
https://discourse.llvm.org/t/lldb-unable-to-break-at-start/78282 we
attach to/launch a process with the pc at a BreakpointSite and
misbehave. Caroline Tice mentioned it is also a problem they've had with
putting a breakpoint on _dl_debug_state.

The change to each Process plugin that does execution control is that

1. If we've stopped at a BreakpointSite that has not been executed yet,
we will call Thread::SetThreadStoppedAtUnexecutedBP(pc) to record
that.  When the thread resumes, if the pc is still at the same site, we
will continue, hit the breakpoint, and stop again.

2. When we've actually hit a breakpoint (enabled for this thread or not),
the Process plugin should call Thread::SetThreadHitBreakpointSite().
When we go to resume the thread, we will push a step-over-breakpoint
ThreadPlan before resuming.

The biggest set of changes is to StopInfoMachException where we
translate a Mach Exception into a stop reason. The Mach exception codes
differ in a few places depending on the target (unambiguously), and I
didn't want to duplicate the new code for each target so I've tested
what mach exceptions we get for each action on each target, and
reorganized StopInfoMachException::CreateStopReasonWithMachException to
document these possible values, and handle them without specializing
based on the target arch.

rdar://123942164

Added: 


Modified: 
lldb/include/lldb/Target/Thread.h
lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
lldb/source/Target/StopInfo.cpp
lldb/source/Target/Thread.cpp

lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py

lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py

Removed: 




diff  --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index 2ff1f50d497e2..d3e429e9256df 100644
--- a/ll

[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-19 Thread Jason Molenda via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-19 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`cross-project-tests-sie-ubuntu-dwarf5` running on `doug-worker-1b` while 
building `lldb` at step 6 "test-build-unified-tree-check-cross-project".

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

Here is the relevant piece of the build log for the reference:
```
Step 6 (test-build-unified-tree-check-cross-project) failure: test (failure)
 TEST 'cross-project-tests :: 
debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp' FAILED 

Exit Code: 1

Command Output (stderr):
--
RUN: at line 14: clang++ -O0 -glldb -std=gnu++11 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp
 -o 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/projects/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/Output/address_printing.cpp.tmp
+ clang++ -O0 -glldb -std=gnu++11 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp
 -o 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/projects/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/Output/address_printing.cpp.tmp
RUN: at line 15: not "/usr/bin/python3.10" 
"/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/cross-project-tests/debuginfo-tests/dexter/dexter.py"
 test --fail-lt 1.0 -w --debugger lldb --binary 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/projects/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/Output/address_printing.cpp.tmp
 -v -- 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp
 | 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/bin/FileCheck
 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp
+ 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/bin/FileCheck
 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp
+ not /usr/bin/python3.10 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/cross-project-tests/debuginfo-tests/dexter/dexter.py
 test --fail-lt 1.0 -w --debugger lldb --binary 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/build/projects/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/Output/address_printing.cpp.tmp
 -v -- 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp:34:16:
 error: CHECK-NEXT: expected string not found in input
// CHECK-NEXT: (0x[[Y_VAL]]): step 4
   ^
:37:20: note: scanning from here
 misordered result:
   ^
:37:20: note: with "Y_VAL" equal to 
"5556aed0"
 misordered result:
   ^
:38:16: note: possible intended match here
 (0x5556aed0): step 6 [-3]
   ^

Input file: 
Check file: 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp

-dump-input=help explains the following input dump.

Input was:
<<
1: address_printing.cpp: (0.5714) 

2:  
3: ## BEGIN ## 
4: [1, "main", 
"/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp",
 38, 14, "StopReason.BREAKPOINT", "StepKind.FUNC", []] 
5: [2, "main", 
"/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu-dwarf5/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/subtools/test/address_printing.cpp",
 39, 14, "StopReason.STEP", "StepKind.VERTICAL_FORWARD", []] 
6: [3, "main", 
"/home/buildbot/buildbot

[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-19 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`cross-project-tests-sie-ubuntu` running on `doug-worker-1a` while building 
`lldb` at step 6 "test-build-unified-tree-check-cross-project".

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

Here is the relevant piece of the build log for the reference:
```
Step 6 (test-build-unified-tree-check-cross-project) failure: test (failure)
 TEST 'cross-project-tests :: 
debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_conditional_hit_count.cpp'
 FAILED 
Exit Code: 2

Command Output (stderr):
--
RUN: at line 10: clang++ -O0 -glldb -std=gnu++11 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_conditional_hit_count.cpp
 -o 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/projects/cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/Output/default_conditional_hit_count.cpp.tmp
+ clang++ -O0 -glldb -std=gnu++11 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_conditional_hit_count.cpp
 -o 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/projects/cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/Output/default_conditional_hit_count.cpp.tmp
RUN: at line 11: "/usr/bin/python3.8" 
"/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter/dexter.py"
 test --fail-lt 1.0 -w --debugger lldb --binary 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/projects/cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/Output/default_conditional_hit_count.cpp.tmp
 -- 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_conditional_hit_count.cpp
 | 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/bin/FileCheck 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_conditional_hit_count.cpp
+ /usr/bin/python3.8 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter/dexter.py
 test --fail-lt 1.0 -w --debugger lldb --binary 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/projects/cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/Output/default_conditional_hit_count.cpp.tmp
 -- 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_conditional_hit_count.cpp
+ 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/build/bin/FileCheck 
/home/buildbot/buildbot-root/cross-project-tests-sie-ubuntu/llvm-project/cross-project-tests/debuginfo-tests/dexter/feature_tests/commands/perfect/dex_finish_test/default_conditional_hit_count.cpp

--




```

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


[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-19 Thread LLVM Continuous Integration via lldb-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `lldb-arm-ubuntu` running 
on `linaro-lldb-arm-ubuntu` while building `lldb` at step 6 "test".

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

Here is the relevant piece of the build log for the reference:
```
Step 6 (test) failure: build (failure)
...
PASS: lldb-api :: symbol_ondemand/shared_library/TestSharedLibOnDemand.py (1098 
of 2753)
PASS: lldb-api :: terminal/TestSTTYBeforeAndAfter.py (1099 of 2753)
PASS: lldb-api :: test_utils/TestDecorators.py (1100 of 2753)
PASS: lldb-api :: test_utils/TestInlineTest.py (1101 of 2753)
PASS: lldb-api :: test_utils/TestPExpectTest.py (1102 of 2753)
PASS: lldb-api :: test_utils/base/TestBaseTest.py (1103 of 2753)
PASS: lldb-api :: terminal/TestEditline.py (1104 of 2753)
PASS: lldb-api :: tools/lldb-dap/attach/TestDAP_attach.py (1105 of 2753)
UNSUPPORTED: lldb-api :: 
tools/lldb-dap/breakpoint-events/TestDAP_breakpointEvents.py (1106 of 2753)
TIMEOUT: lldb-api :: 
functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
 (1107 of 2753)
 TEST 'lldb-api :: 
functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py'
 FAILED 
Script:
--
/usr/bin/python3.8 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/dotest.py 
-u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/local/bin/llvm-ar --env 
OBJCOPY=/usr/bin/llvm-objcopy --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include --env 
LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --arch 
armv8l --build-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/lldb 
--compiler /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/clang 
--dsymutil /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/dsymutil 
--llvm-tools-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin 
--lldb-obj-root /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/tools/lldb 
--lldb-libs-dir /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/functionalities/breakpoint/consecutive_breakpoints
 -p TestConsecutiveBreakpoints.py
--
Exit Code: -9
Timeout: Reached timeout of 600 seconds

Command Output (stdout):
--
lldb version 19.0.0git (https://github.com/llvm/llvm-project.git revision 
05f0e86cc895181b3d2210458c78938f83353002)
  clang revision 05f0e86cc895181b3d2210458c78938f83353002
  llvm revision 05f0e86cc895181b3d2210458c78938f83353002

--


PASS: lldb-api :: tools/lldb-dap/breakpoint/TestDAP_logpoints.py (1108 of 2753)
PASS: lldb-api :: tools/lldb-dap/breakpoint/TestDAP_setExceptionBreakpoints.py 
(1109 of 2753)
PASS: lldb-api :: tools/lldb-dap/breakpoint/TestDAP_setBreakpoints.py (1110 of 
2753)
PASS: lldb-api :: tools/lldb-dap/commands/TestDAP_commands.py ( of 2753)
PASS: lldb-api :: tools/lldb-dap/attach/TestDAP_attachByPortNum.py (1112 of 
2753)
PASS: lldb-api :: tools/lldb-dap/breakpoint/TestDAP_setFunctionBreakpoints.py 
(1113 of 2753)
PASS: lldb-api :: tools/lldb-dap/console/TestDAP_redirection_to_console.py 
(1114 of 2753)
PASS: lldb-api :: tools/lldb-dap/completions/TestDAP_completions.py (1115 of 
2753)
PASS: lldb-api :: tools/lldb-dap/coreFile/TestDAP_coreFile.py (1116 of 2753)
PASS: lldb-api :: tools/lldb-dap/disassemble/TestDAP_disassemble.py (1117 of 
2753)
TIMEOUT: lldb-api :: 
functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py (1118 
of 2753)
 TEST 'lldb-api :: 
functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py' 
FAILED 
Script:
--
/usr/bin/python3.8 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/llvm-project/lldb/test/API/dotest.py 
-u CXXFLAGS -u CFLAGS --env ARCHIVER=/usr/local/bin/llvm-ar --env 
OBJCOPY=/usr/bin/llvm-objcopy --env 
LLVM_LIBS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./lib --env 
LLVM_INCLUDE_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/include --env 
LLVM_TOOLS_DIR=/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin --arch 
armv8l --build-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex 
--lldb-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-lldb/lldb-api
 --clang-module-cache-dir 
/home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/lldb-test-build.noindex/module-cache-clang/lldb-api
 --executable /home/tcwg-buildbot/worker/lldb-arm-ubuntu/build/./bin/lldb 

[Lldb-commits] [lldb] 52c08d7 - Revert "[lldb] Change lldb's breakpoint handling behavior (#96260)"

2024-07-19 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2024-07-19T18:43:53-07:00
New Revision: 52c08d7ffd380f4abd819c20bec76252272f6337

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

LOG: Revert "[lldb] Change lldb's breakpoint handling behavior (#96260)"

This reverts commit 05f0e86cc895181b3d2210458c78938f83353002.

The debuginfo dexter tests are failing, probably because the way
stepping over breakpoints has changed with my patches.  And there
are two API tests fails on the ubuntu-arm (32-bit) bot. I'll need
to investigate both of these, neither has an obvious failure reason.

Added: 


Modified: 
lldb/include/lldb/Target/Thread.h
lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
lldb/source/Plugins/Process/Windows/Common/ProcessWindows.cpp
lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
lldb/source/Plugins/Process/scripted/ScriptedThread.cpp
lldb/source/Target/StopInfo.cpp
lldb/source/Target/Thread.cpp

lldb/test/API/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py

lldb/test/API/functionalities/breakpoint/step_over_breakpoint/TestStepOverBreakpoint.py

Removed: 




diff  --git a/lldb/include/lldb/Target/Thread.h 
b/lldb/include/lldb/Target/Thread.h
index d3e429e9256df..2ff1f50d497e2 100644
--- a/lldb/include/lldb/Target/Thread.h
+++ b/lldb/include/lldb/Target/Thread.h
@@ -129,7 +129,6 @@ class Thread : public std::enable_shared_from_this,
 register_backup_sp; // You need to restore the registers, of course...
 uint32_t current_inlined_depth;
 lldb::addr_t current_inlined_pc;
-lldb::addr_t stopped_at_unexecuted_bp;
   };
 
   /// Constructor
@@ -379,26 +378,6 @@ class Thread : public std::enable_shared_from_this,
 
   virtual void SetQueueLibdispatchQueueAddress(lldb::addr_t dispatch_queue_t) 
{}
 
-  /// When a thread stops at an enabled BreakpointSite that has not executed,
-  /// the Process plugin should call SetThreadStoppedAtUnexecutedBP(pc).
-  /// If that BreakpointSite was actually triggered (the instruction was
-  /// executed, for a software breakpoint), regardless of whether the
-  /// breakpoint is valid for this thread, SetThreadHitBreakpointSite()
-  /// should be called to record that fact.
-  ///
-  /// Depending on the structure of the Process plugin, it may be easiest
-  /// to call SetThreadStoppedAtUnexecutedBP(pc) unconditionally when at
-  /// a BreakpointSite, and later when it is known that it was triggered,
-  /// SetThreadHitBreakpointSite() can be called.  These two methods
-  /// overwrite the same piece of state in the Thread, the last one
-  /// called on a Thread wins.
-  void SetThreadStoppedAtUnexecutedBP(lldb::addr_t pc) {
-m_stopped_at_unexecuted_bp = pc;
-  }
-  void SetThreadHitBreakpointSite() {
-m_stopped_at_unexecuted_bp = LLDB_INVALID_ADDRESS;
-  }
-
   /// Whether this Thread already has all the Queue information cached or not
   ///
   /// A Thread may be associated with a libdispatch work Queue at a given
@@ -1333,9 +1312,6 @@ class Thread : public 
std::enable_shared_from_this,
   bool m_should_run_before_public_stop;  // If this thread has "stop others" 
  // private work to do, then it will
  // set this.
-  lldb::addr_t m_stopped_at_unexecuted_bp; // Set to the address of a 
breakpoint
-   // instruction that we have not yet
-   // hit, but will hit when we resume.
   const uint32_t m_index_id; ///< A unique 1 based index assigned to each 
thread
  /// for easy UI/command line access.
   lldb::RegisterContextSP m_reg_context_sp; ///< The register context for this

diff  --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp 
b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
index f1853be12638e..25cee369d7ee3 100644
--- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -488,6 +488,38 @@ const char *StopInfoMachException::GetDescription() {
   return m_description.c_str();
 }
 
+static StopInfoSP GetStopInfoForHardwareBP(Thread &thread, Target *target,
+   uint32_t exc_data_count,
+   uint64_t exc_sub_code,
+   uint64_t exc_sub_sub_code) {
+  // Try hardware watchpoint.
+  if (target) {
+// The exc_sub_code indicates the data break address.
+WatchpointResourceSP wp_rsrc_sp =
+target->GetProcessSP()->GetWatchpointResourceList().FindByAddress(
+(addr_t)exc_sub_code);
+if (wp_rsrc_sp && wp_rsrc

[Lldb-commits] [lldb] [lldb] Change lldb's breakpoint handling behavior (PR #96260)

2024-07-19 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

I've reverted this change until I can debug the failures found on the CI bots.  

Two debuginfo dexter tests failed, likely because the way stepping and 
breakpoints works is now different.  If you're sitting at a BreakpointSite 
which has not yet executed, previously lldb would overwrite the stop reason 
with "breakpoint hit" even though it had not been hit.  Now, you'll have your 
actual stop reason -- and when you resume, you'll hit the breakpoint and stop 
again.  If you 'continue', it stops again.  If you 'next/step', it stops again 
and your next/step is still on the thread plan stack, so if you 'continue', 
you're going to first do the next/step that was on the thread stack, and then 
you can do your other command.

I've spent a lot of time thinking about any other approach to this, and they 
all have bad outcomes that we don't want to add.

In short, I expect the debuginfo tests are continuing from a breakpoint and not 
expecting the breakpoint to be hit.

The ubuntu-arm bot failed TestConsecutiveBreakpoints.py and 
TestConsecutiveBreakpoints.py, but it seems like the only failure text was like 
"process exited -9" or something.  I may need to re-land the patch with a lot 
more logging enabled on these two, to narrow down what this bot is seeing.  I 
let it run an extra cycle and it failed in the same spot again, so it wasn't a 
oneoff error.

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Robert O'Callahan via lldb-commits

https://github.com/rocallahan created 
https://github.com/llvm/llvm-project/pull/99736

This commit only adds support for the
`SBProcess::ReverseContinue()` API. A user-accessible command for this will 
follow in a later commit.

This feature depends on a gdbserver implementation (e.g. `rr`) providing 
support for the `bc` and `bs` packets. `lldb-server` does not support those 
packets, and there is no plan to change that. So, for testing purposes, 
`lldbreverse.py` wraps `lldb-server` with a Python implementation of *very 
limited* record-and-replay functionality for use by *tests only*.

The majority of this PR is test infrastructure (about 700 of the 950 lines 
added).

>From ce13a715cf12571431b5d7cfc9293dfaa1ff2d4b Mon Sep 17 00:00:00 2001
From: Robert O'Callahan 
Date: Fri, 19 Jul 2024 22:46:42 +1200
Subject: [PATCH] [lldb] Implement basic support for reverse-continue

This commit only adds support for the
`SBProcess::ReverseContinue()` API. A user-accessible command
for this will follow in a later commit.

This feature depends on a gdbserver implementation (e.g. `rr`)
providing support for the `bc` and `bs` packets. `lldb-server`
does not support those packets, and there is no plan to change that.
So, for testing purposes, `lldbreverse.py` wraps `lldb-server`
with a Python implementation of *very limited* record-and-replay
functionality.
---
 lldb/include/lldb/API/SBProcess.h |   2 +
 lldb/include/lldb/Target/Process.h|  25 +-
 lldb/include/lldb/Target/StopInfo.h   |   3 +
 lldb/include/lldb/lldb-enumerations.h |   4 +
 .../Python/lldbsuite/test/gdbclientutils.py   |   5 +-
 .../Python/lldbsuite/test/lldbgdbproxy.py | 176 
 .../Python/lldbsuite/test/lldbreverse.py  | 415 ++
 .../Python/lldbsuite/test/lldbtest.py |   2 +
 lldb/source/API/SBProcess.cpp |  20 +
 lldb/source/API/SBThread.cpp  |   2 +
 .../source/Interpreter/CommandInterpreter.cpp |   3 +-
 .../Process/Linux/NativeThreadLinux.cpp   |   3 +
 .../GDBRemoteCommunicationClient.cpp  |  22 +
 .../gdb-remote/GDBRemoteCommunicationClient.h |   6 +
 .../GDBRemoteCommunicationServerLLGS.cpp  |   1 +
 .../Process/gdb-remote/ProcessGDBRemote.cpp   | 119 -
 .../Process/gdb-remote/ProcessGDBRemote.h |   2 +
 lldb/source/Target/Process.cpp|  29 +-
 lldb/source/Target/StopInfo.cpp   |  29 ++
 lldb/source/Target/Thread.cpp |   8 +-
 .../reverse-execution/Makefile|   3 +
 .../TestReverseContinueBreakpoints.py |  79 
 .../functionalities/reverse-execution/main.c  |  12 +
 lldb/tools/lldb-dap/JSONUtils.cpp |   3 +
 lldb/tools/lldb-dap/LLDBUtils.cpp |   1 +
 25 files changed, 946 insertions(+), 28 deletions(-)
 create mode 100644 lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py
 create mode 100644 lldb/packages/Python/lldbsuite/test/lldbreverse.py
 create mode 100644 lldb/test/API/functionalities/reverse-execution/Makefile
 create mode 100644 
lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
 create mode 100644 lldb/test/API/functionalities/reverse-execution/main.c

diff --git a/lldb/include/lldb/API/SBProcess.h 
b/lldb/include/lldb/API/SBProcess.h
index 778be79583990..9b17bac0093e6 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -160,6 +160,8 @@ class LLDB_API SBProcess {
 
   lldb::SBError Continue();
 
+  lldb::SBError ReverseContinue();
+
   lldb::SBError Stop();
 
   lldb::SBError Kill();
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index c8475db8ae160..203d3484f3704 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -874,10 +874,10 @@ class Process : public 
std::enable_shared_from_this,
   /// \see Thread:Resume()
   /// \see Thread:Step()
   /// \see Thread:Suspend()
-  Status Resume();
+  Status Resume(lldb::RunDirection direction = lldb::eRunForward);
 
   /// Resume a process, and wait for it to stop.
-  Status ResumeSynchronous(Stream *stream);
+  Status ResumeSynchronous(Stream *stream, lldb::RunDirection direction = 
lldb::eRunForward);
 
   /// Halts a running process.
   ///
@@ -1136,6 +1136,22 @@ class Process : public 
std::enable_shared_from_this,
 return error;
   }
 
+  /// Like DoResume() but executes in reverse if supported.
+  ///
+  /// \return
+  /// Returns \b true if the process successfully resumes using
+  /// the thread run control actions, \b false otherwise.
+  ///
+  /// \see Thread:Resume()
+  /// \see Thread:Step()
+  /// \see Thread:Suspend()
+  virtual Status DoResumeReverse() {
+Status error;
+error.SetErrorStringWithFormatv(
+"error: {0} does not support reverse execution of processes", 
GetPluginName());
+return error;
+  }
+
   /// Called after resuming a process.
   ///
   /// Allow Process plug-ins 

[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread via lldb-commits

github-actions[bot] wrote:



Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment โ€œPingโ€. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Robert O'Callahan (rocallahan)


Changes

This commit only adds support for the
`SBProcess::ReverseContinue()` API. A user-accessible command for this will 
follow in a later commit.

This feature depends on a gdbserver implementation (e.g. `rr`) providing 
support for the `bc` and `bs` packets. `lldb-server` does not support those 
packets, and there is no plan to change that. So, for testing purposes, 
`lldbreverse.py` wraps `lldb-server` with a Python implementation of *very 
limited* record-and-replay functionality for use by *tests only*.

The majority of this PR is test infrastructure (about 700 of the 950 lines 
added).

---

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


25 Files Affected:

- (modified) lldb/include/lldb/API/SBProcess.h (+2) 
- (modified) lldb/include/lldb/Target/Process.h (+22-3) 
- (modified) lldb/include/lldb/Target/StopInfo.h (+3) 
- (modified) lldb/include/lldb/lldb-enumerations.h (+4) 
- (modified) lldb/packages/Python/lldbsuite/test/gdbclientutils.py (+3-2) 
- (added) lldb/packages/Python/lldbsuite/test/lldbgdbproxy.py (+176) 
- (added) lldb/packages/Python/lldbsuite/test/lldbreverse.py (+415) 
- (modified) lldb/packages/Python/lldbsuite/test/lldbtest.py (+2) 
- (modified) lldb/source/API/SBProcess.cpp (+20) 
- (modified) lldb/source/API/SBThread.cpp (+2) 
- (modified) lldb/source/Interpreter/CommandInterpreter.cpp (+2-1) 
- (modified) lldb/source/Plugins/Process/Linux/NativeThreadLinux.cpp (+3) 
- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp (+22) 
- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.h (+6) 
- (modified) 
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp 
(+1) 
- (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp 
(+108-11) 
- (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (+2) 
- (modified) lldb/source/Target/Process.cpp (+20-9) 
- (modified) lldb/source/Target/StopInfo.cpp (+29) 
- (modified) lldb/source/Target/Thread.cpp (+6-2) 
- (added) lldb/test/API/functionalities/reverse-execution/Makefile (+3) 
- (added) 
lldb/test/API/functionalities/reverse-execution/TestReverseContinueBreakpoints.py
 (+79) 
- (added) lldb/test/API/functionalities/reverse-execution/main.c (+12) 
- (modified) lldb/tools/lldb-dap/JSONUtils.cpp (+3) 
- (modified) lldb/tools/lldb-dap/LLDBUtils.cpp (+1) 


``diff
diff --git a/lldb/include/lldb/API/SBProcess.h 
b/lldb/include/lldb/API/SBProcess.h
index 778be79583990..9b17bac0093e6 100644
--- a/lldb/include/lldb/API/SBProcess.h
+++ b/lldb/include/lldb/API/SBProcess.h
@@ -160,6 +160,8 @@ class LLDB_API SBProcess {
 
   lldb::SBError Continue();
 
+  lldb::SBError ReverseContinue();
+
   lldb::SBError Stop();
 
   lldb::SBError Kill();
diff --git a/lldb/include/lldb/Target/Process.h 
b/lldb/include/lldb/Target/Process.h
index c8475db8ae160..203d3484f3704 100644
--- a/lldb/include/lldb/Target/Process.h
+++ b/lldb/include/lldb/Target/Process.h
@@ -874,10 +874,10 @@ class Process : public 
std::enable_shared_from_this,
   /// \see Thread:Resume()
   /// \see Thread:Step()
   /// \see Thread:Suspend()
-  Status Resume();
+  Status Resume(lldb::RunDirection direction = lldb::eRunForward);
 
   /// Resume a process, and wait for it to stop.
-  Status ResumeSynchronous(Stream *stream);
+  Status ResumeSynchronous(Stream *stream, lldb::RunDirection direction = 
lldb::eRunForward);
 
   /// Halts a running process.
   ///
@@ -1136,6 +1136,22 @@ class Process : public 
std::enable_shared_from_this,
 return error;
   }
 
+  /// Like DoResume() but executes in reverse if supported.
+  ///
+  /// \return
+  /// Returns \b true if the process successfully resumes using
+  /// the thread run control actions, \b false otherwise.
+  ///
+  /// \see Thread:Resume()
+  /// \see Thread:Step()
+  /// \see Thread:Suspend()
+  virtual Status DoResumeReverse() {
+Status error;
+error.SetErrorStringWithFormatv(
+"error: {0} does not support reverse execution of processes", 
GetPluginName());
+return error;
+  }
+
   /// Called after resuming a process.
   ///
   /// Allow Process plug-ins to execute some code after resuming a process.
@@ -2367,6 +2383,8 @@ class Process : public 
std::enable_shared_from_this,
 
   bool IsRunning() const;
 
+  lldb::RunDirection GetLastRunDirection() { return m_last_run_direction; }
+
   DynamicCheckerFunctions *GetDynamicCheckers() {
 return m_dynamic_checkers_up.get();
   }
@@ -2861,7 +2879,7 @@ void PruneThreadPlans();
   ///
   /// \return
   /// An Status object describing the success or failure of the resume.
-  Status PrivateResume();
+  Status PrivateResume(lldb::RunDirection direction = lldb::eRunForward);
 
   // Called internally
   void CompleteAttach();
@@ -3139,6 +3157,7 @@ void PruneThreadPlans();

[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Robert O'Callahan via lldb-commits

rocallahan wrote:

BTW this was discussed in 
https://discourse.llvm.org/t/how-to-test-reverse-execution-support-in-lldb/79696.

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,12 @@
+static void start_recording() {}
+
+static void trigger_breakpoint() {}
+
+static void stop_recording() {}

medismailben wrote:

It would be nice to add some sample code in each of these functions to test of 
lldb behaves with things like variable inspection, source listing, etc.

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Med Ismail Bennani via lldb-commits


@@ -1395,6 +1395,91 @@ Status ProcessGDBRemote::DoResume() {
   return error;
 }
 
+Status ProcessGDBRemote::DoResumeReverse() {
+  Status error;
+  Log *log = GetLog(GDBRLog::Process);
+  LLDB_LOGF(log, "ProcessGDBRemote::DoResumeReverse()");
+
+  ListenerSP listener_sp(
+  Listener::MakeListener("gdb-remote.resume-packet-sent"));
+  if (listener_sp->StartListeningForEvents(
+  &m_gdb_comm, GDBRemoteClientBase::eBroadcastBitRunPacketSent)) {
+listener_sp->StartListeningForEvents(
+&m_async_broadcaster,
+ProcessGDBRemote::eBroadcastBitAsyncThreadDidExit);
+
+const size_t num_threads = GetThreadList().GetSize();
+
+StreamString continue_packet;
+
+const size_t num_continue_C_tids = m_continue_C_tids.size();
+const size_t num_continue_s_tids = m_continue_s_tids.size();
+const size_t num_continue_S_tids = m_continue_S_tids.size();

medismailben wrote:

Could you explicit what's the difference between each of these ?

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Med Ismail Bennani via lldb-commits


@@ -1881,18 +1970,24 @@ ThreadSP ProcessGDBRemote::SetThreadStopInfo(
   handled = true;
 }
   } else if (!signo) {
-addr_t pc = thread_sp->GetRegisterContext()->GetPC();
-lldb::BreakpointSiteSP bp_site_sp =
-thread_sp->GetProcess()->GetBreakpointSiteList().FindByAddress(pc);
-
-// If a thread is stopped at a breakpoint site, set that as the stop
-// reason even if it hasn't executed the breakpoint instruction yet.
-// We will silently step over the breakpoint when we resume execution
-// and miss the fact that this thread hit the breakpoint.
-if (bp_site_sp && bp_site_sp->ValidForThisThread(*thread_sp)) {
-  
thread_sp->SetStopInfo(StopInfo::CreateStopReasonWithBreakpointSiteID(
-  *thread_sp, bp_site_sp->GetID()));
+if (m_last_run_direction == eRunReverse) {

medismailben wrote:

nit: let's keep the `forward` case the main branch since this should be the 
default case most of the time.

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Med Ismail Bennani via lldb-commits

https://github.com/medismailben commented:

This is very interesting, I've left a few comments here and there but I've 
noticed you didn't check if this works both when the debugger is in synchronous 
and asynchronous in your tests. This is definitely something you want to 
exercise since it changes lldb's execution control behavior.

Also, I'm not sure what additional information does the `History Boundary` stop 
reason provides. Can it actually provide historical data to the user ? If so, 
I'm not sure the stop reason is the best place to put it. May be it would be 
worth adding a new subcommand to [the trace top-level 
command](https://github.com/llvm/llvm-project/blob/main/lldb/source/Commands/CommandObjectTrace.cpp#L379)
 ?

Thanks!

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,79 @@
+import lldb
+import unittest
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbreverse import ReverseTestBase
+from lldbsuite.test import lldbutil
+
+
+class TestReverseContinueBreakpoints(ReverseTestBase):
+@add_test_categories(["dwarf"])
+def test_reverse_continue(self):
+target, process, initial_threads = self.setup_recording()
+
+# Reverse-continue. We'll stop at the point where we started recording.
+status = process.ReverseContinue()
+self.assertSuccess(status)
+self.expect(
+"thread list",
+STOPPED_DUE_TO_HISTORY_BOUNDARY,
+substrs=["stopped", "stop reason = history boundary"],
+)
+
+# Continue forward normally until the target exits.
+status = process.Continue()
+self.assertSuccess(status)
+self.assertState(process.GetState(), lldb.eStateExited)
+self.assertEqual(process.GetExitStatus(), 0)
+
+@add_test_categories(["dwarf"])
+def test_reverse_continue_breakpoint(self):
+target, process, initial_threads = self.setup_recording()
+
+# Reverse-continue to the function "trigger_breakpoint".
+trigger_bkpt = target.BreakpointCreateByName("trigger_breakpoint", 
None)
+status = process.ReverseContinue()
+self.assertSuccess(status)
+threads_now = lldbutil.get_threads_stopped_at_breakpoint(process, 
trigger_bkpt)
+self.assertEqual(threads_now, initial_threads)

medismailben wrote:

How does this test that we're actually stopped in `trigger_breakpoint` after 
running `process.ReverseContinue` ?

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,79 @@
+import lldb
+import unittest
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbreverse import ReverseTestBase
+from lldbsuite.test import lldbutil
+
+
+class TestReverseContinueBreakpoints(ReverseTestBase):
+@add_test_categories(["dwarf"])
+def test_reverse_continue(self):
+target, process, initial_threads = self.setup_recording()
+
+# Reverse-continue. We'll stop at the point where we started recording.
+status = process.ReverseContinue()
+self.assertSuccess(status)
+self.expect(
+"thread list",
+STOPPED_DUE_TO_HISTORY_BOUNDARY,
+substrs=["stopped", "stop reason = history boundary"],
+)
+
+# Continue forward normally until the target exits.
+status = process.Continue()
+self.assertSuccess(status)
+self.assertState(process.GetState(), lldb.eStateExited)
+self.assertEqual(process.GetExitStatus(), 0)
+
+@add_test_categories(["dwarf"])
+def test_reverse_continue_breakpoint(self):
+target, process, initial_threads = self.setup_recording()
+
+# Reverse-continue to the function "trigger_breakpoint".
+trigger_bkpt = target.BreakpointCreateByName("trigger_breakpoint", 
None)
+status = process.ReverseContinue()
+self.assertSuccess(status)
+threads_now = lldbutil.get_threads_stopped_at_breakpoint(process, 
trigger_bkpt)
+self.assertEqual(threads_now, initial_threads)
+
+@add_test_categories(["dwarf"])
+def test_reverse_continue_skip_breakpoint(self):
+target, process, initial_threads = self.setup_recording()
+
+# Reverse-continue, skipping a disabled breakpoint at 
"trigger_breakpoint".
+trigger_bkpt = target.BreakpointCreateByName("trigger_breakpoint", 
None)
+trigger_bkpt.SetCondition("0")

medismailben wrote:

```suggestion
trigger_bkpt.SetEnabled(False)
```

If you want to disable the breakpoint you should use this API: 
https://lldb.llvm.org/python_api/lldb.SBBreakpoint.html#lldb.SBBreakpoint.SetEnabled

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,415 @@
+import os
+import os.path
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbgdbproxy import *
+import lldbgdbserverutils
+import re
+
+
+class ThreadSnapshot:
+def __init__(self, thread_id, registers):
+self.thread_id = thread_id
+self.registers = registers
+
+
+class MemoryBlockSnapshot:
+def __init__(self, address, data):
+self.address = address
+self.data = data
+
+
+class StateSnapshot:
+def __init__(self, thread_snapshots, memory):
+self.thread_snapshots = thread_snapshots
+self.memory = memory
+self.thread_id = None
+
+
+class RegisterInfo:
+def __init__(self, lldb_index, bitsize, little_endian):
+self.lldb_index = lldb_index
+self.bitsize = bitsize
+self.little_endian = little_endian
+
+
+BELOW_STACK_POINTER = 16384
+ABOVE_STACK_POINTER = 4096
+
+BLOCK_SIZE = 1024
+
+SOFTWARE_BREAKPOINTS = 0
+HARDWARE_BREAKPOINTS = 1
+WRITE_WATCHPOINTS = 2
+
+
+class ReverseTestBase(GDBProxyTestBase):

medismailben wrote:

same thing here ๐Ÿ™‚ but we can do it in a follow-up

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,79 @@
+import lldb
+import unittest
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.decorators import *
+from lldbsuite.test.gdbclientutils import *
+from lldbsuite.test.lldbreverse import ReverseTestBase
+from lldbsuite.test import lldbutil
+
+
+class TestReverseContinueBreakpoints(ReverseTestBase):
+@add_test_categories(["dwarf"])
+def test_reverse_continue(self):
+target, process, initial_threads = self.setup_recording()
+
+# Reverse-continue. We'll stop at the point where we started recording.
+status = process.ReverseContinue()
+self.assertSuccess(status)
+self.expect(
+"thread list",
+STOPPED_DUE_TO_HISTORY_BOUNDARY,
+substrs=["stopped", "stop reason = history boundary"],
+)
+
+# Continue forward normally until the target exits.
+status = process.Continue()
+self.assertSuccess(status)
+self.assertState(process.GetState(), lldb.eStateExited)
+self.assertEqual(process.GetExitStatus(), 0)
+
+@add_test_categories(["dwarf"])
+def test_reverse_continue_breakpoint(self):
+target, process, initial_threads = self.setup_recording()
+
+# Reverse-continue to the function "trigger_breakpoint".
+trigger_bkpt = target.BreakpointCreateByName("trigger_breakpoint", 
None)
+status = process.ReverseContinue()
+self.assertSuccess(status)
+threads_now = lldbutil.get_threads_stopped_at_breakpoint(process, 
trigger_bkpt)
+self.assertEqual(threads_now, initial_threads)
+
+@add_test_categories(["dwarf"])
+def test_reverse_continue_skip_breakpoint(self):
+target, process, initial_threads = self.setup_recording()
+
+# Reverse-continue, skipping a disabled breakpoint at 
"trigger_breakpoint".
+trigger_bkpt = target.BreakpointCreateByName("trigger_breakpoint", 
None)
+trigger_bkpt.SetCondition("0")
+status = process.ReverseContinue()
+self.assertSuccess(status)
+self.expect(
+"thread list",
+STOPPED_DUE_TO_HISTORY_BOUNDARY,
+substrs=["stopped", "stop reason = history boundary"],
+)
+
+def setup_recording(self):
+"""
+Record execution of code between "start_recording" and 
"stop_recording" breakpoints.
+
+Returns with the target stopped at "stop_recording", with recording 
disabled,
+ready to reverse-execute.
+"""
+self.build()
+target = self.dbg.CreateTarget("")
+process = self.connect(target)
+
+# Record execution from the start of the function "start_recording"
+# to the start of the function "stop_recording".
+start_recording_bkpt = 
target.BreakpointCreateByName("start_recording", None)
+initial_threads = lldbutil.continue_to_breakpoint(process, 
start_recording_bkpt)
+self.assertEqual(len(initial_threads), 1)
+target.BreakpointDelete(start_recording_bkpt.GetID())
+self.start_recording()
+stop_recording_bkpt = target.BreakpointCreateByName("stop_recording", 
None)
+lldbutil.continue_to_breakpoint(process, stop_recording_bkpt)
+target.BreakpointDelete(stop_recording_bkpt.GetID())
+self.stop_recording()

medismailben wrote:

This is ok, but you could have [stopped the process at 
entry](https://github.com/llvm/llvm-project/blob/main/lldb/test/API/python_api/debugger/TestDebuggerAPI.py#L74)
 to start the recording and have something like a 
[stop-hook](https://lldb.llvm.org/use/python-reference.html#writing-target-stop-hooks-in-python)
 to stop recording instead of using public breakpoints. 

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Med Ismail Bennani via lldb-commits


@@ -0,0 +1,176 @@
+import logging
+import os
+import os.path
+import random
+
+import lldb
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test.gdbclientutils import *
+import lldbgdbserverutils
+from lldbsuite.support import seven
+
+
+class GDBProxyTestBase(TestBase):

medismailben wrote:

nit: This class is pretty cool, however it would be nice if we could separate 
the proxy GDB server from the test base class, since one could want to use the 
proxy GDB server for something other than a test.

You could the mock class in lldb/example/python and add it to the lldb python 
module. This could be a follow-up.

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Med Ismail Bennani via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Implement basic support for reverse-continue (PR #99736)

2024-07-19 Thread Med Ismail Bennani via lldb-commits

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