[Lldb-commits] [lldb] 9984cfc - [lldb] Use llvm::byteswap in DumpRegisterValue

2023-04-18 Thread David Spickett via lldb-commits

Author: David Spickett
Date: 2023-04-18T08:18:59Z
New Revision: 9984cfc86ed6d5c1558d8dd82d82448e50d704ad

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

LOG: [lldb] Use llvm::byteswap in DumpRegisterValue

7978abd5aef1ba84d7a1cefbc3443245acff2c48 fixed a build issue
on MSVC with some code I previously added, by adding some
ifdefs.

Now I realise that I should have been using llvm::byteswap
in the first place, which does exactly that.

Added: 


Modified: 
lldb/source/Core/DumpRegisterValue.cpp

Removed: 




diff  --git a/lldb/source/Core/DumpRegisterValue.cpp 
b/lldb/source/Core/DumpRegisterValue.cpp
index 3e59fb13b8ca..463aa5926772 100644
--- a/lldb/source/Core/DumpRegisterValue.cpp
+++ b/lldb/source/Core/DumpRegisterValue.cpp
@@ -17,26 +17,10 @@
 #include "lldb/Utility/RegisterValue.h"
 #include "lldb/Utility/StreamString.h"
 #include "lldb/lldb-private-types.h"
-
-#if !defined(__has_builtin)
-#define __has_builtin(x) 0
-#endif
-
-#if __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)
-#define bswap_32(x) __builtin_bswap32(x)
-#define bswap_64(x) __builtin_bswap64(x)
-#elif defined(_MSC_VER)
-#define bswap_32(x) _byteswap_ulong(x)
-#define bswap_64(x) _byteswap_uint64(x)
-#else
-#include 
-#endif
+#include "llvm/ADT/bit.h"
 
 using namespace lldb;
 
-static uint32_t swap_value(uint32_t v) { return bswap_32(v); }
-static uint64_t swap_value(uint64_t v) { return bswap_64(v); }
-
 template 
 static void dump_type_value(lldb_private::CompilerType &fields_type, T value,
 lldb_private::ExecutionContextScope *exe_scope,
@@ -55,7 +39,7 @@ static void dump_type_value(lldb_private::CompilerType 
&fields_type, T value,
 
   // Then we need to match the target's endian on a byte level as well.
   if (lldb_private::endian::InlHostByteOrder() != target_order)
-value = swap_value(value);
+value = llvm::byteswap(value);
 
   lldb_private::DataExtractor data_extractor{
   &value, sizeof(T), lldb_private::endian::InlHostByteOrder(), 8};



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


[Lldb-commits] [PATCH] D148541: [lldb] fix build issue on MSVC because of missing byte-swap builtins

2023-04-18 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

Thanks for the fix!

Made me realise I should have looked harder for an llvm utility in the first 
place, and it turns out `llvm::byteswap` exists. So I've changed this to use 
that in 
https://github.com/llvm/llvm-project/commit/9984cfc86ed6d5c1558d8dd82d82448e50d704ad.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148541/new/

https://reviews.llvm.org/D148541

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


[Lldb-commits] [PATCH] D148541: [lldb] fix build issue on MSVC because of missing byte-swap builtins

2023-04-18 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

By the way, did this come up on a bot? Just wondering if I ignored an email, 
apologies if so.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148541/new/

https://reviews.llvm.org/D148541

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


[Lldb-commits] [PATCH] D140630: [lldb-vscode] Add data breakpoint support

2023-04-18 Thread Callum Macmillan via Phabricator via lldb-commits
cimacmillan added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140630/new/

https://reviews.llvm.org/D140630

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


[Lldb-commits] [PATCH] D148546: Reland: [Demangle] replace use of llvm::StringView w/ std::string_view

2023-04-18 Thread David Spickett via Phabricator via lldb-commits
DavidSpickett added a comment.

I am confused why startswith is in the itanium demangle namespace but I could 
be confusing a specialised function with the generic one that works for any 
string view. Otherwise looks fine at a glance.




Comment at: llvm/include/llvm/Demangle/ItaniumDemangle.h:1586
   // The instantiations are typedefs that drop the "basic_" prefix.
-  assert(SV.startsWith("basic_"));
+  assert(llvm::itanium_demangle::starts_with(SV, "basic_"));
   SV.remove_prefix(sizeof("basic_") - 1);

Is this right? Not sure `itanium_demangle` makes sense here.



Comment at: llvm/include/llvm/Demangle/ItaniumDemangle.h:2486
+  bool consumeIf(std::string_view S) {
+if (llvm::itanium_demangle::starts_with(std::string_view(First, Last - 
First), S)) {
   First += S.size();

Same here, namespace doesn't sound right.



Comment at: llvm/include/llvm/Demangle/MicrosoftDemangle.h:14
 
+#include 
+#include 

Needed because llvm's stringview included assert?



Comment at: llvm/include/llvm/Demangle/Utility.h:19
 
-#include "StringView.h"
+#include "DemangleConfig.h"
+

Why does this change?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148546/new/

https://reviews.llvm.org/D148546

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


[Lldb-commits] [PATCH] D148541: [lldb] fix build issue on MSVC because of missing byte-swap builtins

2023-04-18 Thread Ashay Rane via Phabricator via lldb-commits
ashay-github added a comment.

The `llvm::byteswap()` fix is much nicer.  Thanks for the change!

No, this build error didn't show up on a bot (at least as far as I can tell).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148541/new/

https://reviews.llvm.org/D148541

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


[Lldb-commits] [PATCH] D148546: Reland: [Demangle] replace use of llvm::StringView w/ std::string_view

2023-04-18 Thread Nick Desaulniers via Phabricator via lldb-commits
nickdesaulniers marked 2 inline comments as done.
nickdesaulniers added a comment.

In D148546#4276926 , @DavidSpickett 
wrote:

> I am confused why startswith is in the itanium demangle namespace but I could 
> be confusing a specialised function with the generic one that works for any 
> string view. Otherwise looks fine at a glance.

Hey David! Thanks for the review!  See the two parent commits for more context:

1. https://reviews.llvm.org/D148547
2. https://reviews.llvm.org/D148556

The second in particular could use review still ;) The first has landed.  This 
patch is part of a stack that could use review if you have the cycles for it.




Comment at: llvm/include/llvm/Demangle/MicrosoftDemangle.h:14
 
+#include 
+#include 

DavidSpickett wrote:
> Needed because llvm's stringview included assert?
yep, used below on L49.



Comment at: llvm/include/llvm/Demangle/Utility.h:19
 
-#include "StringView.h"
+#include "DemangleConfig.h"
+

DavidSpickett wrote:
> Why does this change?
The definition of DEMANGLE_NAMESPACE_BEGIN used below on L30 comes from this 
header, which was being included indirectly by StringView.h before this change.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148546/new/

https://reviews.llvm.org/D148546

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


[Lldb-commits] [PATCH] D148650: [lldb] Pass skip_exec=True in TestExec.test_skipping_exec

2023-04-18 Thread Dave Lee via Phabricator via lldb-commits
kastiglione created this revision.
kastiglione added a reviewer: jingham.
Herald added a project: All.
kastiglione requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Fix the test to match the function name, by passing `skip_exec=True`.

Otherwise, both `test_hitting_exec` and `test_skipping_exec` are identical.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148650

Files:
  lldb/test/API/functionalities/exec/TestExec.py


Index: lldb/test/API/functionalities/exec/TestExec.py
===
--- lldb/test/API/functionalities/exec/TestExec.py
+++ lldb/test/API/functionalities/exec/TestExec.py
@@ -19,8 +19,8 @@
 @expectedFailureNetBSD
 @skipIfAsan # rdar://problem/43756823
 @skipIfWindows
-def test_hitting_exec (self):
-self.do_test(False)
+def test_hitting_exec(self):
+self.do_test(skip_exec=False)
 
 @expectedFailureAll(archs=['i386'],
 oslist=no_match(["freebsd"]),
@@ -29,8 +29,8 @@
 @expectedFailureNetBSD
 @skipIfAsan # rdar://problem/43756823
 @skipIfWindows
-def test_skipping_exec (self):
-self.do_test(True)
+def test_skipping_exec(self):
+self.do_test(skip_exec=True)
 
 def do_test(self, skip_exec):
 self.build()


Index: lldb/test/API/functionalities/exec/TestExec.py
===
--- lldb/test/API/functionalities/exec/TestExec.py
+++ lldb/test/API/functionalities/exec/TestExec.py
@@ -19,8 +19,8 @@
 @expectedFailureNetBSD
 @skipIfAsan # rdar://problem/43756823
 @skipIfWindows
-def test_hitting_exec (self):
-self.do_test(False)
+def test_hitting_exec(self):
+self.do_test(skip_exec=False)
 
 @expectedFailureAll(archs=['i386'],
 oslist=no_match(["freebsd"]),
@@ -29,8 +29,8 @@
 @expectedFailureNetBSD
 @skipIfAsan # rdar://problem/43756823
 @skipIfWindows
-def test_skipping_exec (self):
-self.do_test(True)
+def test_skipping_exec(self):
+self.do_test(skip_exec=True)
 
 def do_test(self, skip_exec):
 self.build()
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D148650: [lldb] Pass skip_exec=True in TestExec.test_skipping_exec

2023-04-18 Thread Dave Lee via Phabricator via lldb-commits
kastiglione abandoned this revision.
kastiglione added a comment.
Herald added a subscriber: JDevlieghere.

🤦‍♂️


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148650/new/

https://reviews.llvm.org/D148650

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


[Lldb-commits] [PATCH] D148603: Remove hardcoding of addressing bits in ABIMacOSX_arm64

2023-04-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere accepted this revision.
JDevlieghere added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148603/new/

https://reviews.llvm.org/D148603

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


[Lldb-commits] [lldb] 53430bf - Remove hardcoded address bits in ABIMacOS_arm64

2023-04-18 Thread Jason Molenda via lldb-commits

Author: Jason Molenda
Date: 2023-04-18T13:01:49-07:00
New Revision: 53430bfd5c9d0074dd6de06dccea366e1d40bce4

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

LOG: Remove hardcoded address bits in ABIMacOS_arm64

A default number of addressing bits was hardcoded in
ABIMacOSX_arm64::FixAddress while we updated different
environments to fetch the value dynamically.  Remove
the old hardcoded value.

Differential Revision: https://reviews.llvm.org/D148603
rdar://108068497

Added: 


Modified: 
lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp

Removed: 
lldb/test/API/macosx/corefile-default-ptrauth/Makefile
lldb/test/API/macosx/corefile-default-ptrauth/TestCorefileDefaultPtrauth.py
lldb/test/API/macosx/corefile-default-ptrauth/create-corefile.c
lldb/test/API/macosx/corefile-default-ptrauth/main.c



diff  --git a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp 
b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
index 4079338e190cd..4d2505ece50de 100644
--- a/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
+++ b/lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
@@ -816,15 +816,12 @@ ValueObjectSP ABIMacOSX_arm64::GetReturnValueObjectImpl(
 
 lldb::addr_t ABIMacOSX_arm64::FixAddress(addr_t pc, addr_t mask) {
   lldb::addr_t pac_sign_extension = 0x0080ULL;
-  // Darwin systems originally couldn't determine the proper value
-  // dynamically, so the most common value was hardcoded.  This has
-  // largely been cleaned up, but there are still a handful of
-  // environments that assume the default value is set to this value
-  // and there's no dynamic value to correct it.
-  // When no mask is specified, set it to 39 bits of addressing (0..38).
+  // When no mask is specified, clear/set the top byte; preserve
+  // the low 55 bits (00..54) for addressing and bit 55 to indicate
+  // sign.
   if (mask == 0) {
-// ~((1ULL<<39)-1)
-mask = 0xff80;
+// ~((1ULL<<55)-1)
+mask = 0xff80;
   }
   return (pc & pac_sign_extension) ? pc | mask : pc & (~mask);
 }

diff  --git a/lldb/test/API/macosx/corefile-default-ptrauth/Makefile 
b/lldb/test/API/macosx/corefile-default-ptrauth/Makefile
deleted file mode 100644
index 2ec01bc411528..0
--- a/lldb/test/API/macosx/corefile-default-ptrauth/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-C_SOURCES := main.c
-
-# compile a.out and create-corefile
-# create-corefile will create a custom corefile using the symbols
-# addresses from the a.out binary.
-all: a.out create-corefile
-
-create-corefile:
-   $(MAKE) -f $(MAKEFILE_RULES) EXE=create-corefile \
-   C_SOURCES=create-corefile.c
-
-include Makefile.rules

diff  --git 
a/lldb/test/API/macosx/corefile-default-ptrauth/TestCorefileDefaultPtrauth.py 
b/lldb/test/API/macosx/corefile-default-ptrauth/TestCorefileDefaultPtrauth.py
deleted file mode 100644
index f9a62bc2b6778..0
--- 
a/lldb/test/API/macosx/corefile-default-ptrauth/TestCorefileDefaultPtrauth.py
+++ /dev/null
@@ -1,51 +0,0 @@
-"""Test that lldb has a default mask for addressable bits on Darwin arm64 
ABI"""
-
-
-import os
-import re
-import subprocess
-
-import lldb
-from lldbsuite.test.decorators import *
-from lldbsuite.test.lldbtest import *
-from lldbsuite.test import lldbutil
-
-
-class TestCorefileDefaultPtrauth(TestBase):
-
-@skipIf(debug_info=no_match(["dsym"]), bugnumber="This test is looking 
explicitly for a dSYM")
-@skipIf(archs=no_match(['arm64','arm64e']))
-@skipUnlessDarwin
-@skipIfRemote
-def test_lc_note(self):
-self.build()
-self.test_exe = self.getBuildArtifact("a.out")
-self.create_corefile = self.getBuildArtifact("create-corefile")
-self.corefile = self.getBuildArtifact("core")
-
-### Create our corefile
-retcode = call(self.create_corefile + " " +  self.test_exe + " " + 
self.corefile, shell=True)
-
-## This corefile has no metadata telling us how many bits are
-## used for ptrauth signed function pointers.  We will need lldb
-## to fall back on its old default value for Darwin arm64 ABIs
-## to correctly strip the bits.
-
-# Create a Target with our main executable binary to get it
-# seeded in lldb's global module cache.  Then delete the Target.
-# This way when the corefile searches for a binary with its UUID,
-# it'll be found by that search.
-initial_target = self.dbg.CreateTarget(self.test_exe)
-self.dbg.DeleteTarget(initial_target)
-
-self.target = self.dbg.CreateTarget('')
-err = lldb.SBError()
-self.process = self.target.LoadCore(self.corefile)
-self.assertEqual(self.process.IsValid(), True)
-
-# target variable should show

[Lldb-commits] [PATCH] D148603: Remove hardcoding of addressing bits in ABIMacOSX_arm64

2023-04-18 Thread Jason Molenda via Phabricator via lldb-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG53430bfd5c9d: Remove hardcoded address bits in 
ABIMacOS_arm64 (authored by jasonmolenda).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148603/new/

https://reviews.llvm.org/D148603

Files:
  lldb/source/Plugins/ABI/AArch64/ABIMacOSX_arm64.cpp
  lldb/test/API/macosx/corefile-default-ptrauth/Makefile
  lldb/test/API/macosx/corefile-default-ptrauth/TestCorefileDefaultPtrauth.py
  lldb/test/API/macosx/corefile-default-ptrauth/create-corefile.c
  lldb/test/API/macosx/corefile-default-ptrauth/main.c

Index: lldb/test/API/macosx/corefile-default-ptrauth/main.c
===
--- lldb/test/API/macosx/corefile-default-ptrauth/main.c
+++ /dev/null
@@ -1,6 +0,0 @@
-int main();
-int (*fmain)() = main;
-int main () {
-  return fmain();
-}
-
Index: lldb/test/API/macosx/corefile-default-ptrauth/create-corefile.c
===
--- lldb/test/API/macosx/corefile-default-ptrauth/create-corefile.c
+++ /dev/null
@@ -1,189 +0,0 @@
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-// Given an executable binary with 
-//   "fmain" (a function pointer to main)
-//   "main"
-// symbols, create a fake arm64e corefile that
-// contains a memory segment for the fmain 
-// function pointer, with the value of the 
-// address of main() with ptrauth bits masked on.
-//
-// The corefile does not include the "addrable bits"
-// LC_NOTE, so lldb will need to fall back on its 
-// default value from the Darwin arm64 ABI.
-
-int main(int argc, char **argv)
-{
-  if (argc != 3) {
-fprintf (stderr, "usage: %s executable-binary output-file\n", argv[0]);
-exit(1);
-  }
-  FILE *exe = fopen(argv[1], "r");
-  if (!exe) {
-fprintf (stderr, "Unable to open executable %s for reading\n", argv[1]);
-exit(1);
-  }
-  FILE *out = fopen(argv[2], "w");
-  if (!out) {
-fprintf (stderr, "Unable to open %s for writing\n", argv[2]);
-exit(1);
-  }
-
-  char buf[PATH_MAX + 6];
-  sprintf (buf, "nm '%s'", argv[1]);
-  FILE *nm = popen(buf, "r");
-  if (!nm) {
-fprintf (stderr, "Unable to run nm on '%s'", argv[1]);
-exit (1);
-  }
-  uint64_t main_addr = 0;
-  uint64_t fmain_addr = 0;
-  while (fgets (buf, sizeof(buf), nm)) {
-if (strstr (buf, "_fmain")) {
-  fmain_addr = strtoul (buf, NULL, 16);
-}
-if (strstr (buf, "_main")) {
-  main_addr = strtoul (buf, NULL, 16);
-}
-  }
-  pclose (nm);
-
-  sprintf (buf, "dwarfdump -u '%s'", argv[1]);
-  FILE *dwarfdump = popen(buf, "r");
-  if (!dwarfdump) {
-fprintf (stderr, "Unable to run dwarfdump -u on '%s'\n", argv[1]);
-exit (1);
-  }
-  uuid_t uuid;
-  uuid_clear (uuid);
-  while (fgets (buf, sizeof(buf), dwarfdump)) {
-if (strncmp (buf, "UUID: ", 6) == 0) {
-  buf[6 + 36] = '\0';
-  if (uuid_parse (buf + 6, uuid) != 0) {
-fprintf (stderr, "Unable to parse UUID in '%s'\n", buf);
-exit (1);
-  }
-}
-  }
-  if (uuid_is_null(uuid)) {
-fprintf (stderr, "Got a null uuid for the binary\n");
-exit (1);
-  }
-
-  if (main_addr == 0 || fmain_addr == 0) {
-fprintf(stderr, "Unable to find address of main or fmain in %s.\n",
-argv[1]);
-exit (1);
-  }
-
-  // Write out a corefile with contents in this order:
-  //1. mach header
-  //2. LC_THREAD load command
-  //3. LC_SEGMENT_64 load command
-  //4. LC_NOTE load command
-  //5. memory segment contents
-  //6. "load binary" note contents
-
-  // struct thread_command {
-  //   uint32_tcmd;
-  //   uint32_tcmdsize;
-  //   uint32_t flavor  
-  //   uint32_t count   
-  //   struct XXX_thread_state state
-  int size_of_thread_cmd = 4 + 4 + 4 + 4 + sizeof (arm_thread_state64_t);
-
-  struct mach_header_64 mh;
-  mh.magic = 0xfeedfacf;
-  mh.cputype = CPU_TYPE_ARM64;
-  mh.cpusubtype = CPU_SUBTYPE_ARM64E;
-  mh.filetype = MH_CORE;
-  mh.ncmds = 3; // LC_THREAD, LC_SEGMENT_64, LC_NOTE
-  mh.sizeofcmds = size_of_thread_cmd + sizeof(struct segment_command_64) + sizeof(struct note_command);
-  mh.flags = 0;
-  mh.reserved = 0;
-
-  fwrite(&mh, sizeof (mh), 1, out);
-
-  struct note_command lcnote;
-  struct segment_command_64 seg;
-  seg.cmd = LC_SEGMENT_64;
-  seg.cmdsize = sizeof(seg);
-  memset (&seg.segname, 0, 16);
-  seg.vmaddr = fmain_addr;
-  seg.vmsize = 8;
-  // Offset to segment contents
-  seg.fileoff = sizeof (mh) + size_of_thread_cmd + sizeof(seg) + sizeof(lcnote);
-  seg.filesize = 8;
-  seg.maxprot = 3;
-  seg.initprot = 3;
-  seg.nsects = 0;
-  seg.flags = 0;
-
-  fwrite (&seg, sizeof (seg), 1, out);
-
-  uint32_t cmd = LC_THREAD;
-  fwrite (&cmd, sizeof (cmd), 1, out);
-  uint32_t cmdsize = size_of_thread_cmd;
-  fwrite (&cmdsize, sizeof (cmdsize), 1, out);
-  uint32_t flavor = AR

[Lldb-commits] [PATCH] D148662: [lldb] Make the libcxx unique_ptr prettyprinter support custom deleters.

2023-04-18 Thread Jorge Gorbe Moya via Phabricator via lldb-commits
jgorbe created this revision.
jgorbe added reviewers: shafik, kastiglione.
jgorbe added a project: LLDB.
Herald added a subscriber: JDevlieghere.
Herald added a project: All.
jgorbe requested review of this revision.

The unique_ptr prettyprinter calls `GetValueOfLibCXXCompressedPair`,
which looks for a `__value_` child. However, when the second value in
the compressed pair is not an empty class, there are two `__value_`
children because `__compressed_pair` derives twice from
`__compressed_pair_elem`, one for each member of the pair. And then the
lookup fails because it's ambiguous.

This patch makes the following changes:

- Rename `GetValueOfLibCXXCompressedPair` to 
`GetFirstValueOfLibCXXCompressedPair`, and add a similar function to get the 
second value. Put both functions in Plugin/Language/CPlusPlus/LibCxx.cpp 
because it seems inappropriate to have libcxx-specific helpers separate from 
all the libcxx-dependent code.

- Read the second value of the `__ptr_` pair and display a "deleter" child in 
the unique_ptr synthetic child provider, when available.

- Add a test case for the non-empty deleter case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148662

Files:
  lldb/include/lldb/DataFormatters/FormattersHelpers.h
  lldb/source/DataFormatters/FormattersHelpers.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
  lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
  
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp

Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp
@@ -6,6 +6,15 @@
   std::string name = "steph";
 };
 
+// libc++ stores unique_ptr data in a compressed pair, which has a specialized
+// representation when the type of the second element is an empty class. So
+// we need a deleter class with a dummy data member to trigger the other path.
+struct NonEmptyIntDeleter {
+  void operator()(int* ptr) { delete ptr; }
+
+  int dummy_ = ;
+};
+
 int main() {
   std::unique_ptr up_empty;
   std::unique_ptr up_int = std::make_unique(10);
@@ -13,6 +22,8 @@
   std::unique_ptr &up_int_ref = up_int;
   std::unique_ptr &&up_int_ref_ref = std::make_unique(10);
   std::unique_ptr up_user = std::make_unique();
+  auto up_non_empty_deleter =
+  std::unique_ptr(new int(1234));
 
   return 0; // break here
 }
Index: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
===
--- lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
+++ lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py
@@ -97,5 +97,18 @@
 )
 self.assertEqual(str(valobj), '(User) *__value_ = (id = 30, name = "steph")')
 
+valobj = self.expect_var_path(
+"up_non_empty_deleter",
+type="std::unique_ptr",
+summary="1234",
+children=[
+ValueCheck(name="__value_"),
+ValueCheck(name="deleter", children=[
+ValueCheck(name="dummy_", value="")
+]),
+],
+)
+self.assertNotEqual(valobj.child[0].unsigned, 0)
+
 self.expect_var_path("up_user->id", type="int", value="30")
 self.expect_var_path("up_user->name", type="std::string", summary='"steph"')
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
===
--- lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
@@ -300,7 +300,7 @@
   m_backend.GetChildMemberWithName(ConstString("__before_begin_"), true));
   if (!impl_sp)
 return false;
-  impl_sp = GetValueOfLibCXXCompressedPair(*impl_sp);
+  impl_sp = GetFirstValueOfLibCXXCompressedPair(*impl_sp);
   if (!impl_sp)
 return false;
   m_head = impl_sp->GetChildMemberWithName(ConstString("__next_"), true).get();
@@ -321,7 +321,7 @@
   ValueObjectSP size_alloc(
   m_backend.GetChildMemberWithName(ConstString("__size_alloc_"), true));
   if (size_alloc) {
-ValueObjectSP value = GetValueOfLibCXXCompressedPair(*size_alloc);
+ValueObjectSP value = GetFirstValueOfLibCXXCompressedPair(*size_alloc);
 if (value) {
   m_count = value->GetValueAsUnsigned(UINT32_MAX);
 }
Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.h
==

[Lldb-commits] [PATCH] D148676: [lldb][NFCI] Stop creating additional temporary string in Log::VAPrintf

2023-04-18 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, mib, jingham, clayborg.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

Instead of creating a std::string from the `SmallString`,
let's just use a std::string from the start. I initially tried to make
`SmallString` work but getting it right proved complicated because
`LogHandler::Emit` will take its `StringRef` parameter and touch the raw
`const char *` from it directly, which isn't guaranteed to be
null-terminated with a `SmallString`.

I changed `WriteMessage` to take a `StringRef` instead of a
`const std::string &` for flexibility.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148676

Files:
  lldb/include/lldb/Utility/Log.h
  lldb/source/Utility/Log.cpp


Index: lldb/source/Utility/Log.cpp
===
--- lldb/source/Utility/Log.cpp
+++ lldb/source/Utility/Log.cpp
@@ -146,8 +146,8 @@
 // callback registered, then we call the logging callback. If we have a valid
 // file handle, we also log to the file.
 void Log::VAPrintf(const char *format, va_list args) {
-  llvm::SmallString<64> FinalMessage;
-  llvm::raw_svector_ostream Stream(FinalMessage);
+  std::string FinalMessage;
+  llvm::raw_string_ostream Stream(FinalMessage);
   WriteHeader(Stream, "", "");
 
   llvm::SmallString<64> Content;
@@ -155,7 +155,7 @@
 
   Stream << Content << "\n";
 
-  WriteMessage(std::string(FinalMessage.str()));
+  WriteMessage(FinalMessage);
 }
 
 // Printing of errors that are not fatal.
@@ -344,7 +344,7 @@
   }
 }
 
-void Log::WriteMessage(const std::string &message) {
+void Log::WriteMessage(llvm::StringRef message) {
   // Make a copy of our stream shared pointer in case someone disables our log
   // while we are logging and releases the stream
   auto handler_sp = GetHandler();
Index: lldb/include/lldb/Utility/Log.h
===
--- lldb/include/lldb/Utility/Log.h
+++ lldb/include/lldb/Utility/Log.h
@@ -265,7 +265,7 @@
 
   void WriteHeader(llvm::raw_ostream &OS, llvm::StringRef file,
llvm::StringRef function);
-  void WriteMessage(const std::string &message);
+  void WriteMessage(llvm::StringRef message);
 
   void Format(llvm::StringRef file, llvm::StringRef function,
   const llvm::formatv_object_base &payload);


Index: lldb/source/Utility/Log.cpp
===
--- lldb/source/Utility/Log.cpp
+++ lldb/source/Utility/Log.cpp
@@ -146,8 +146,8 @@
 // callback registered, then we call the logging callback. If we have a valid
 // file handle, we also log to the file.
 void Log::VAPrintf(const char *format, va_list args) {
-  llvm::SmallString<64> FinalMessage;
-  llvm::raw_svector_ostream Stream(FinalMessage);
+  std::string FinalMessage;
+  llvm::raw_string_ostream Stream(FinalMessage);
   WriteHeader(Stream, "", "");
 
   llvm::SmallString<64> Content;
@@ -155,7 +155,7 @@
 
   Stream << Content << "\n";
 
-  WriteMessage(std::string(FinalMessage.str()));
+  WriteMessage(FinalMessage);
 }
 
 // Printing of errors that are not fatal.
@@ -344,7 +344,7 @@
   }
 }
 
-void Log::WriteMessage(const std::string &message) {
+void Log::WriteMessage(llvm::StringRef message) {
   // Make a copy of our stream shared pointer in case someone disables our log
   // while we are logging and releases the stream
   auto handler_sp = GetHandler();
Index: lldb/include/lldb/Utility/Log.h
===
--- lldb/include/lldb/Utility/Log.h
+++ lldb/include/lldb/Utility/Log.h
@@ -265,7 +265,7 @@
 
   void WriteHeader(llvm::raw_ostream &OS, llvm::StringRef file,
llvm::StringRef function);
-  void WriteMessage(const std::string &message);
+  void WriteMessage(llvm::StringRef message);
 
   void Format(llvm::StringRef file, llvm::StringRef function,
   const llvm::formatv_object_base &payload);
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D148400: [lldb] Fix bug to update process public run lock with process state

2023-04-18 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 514792.
mib marked 3 inline comments as done.
mib added a comment.

Address @bulbazord comments


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148400/new/

https://reviews.llvm.org/D148400

Files:
  lldb/include/lldb/Target/Process.h
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp

Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3157,8 +3157,8 @@
   // its own hijacking listener or if the process is created by the target
   // manually, without the platform).
   if (!launch_info.GetHijackListener())
-launch_info.SetHijackListener(
-Listener::MakeListener("lldb.Target.Launch.hijack"));
+launch_info.SetHijackListener(Listener::MakeListener(
+Process::GetLaunchSynchronousHijackListenerName().data()));
 
   // If we're not already connected to the process, and if we have a platform
   // that can launch a process for debugging, go ahead and do that here.
@@ -3334,8 +3334,8 @@
   ListenerSP hijack_listener_sp;
   const bool async = attach_info.GetAsync();
   if (!async) {
-hijack_listener_sp =
-Listener::MakeListener("lldb.Target.Attach.attach.hijack");
+hijack_listener_sp = Listener::MakeListener(
+Process::GetAttachSynchronousHijackListenerName().data());
 attach_info.SetHijackListener(hijack_listener_sp);
   }
 
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -401,6 +401,18 @@
   return class_name;
 }
 
+llvm::StringRef Process::GetAttachSynchronousHijackListenerName() {
+  return "lldb.internal.Process.AttachSynchronous.hijack";
+}
+
+llvm::StringRef Process::GetLaunchSynchronousHijackListenerName() {
+  return "lldb.internal.Process.LaunchSynchronous.hijack";
+}
+
+llvm::StringRef Process::GetResumeSynchronousHijackListenerName() {
+  return "lldb.internal.Process.ResumeSynchronous.hijack";
+}
+
 Process::Process(lldb::TargetSP target_sp, ListenerSP listener_sp)
 : Process(target_sp, listener_sp, UnixSignals::CreateForHost()) {
   // This constructor just delegates to the full Process constructor,
@@ -1355,8 +1367,6 @@
   return error;
 }
 
-static const char *g_resume_sync_name = "lldb.Process.ResumeSynchronous.hijack";
-
 Status Process::ResumeSynchronous(Stream *stream) {
   Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
   LLDB_LOGF(log, "Process::ResumeSynchronous -- locking run lock");
@@ -1367,7 +1377,7 @@
   }
 
   ListenerSP listener_sp(
-  Listener::MakeListener(g_resume_sync_name));
+  Listener::MakeListener(GetResumeSynchronousHijackListenerName().data()));
   HijackProcessEvents(listener_sp);
 
   Status error = PrivateResume();
@@ -1393,9 +1403,8 @@
 
 bool Process::StateChangedIsExternallyHijacked() {
   if (IsHijackedForEvent(eBroadcastBitStateChanged)) {
-const char *hijacking_name = GetHijackingListenerName();
-if (hijacking_name &&
-strcmp(hijacking_name, g_resume_sync_name))
+llvm::StringRef hijacking_name = GetHijackingListenerName();
+if (hijacking_name.starts_with("lldb.internal"))
   return true;
   }
   return false;
@@ -1403,9 +1412,8 @@
 
 bool Process::StateChangedIsHijackedForSynchronousResume() {
   if (IsHijackedForEvent(eBroadcastBitStateChanged)) {
-const char *hijacking_name = GetHijackingListenerName();
-if (hijacking_name &&
-strcmp(hijacking_name, g_resume_sync_name) == 0)
+llvm::StringRef hijacking_name = GetHijackingListenerName();
+if (hijacking_name == GetResumeSynchronousHijackListenerName())
   return true;
   }
   return false;
Index: lldb/include/lldb/Target/Process.h
===
--- lldb/include/lldb/Target/Process.h
+++ lldb/include/lldb/Target/Process.h
@@ -386,6 +386,10 @@
 
   static ConstString &GetStaticBroadcasterClass();
 
+  static llvm::StringRef GetAttachSynchronousHijackListenerName();
+  static llvm::StringRef GetLaunchSynchronousHijackListenerName();
+  static llvm::StringRef GetResumeSynchronousHijackListenerName();
+
   ConstString &GetBroadcasterClass() const override {
 return GetStaticBroadcasterClass();
   }
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [PATCH] D148676: [lldb][NFCI] Stop creating additional temporary string in Log::VAPrintf

2023-04-18 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib accepted this revision.
mib added a comment.
This revision is now accepted and ready to land.

Makes sense. LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148676/new/

https://reviews.llvm.org/D148676

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


[Lldb-commits] [PATCH] D148400: [lldb] Fix bug to update process public run lock with process state

2023-04-18 Thread Alex Langford via Phabricator via lldb-commits
bulbazord accepted this revision.
bulbazord added a comment.
This revision is now accepted and ready to land.

LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148400/new/

https://reviews.llvm.org/D148400

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


[Lldb-commits] [PATCH] D148679: [lldb] Change setting descriptions to use StringRef instead of ConstString

2023-04-18 Thread Alex Langford via Phabricator via lldb-commits
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, mib, jingham.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

These probably do not need to be in the ConstString StringPool as they
don't really need any of the advantages that ConstStrings offer.
Lifetime for these things is always static and we never need to perform
comparisons for setting descriptions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D148679

Files:
  lldb/include/lldb/Core/PluginManager.h
  lldb/include/lldb/Interpreter/OptionValueProperties.h
  lldb/source/Core/Debugger.cpp
  lldb/source/Core/PluginManager.cpp
  lldb/source/Interpreter/OptionValueProperties.cpp
  lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  lldb/source/Plugins/JITLoader/GDB/JITLoaderGDB.cpp
  lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
  lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/Trace/intel-pt/TraceIntelPT.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp
  lldb/unittests/Interpreter/TestOptionValue.cpp

Index: lldb/unittests/Interpreter/TestOptionValue.cpp
===
--- lldb/unittests/Interpreter/TestOptionValue.cpp
+++ lldb/unittests/Interpreter/TestOptionValue.cpp
@@ -84,11 +84,10 @@
 const bool is_global = false;
 
 auto dict_sp = std::make_shared(1 << eTypeUInt64);
-props_sp->AppendProperty(ConstString("dict"), ConstString(), is_global,
- dict_sp);
+props_sp->AppendProperty(ConstString("dict"), "", is_global, dict_sp);
 
 auto file_list_sp = std::make_shared();
-props_sp->AppendProperty(ConstString("file-list"), ConstString(), is_global,
+props_sp->AppendProperty(ConstString("file-list"), "", is_global,
  file_list_sp);
 return props_sp;
   }
Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -4088,8 +4088,8 @@
 std::make_unique();
 m_collection_sp->AppendProperty(
 ConstString(Properties::GetExperimentalSettingsName()),
-ConstString("Experimental settings - setting these won't produce "
-"errors if the setting is not present."),
+"Experimental settings - setting these won't produce "
+"errors if the setting is not present.",
 true, m_experimental_properties_up->GetValueProperties());
   } else {
 m_collection_sp =
@@ -4099,12 +4099,12 @@
 std::make_unique();
 m_collection_sp->AppendProperty(
 ConstString(Properties::GetExperimentalSettingsName()),
-ConstString("Experimental settings - setting these won't produce "
-"errors if the setting is not present."),
+"Experimental settings - setting these won't produce "
+"errors if the setting is not present.",
 true, m_experimental_properties_up->GetValueProperties());
 m_collection_sp->AppendProperty(
-ConstString("process"), ConstString("Settings specific to processes."),
-true, Process::GetGlobalProperties().GetValueProperties());
+ConstString("process"), "Settings specific to processes.", true,
+Process::GetGlobalProperties().GetValueProperties());
 m_collection_sp->SetValueChangedCallback(
 ePropertySaveObjectsDir, [this] { CheckJITObjectsDir(); });
   }
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -167,8 +167,8 @@
 std::make_shared(ConstString("process"));
 m_collection_sp->Initialize(g_process_properties);
 m_collection_sp->AppendProperty(
-ConstString("thread"), ConstString("Settings specific to threads."),
-true, Thread::GetGlobalProperties().GetValueProperties());
+ConstString("thread"), "Settings specific to threads.", true,
+Thread::GetGlobalProperties().GetValueProperties());
   } else {
 m_collection_sp =
 OptionValueProperties::CreateLocalCopy(Process::GetGlobalProperties());
@@ -181,8 +181,8 @@
   std::make_unique();
   m_collection_sp->AppendProperty(
   ConstString(Properties::GetExperimentalSettingsName()),
-  ConstString("Experimental settings - setting these won't produce "
-  "errors if the setting is not present

[Lldb-commits] [PATCH] D148400: [lldb] Fix bug to update process public run lock with process state

2023-04-18 Thread Jonas Devlieghere via Phabricator via lldb-commits
JDevlieghere added inline comments.



Comment at: lldb/source/Target/Process.cpp:404-414
+llvm::StringRef Process::GetAttachSynchronousHijackListenerName() {
+  return "lldb.internal.Process.AttachSynchronous.hijack";
+}
+
+llvm::StringRef Process::GetLaunchSynchronousHijackListenerName() {
+  return "lldb.internal.Process.LaunchSynchronous.hijack";
+}

Do these actually need to be methods? Can't these be public static `StringRef`s 
instead?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148400/new/

https://reviews.llvm.org/D148400

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


[Lldb-commits] [PATCH] D148400: [lldb] Fix bug to update process public run lock with process state

2023-04-18 Thread Med Ismail Bennani via Phabricator via lldb-commits
mib updated this revision to Diff 514832.
mib added a comment.

Turning hijack listener name getters into public `static constexpr 
llvmStringRef` as @JDevlieghere suggested.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148400/new/

https://reviews.llvm.org/D148400

Files:
  lldb/include/lldb/Target/Process.h
  lldb/source/Target/Process.cpp
  lldb/source/Target/Target.cpp


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3157,8 +3157,8 @@
   // its own hijacking listener or if the process is created by the target
   // manually, without the platform).
   if (!launch_info.GetHijackListener())
-launch_info.SetHijackListener(
-Listener::MakeListener("lldb.Target.Launch.hijack"));
+launch_info.SetHijackListener(Listener::MakeListener(
+Process::LaunchSynchronousHijackListenerName.data()));
 
   // If we're not already connected to the process, and if we have a platform
   // that can launch a process for debugging, go ahead and do that here.
@@ -3334,8 +3334,8 @@
   ListenerSP hijack_listener_sp;
   const bool async = attach_info.GetAsync();
   if (!async) {
-hijack_listener_sp =
-Listener::MakeListener("lldb.Target.Attach.attach.hijack");
+hijack_listener_sp = Listener::MakeListener(
+Process::AttachSynchronousHijackListenerName.data());
 attach_info.SetHijackListener(hijack_listener_sp);
   }
 
Index: lldb/source/Target/Process.cpp
===
--- lldb/source/Target/Process.cpp
+++ lldb/source/Target/Process.cpp
@@ -1355,8 +1355,6 @@
   return error;
 }
 
-static const char *g_resume_sync_name = 
"lldb.Process.ResumeSynchronous.hijack";
-
 Status Process::ResumeSynchronous(Stream *stream) {
   Log *log(GetLog(LLDBLog::State | LLDBLog::Process));
   LLDB_LOGF(log, "Process::ResumeSynchronous -- locking run lock");
@@ -1367,7 +1365,7 @@
   }
 
   ListenerSP listener_sp(
-  Listener::MakeListener(g_resume_sync_name));
+  Listener::MakeListener(ResumeSynchronousHijackListenerName.data()));
   HijackProcessEvents(listener_sp);
 
   Status error = PrivateResume();
@@ -1393,9 +1391,8 @@
 
 bool Process::StateChangedIsExternallyHijacked() {
   if (IsHijackedForEvent(eBroadcastBitStateChanged)) {
-const char *hijacking_name = GetHijackingListenerName();
-if (hijacking_name &&
-strcmp(hijacking_name, g_resume_sync_name))
+llvm::StringRef hijacking_name = GetHijackingListenerName();
+if (hijacking_name.starts_with("lldb.internal"))
   return true;
   }
   return false;
@@ -1403,9 +1400,8 @@
 
 bool Process::StateChangedIsHijackedForSynchronousResume() {
   if (IsHijackedForEvent(eBroadcastBitStateChanged)) {
-const char *hijacking_name = GetHijackingListenerName();
-if (hijacking_name &&
-strcmp(hijacking_name, g_resume_sync_name) == 0)
+llvm::StringRef hijacking_name = GetHijackingListenerName();
+if (hijacking_name == ResumeSynchronousHijackListenerName)
   return true;
   }
   return false;
Index: lldb/include/lldb/Target/Process.h
===
--- lldb/include/lldb/Target/Process.h
+++ lldb/include/lldb/Target/Process.h
@@ -386,6 +386,13 @@
 
   static ConstString &GetStaticBroadcasterClass();
 
+  static constexpr llvm::StringRef AttachSynchronousHijackListenerName =
+  "lldb.internal.Process.AttachSynchronous.hijack";
+  static constexpr llvm::StringRef LaunchSynchronousHijackListenerName =
+  "lldb.internal.Process.LaunchSynchronous.hijack";
+  static constexpr llvm::StringRef ResumeSynchronousHijackListenerName =
+  "lldb.internal.Process.ResumeSynchronous.hijack";
+
   ConstString &GetBroadcasterClass() const override {
 return GetStaticBroadcasterClass();
   }


Index: lldb/source/Target/Target.cpp
===
--- lldb/source/Target/Target.cpp
+++ lldb/source/Target/Target.cpp
@@ -3157,8 +3157,8 @@
   // its own hijacking listener or if the process is created by the target
   // manually, without the platform).
   if (!launch_info.GetHijackListener())
-launch_info.SetHijackListener(
-Listener::MakeListener("lldb.Target.Launch.hijack"));
+launch_info.SetHijackListener(Listener::MakeListener(
+Process::LaunchSynchronousHijackListenerName.data()));
 
   // If we're not already connected to the process, and if we have a platform
   // that can launch a process for debugging, go ahead and do that here.
@@ -3334,8 +3334,8 @@
   ListenerSP hijack_listener_sp;
   const bool async = attach_info.GetAsync();
   if (!async) {
-hijack_listener_sp =
-Listener::MakeListener("lldb.Target.Attach.attach.hijack");
+hijack_listener_sp = Listener::MakeListener(
+Process::AttachSynchronousHijackListenerName.data());
 attach_info.SetHijackListener(h