[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

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

eronnen wrote:

Aperrantly I missed that searching unnamed symbols is dependant on the symbol 
index at 
https://github.com/llvm/llvm-project/blob/main/lldb/source/Symbol/Symtab.cpp#L668,
 so changing it will require a deeper change

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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

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

eronnen wrote:

Aperrantly I missed that searching unnamed symbols is dependant on the symbol 
index at 
https://github.com/llvm/llvm-project/blob/main/lldb/source/Symbol/Symtab.cpp#L668,
 so changing it will require a deeper change

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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

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

eronnen wrote:

@felipepiovezan Thanks for noticing, I'll try to fix it soon

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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-05-01 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

I'm going to revert this for now, as I see your commit access is still pending 
(hopefully soon!)

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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-05-01 Thread Felipe de Azevedo Piovezan via lldb-commits

felipepiovezan wrote:

@eronnen I believe this is breaking the macOS bots, on the test 
TestFoundationDisassembly.py

```
17:54:59  FAIL: test_foundation_disasm 
(TestFoundationDisassembly.FoundationDisassembleTestCase)
17:54:59 Do 'disassemble -n func' on each and every 'Code' symbol entry 
from the Foundation.framework.
17:54:59  --
17:54:59  Traceback (most recent call last):
17:54:59File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/decorators.py",
 line 148, in wrapper
17:54:59  return func(*args, **kwargs)
17:54:59File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/test/API/lang/objc/foundation/TestFoundationDisassembly.py",
 line 58, in test_foundation_disasm
17:54:59  self.runCmd('image lookup -s "%s"' % func)
17:54:59File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 1005, in runCmd
17:54:59  self.assertTrue(self.res.Succeeded(), msg + output)
17:54:59  AssertionError: False is not true : Command 'image lookup -s 
"___lldb_unnamed_symbol_1816dd9c0"' did not return successfully
17:54:59  
Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang
17:54:59  ==
17:54:59  FAIL: test_foundation_disasm 
(TestFoundationDisassembly.FoundationDisassembleTestCase)
17:54:59 Do 'disassemble -n func' on each and every 'Code' symbol entry 
from the Foundation.framework.
17:54:59  --
17:54:59  Traceback (most recent call last):
17:54:59File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 2065, in tearDown
17:54:59  Base.tearDown(self)
17:54:59File 
"/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/lldbtest.py",
 line 1134, in tearDown
17:54:59  self.assertEqual(lldb.SBModule.GetNumberAllocatedModules(), 0)
17:54:59  AssertionError: 1 != 0
17:54:59  
Config=arm64-/Users/ec2-user/jenkins/workspace/llvm.org/as-lldb-cmake/lldb-build/bin/clang
17:54:59  --
17:54:59  Ran 2 tests in 80.091s
17:54:59  
17:54:59  FAILED (failures=2)
17:54:59  
```

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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-05-01 Thread Jason Molenda via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-04-30 Thread Ely Ronnen via lldb-commits

eronnen wrote:

Changed the commit message and the title

I don't mind if you merge now, I have no idea how long my merge access request 
is going to take :)

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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-04-30 Thread Ely Ronnen via lldb-commits

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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-04-30 Thread Ely Ronnen via lldb-commits

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

>From 032d43184321737b4dcbb9ba7313a22ae59494f6 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 27 Apr 2025 13:48:45 +0200
Subject: [PATCH] Change ___lldb_unnamed_symbol generated names to have the
 file address

---
 lldb/source/Symbol/Symbol.cpp | 4 +++-
 lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml  | 4 ++--
 .../test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test | 2 +-
 lldb/test/Shell/SymbolFile/Breakpad/symtab.test   | 2 +-
 4 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp
index 4828de4fdfa37..da74707c75e13 100644
--- a/lldb/source/Symbol/Symbol.cpp
+++ b/lldb/source/Symbol/Symbol.cpp
@@ -639,7 +639,9 @@ void Symbol::SynthesizeNameIfNeeded() const {
 // breakpoints on them.
 llvm::SmallString<256> name;
 llvm::raw_svector_ostream os(name);
-os << GetSyntheticSymbolPrefix() << GetID();
+os << GetSyntheticSymbolPrefix() << "_"
+   << llvm::format_hex_no_prefix(
+  m_addr_range.GetBaseAddress().GetFileAddress(), 0);
 m_mangled.SetDemangledName(ConstString(os.str()));
   }
 }
diff --git a/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml 
b/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml
index 0dcc9fb76bd4f..709c37e79d878 100644
--- a/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml
+++ b/lldb/test/Shell/ObjectFile/ELF/eh_frame-symbols.yaml
@@ -3,8 +3,8 @@
 
 # CHECK: Index   UserID DSX TypeFile Address/Value Load Address
   Size   Flags  Name
 # CHECK: [0]  1 SourceFile  0x 
   0x 0x0004 -
-# CHECK: [1]  2  SX Code0x00201180 
   0x0010 0x ___lldb_unnamed_symbol{{[0-9]*}}
-# CHECK: [2]  3  SX Code0x00201190 
   0x0006 0x ___lldb_unnamed_symbol{{[0-9]*}}
+# CHECK: [1]  2  SX Code0x00201180 
   0x0010 0x ___lldb_unnamed_symbol_{{[0-9a-f]*}}
+# CHECK: [2]  3  SX Code0x00201190 
   0x0006 0x ___lldb_unnamed_symbol_{{[0-9a-f]*}}
 
 --- !ELF
 FileHeader:
diff --git a/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test 
b/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test
index 98052ea20bedd..00e04eb39a98e 100644
--- a/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test
+++ b/lldb/test/Shell/SymbolFile/Breakpad/symtab-sorted-by-size.test
@@ -3,7 +3,7 @@
 # RUN:   -s %s | FileCheck %s
 
 # CHECK: num_symbols = 4 (sorted by size):
-# CHECK: [0]  0  SX Code0x0040 
   0x00b0 0x ___lldb_unnamed_symbol0
+# CHECK: [0]  0  SX Code0x0040 
   0x00b0 0x ___lldb_unnamed_symbol_40
 # CHECK: [1]  0   X Code0x004000d0 
   0x0022 0x _start
 # CHECK: [2]  0   X Code0x004000b0 
   0x0010 0x f1
 # CHECK: [3]  0   X Code0x004000c0 
   0x0010 0x f2
diff --git a/lldb/test/Shell/SymbolFile/Breakpad/symtab.test 
b/lldb/test/Shell/SymbolFile/Breakpad/symtab.test
index ef41bb3bea955..a32eb5808426f 100644
--- a/lldb/test/Shell/SymbolFile/Breakpad/symtab.test
+++ b/lldb/test/Shell/SymbolFile/Breakpad/symtab.test
@@ -5,7 +5,7 @@
 # CHECK-LABEL: (lldb) image dump symtab symtab.out
 # CHECK: Symtab, file = {{.*}}symtab.out, num_symbols = 4:
 # CHECK: Index   UserID DSX TypeFile Address/Value Load Address
   Size   Flags  Name
-# CHECK: [0]  0  SX Code0x0040 
   0x00b0 0x ___lldb_unnamed_symbol{{[0-9]*}}
+# CHECK: [0]  0  SX Code0x0040 
   0x00b0 0x ___lldb_unnamed_symbol_{{[0-9a-f]*}}
 # CHECK: [1]  0   X Code0x004000b0 
   0x0010 0x f1
 # CHECK: [2]  0   X Code0x004000c0 
   0x0010 0x f2
 # CHECK: [3]  0   X Code0x004000d0 
   0x0022 0x _start

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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-04-30 Thread Jason Molenda via lldb-commits

jasonmolenda wrote:

I can merge it, but I notice the PR description that will become the commit msg 
describes the setting style.  Or we can wait until you have merge access 
yourself to land - your choice.

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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-04-30 Thread Ely Ronnen via lldb-commits

eronnen wrote:

Currently not, waiting for https://github.com/llvm/llvm-project/issues/137382

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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-04-30 Thread Jason Molenda via lldb-commits

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

Looks good, thanks for finishing this.  Are you able to merge the PR?

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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-04-30 Thread Ely Ronnen via lldb-commits

eronnen wrote:

Cool, changed the patch to have it by default 

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


[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-04-30 Thread Ely Ronnen via lldb-commits

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

>From fd74de70151567d402eb7c0326a6234a21cb2db7 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 27 Apr 2025 13:48:45 +0200
Subject: [PATCH 1/6] [lldb] add settings to control how synthetic symbol names
 are generated

---
 lldb/include/lldb/Core/ModuleList.h   | 15 +++
 lldb/include/lldb/lldb-enumerations.h |  6 ++
 lldb/source/Core/CoreProperties.td|  5 +
 lldb/source/Core/ModuleList.cpp   |  8 
 lldb/source/Symbol/Symbol.cpp | 13 -
 5 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/Core/ModuleList.h 
b/lldb/include/lldb/Core/ModuleList.h
index 909ee08f9ba62..baed175be5313 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -67,6 +67,20 @@ static constexpr OptionEnumValueElement 
g_auto_download_enum_values[] = {
 },
 };
 
+static constexpr OptionEnumValueElement
+g_synthetic_symbols_name_style_values[] = {
+{
+lldb::eSyntheticSymbolsNameStyleIndex,
+"index",
+"Function index style",
+},
+{
+lldb::eSyntheticSymbolsNameStyleFileAddress,
+"file-address",
+"Function file address in module style",
+},
+};
+
 class ModuleListProperties : public Properties {
   mutable llvm::sys::RWMutex m_symlink_paths_mutex;
   PathMappingList m_symlink_paths;
@@ -91,6 +105,7 @@ class ModuleListProperties : public Properties {
   bool GetLoadSymbolOnDemand();
 
   lldb::SymbolDownload GetSymbolAutoDownload() const;
+  lldb::SyntheticSymbolsNameStyle GetSyntheticSymbolsNameStyle() const;
 
   PathMappingList GetSymlinkMappings() const;
 };
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 6d10cc8bcffcb..26e83cefbe571 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1391,6 +1391,12 @@ enum StopDisassemblyType {
   eStopDisassemblyTypeAlways
 };
 
+/// Format to use for unknown symbols.
+enum SyntheticSymbolsNameStyle {
+  eSyntheticSymbolsNameStyleIndex = 0,
+  eSyntheticSymbolsNameStyleFileAddress = 1,
+};
+
 } // namespace lldb
 
 #endif // LLDB_LLDB_ENUMERATIONS_H
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index a1a4e994c3b9c..7eaecb729c36d 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -46,6 +46,11 @@ let Definition = "modulelist" in {
 Global,
 DefaultFalse,
 Desc<"Enable on demand symbol loading in LLDB. LLDB will load debug info 
on demand for each module based on various conditions (e.g. matched breakpoint, 
resolved stack frame addresses and matched global variables/function symbols in 
symbol table) to improve performance. Please refer to docs/use/ondemand.rst for 
details.">;
+  def SyntheticSymbolsNameStyle: Property<"synthetic-symbols-name-style", 
"Enum">,
+Global,
+DefaultEnumValue<"eSyntheticSymbolsNameStyleIndex">,
+EnumValues<"OptionEnumValues(g_synthetic_symbols_name_style_values)">,
+Desc<"Determines the way synthetic symbol names are generated for unknown 
symbols">;
 }
 
 let Definition = "debugger" in {
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 6052cc151744d..c48c5bbfb5e92 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -115,6 +115,14 @@ SymbolDownload 
ModuleListProperties::GetSymbolAutoDownload() const {
g_modulelist_properties[idx].default_uint_value));
 }
 
+lldb::SyntheticSymbolsNameStyle
+ModuleListProperties::GetSyntheticSymbolsNameStyle() const {
+  const uint32_t idx = ePropertySyntheticSymbolsNameStyle;
+  return GetPropertyAtIndexAs(
+  idx, static_cast(
+   g_modulelist_properties[idx].default_uint_value));
+}
+
 FileSpec ModuleListProperties::GetClangModulesCachePath() const {
   const uint32_t idx = ePropertyClangModulesCachePath;
   return GetPropertyAtIndexAs(idx, {});
diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp
index 4828de4fdfa37..825ca5babe28e 100644
--- a/lldb/source/Symbol/Symbol.cpp
+++ b/lldb/source/Symbol/Symbol.cpp
@@ -639,7 +639,18 @@ void Symbol::SynthesizeNameIfNeeded() const {
 // breakpoints on them.
 llvm::SmallString<256> name;
 llvm::raw_svector_ostream os(name);
-os << GetSyntheticSymbolPrefix() << GetID();
+os << GetSyntheticSymbolPrefix();
+switch (ModuleList::GetGlobalModuleListProperties()
+.GetSyntheticSymbolsNameStyle()) {
+case eSyntheticSymbolsNameStyleIndex:
+  os << GetID();
+  break;
+case eSyntheticSymbolsNameStyleFileAddress:
+  os << "_"
+ << llvm::format_hex_no_prefix(
+m_addr_range.GetBaseAddress().GetFileAddress(), 0);
+  break;
+}
 m_mangled.SetDemangledName(ConstString(os.str()));

[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-04-30 Thread Ely Ronnen via lldb-commits

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

>From fd74de70151567d402eb7c0326a6234a21cb2db7 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 27 Apr 2025 13:48:45 +0200
Subject: [PATCH 1/5] [lldb] add settings to control how synthetic symbol names
 are generated

---
 lldb/include/lldb/Core/ModuleList.h   | 15 +++
 lldb/include/lldb/lldb-enumerations.h |  6 ++
 lldb/source/Core/CoreProperties.td|  5 +
 lldb/source/Core/ModuleList.cpp   |  8 
 lldb/source/Symbol/Symbol.cpp | 13 -
 5 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/Core/ModuleList.h 
b/lldb/include/lldb/Core/ModuleList.h
index 909ee08f9ba62..baed175be5313 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -67,6 +67,20 @@ static constexpr OptionEnumValueElement 
g_auto_download_enum_values[] = {
 },
 };
 
+static constexpr OptionEnumValueElement
+g_synthetic_symbols_name_style_values[] = {
+{
+lldb::eSyntheticSymbolsNameStyleIndex,
+"index",
+"Function index style",
+},
+{
+lldb::eSyntheticSymbolsNameStyleFileAddress,
+"file-address",
+"Function file address in module style",
+},
+};
+
 class ModuleListProperties : public Properties {
   mutable llvm::sys::RWMutex m_symlink_paths_mutex;
   PathMappingList m_symlink_paths;
@@ -91,6 +105,7 @@ class ModuleListProperties : public Properties {
   bool GetLoadSymbolOnDemand();
 
   lldb::SymbolDownload GetSymbolAutoDownload() const;
+  lldb::SyntheticSymbolsNameStyle GetSyntheticSymbolsNameStyle() const;
 
   PathMappingList GetSymlinkMappings() const;
 };
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 6d10cc8bcffcb..26e83cefbe571 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1391,6 +1391,12 @@ enum StopDisassemblyType {
   eStopDisassemblyTypeAlways
 };
 
+/// Format to use for unknown symbols.
+enum SyntheticSymbolsNameStyle {
+  eSyntheticSymbolsNameStyleIndex = 0,
+  eSyntheticSymbolsNameStyleFileAddress = 1,
+};
+
 } // namespace lldb
 
 #endif // LLDB_LLDB_ENUMERATIONS_H
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index a1a4e994c3b9c..7eaecb729c36d 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -46,6 +46,11 @@ let Definition = "modulelist" in {
 Global,
 DefaultFalse,
 Desc<"Enable on demand symbol loading in LLDB. LLDB will load debug info 
on demand for each module based on various conditions (e.g. matched breakpoint, 
resolved stack frame addresses and matched global variables/function symbols in 
symbol table) to improve performance. Please refer to docs/use/ondemand.rst for 
details.">;
+  def SyntheticSymbolsNameStyle: Property<"synthetic-symbols-name-style", 
"Enum">,
+Global,
+DefaultEnumValue<"eSyntheticSymbolsNameStyleIndex">,
+EnumValues<"OptionEnumValues(g_synthetic_symbols_name_style_values)">,
+Desc<"Determines the way synthetic symbol names are generated for unknown 
symbols">;
 }
 
 let Definition = "debugger" in {
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 6052cc151744d..c48c5bbfb5e92 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -115,6 +115,14 @@ SymbolDownload 
ModuleListProperties::GetSymbolAutoDownload() const {
g_modulelist_properties[idx].default_uint_value));
 }
 
+lldb::SyntheticSymbolsNameStyle
+ModuleListProperties::GetSyntheticSymbolsNameStyle() const {
+  const uint32_t idx = ePropertySyntheticSymbolsNameStyle;
+  return GetPropertyAtIndexAs(
+  idx, static_cast(
+   g_modulelist_properties[idx].default_uint_value));
+}
+
 FileSpec ModuleListProperties::GetClangModulesCachePath() const {
   const uint32_t idx = ePropertyClangModulesCachePath;
   return GetPropertyAtIndexAs(idx, {});
diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp
index 4828de4fdfa37..825ca5babe28e 100644
--- a/lldb/source/Symbol/Symbol.cpp
+++ b/lldb/source/Symbol/Symbol.cpp
@@ -639,7 +639,18 @@ void Symbol::SynthesizeNameIfNeeded() const {
 // breakpoints on them.
 llvm::SmallString<256> name;
 llvm::raw_svector_ostream os(name);
-os << GetSyntheticSymbolPrefix() << GetID();
+os << GetSyntheticSymbolPrefix();
+switch (ModuleList::GetGlobalModuleListProperties()
+.GetSyntheticSymbolsNameStyle()) {
+case eSyntheticSymbolsNameStyleIndex:
+  os << GetID();
+  break;
+case eSyntheticSymbolsNameStyleFileAddress:
+  os << "_"
+ << llvm::format_hex_no_prefix(
+m_addr_range.GetBaseAddress().GetFileAddress(), 0);
+  break;
+}
 m_mangled.SetDemangledName(ConstString(os.str()));

[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-04-30 Thread Ely Ronnen via lldb-commits

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

>From fd74de70151567d402eb7c0326a6234a21cb2db7 Mon Sep 17 00:00:00 2001
From: Ely Ronnen 
Date: Sun, 27 Apr 2025 13:48:45 +0200
Subject: [PATCH 1/4] [lldb] add settings to control how synthetic symbol names
 are generated

---
 lldb/include/lldb/Core/ModuleList.h   | 15 +++
 lldb/include/lldb/lldb-enumerations.h |  6 ++
 lldb/source/Core/CoreProperties.td|  5 +
 lldb/source/Core/ModuleList.cpp   |  8 
 lldb/source/Symbol/Symbol.cpp | 13 -
 5 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/lldb/include/lldb/Core/ModuleList.h 
b/lldb/include/lldb/Core/ModuleList.h
index 909ee08f9ba62..baed175be5313 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -67,6 +67,20 @@ static constexpr OptionEnumValueElement 
g_auto_download_enum_values[] = {
 },
 };
 
+static constexpr OptionEnumValueElement
+g_synthetic_symbols_name_style_values[] = {
+{
+lldb::eSyntheticSymbolsNameStyleIndex,
+"index",
+"Function index style",
+},
+{
+lldb::eSyntheticSymbolsNameStyleFileAddress,
+"file-address",
+"Function file address in module style",
+},
+};
+
 class ModuleListProperties : public Properties {
   mutable llvm::sys::RWMutex m_symlink_paths_mutex;
   PathMappingList m_symlink_paths;
@@ -91,6 +105,7 @@ class ModuleListProperties : public Properties {
   bool GetLoadSymbolOnDemand();
 
   lldb::SymbolDownload GetSymbolAutoDownload() const;
+  lldb::SyntheticSymbolsNameStyle GetSyntheticSymbolsNameStyle() const;
 
   PathMappingList GetSymlinkMappings() const;
 };
diff --git a/lldb/include/lldb/lldb-enumerations.h 
b/lldb/include/lldb/lldb-enumerations.h
index 6d10cc8bcffcb..26e83cefbe571 100644
--- a/lldb/include/lldb/lldb-enumerations.h
+++ b/lldb/include/lldb/lldb-enumerations.h
@@ -1391,6 +1391,12 @@ enum StopDisassemblyType {
   eStopDisassemblyTypeAlways
 };
 
+/// Format to use for unknown symbols.
+enum SyntheticSymbolsNameStyle {
+  eSyntheticSymbolsNameStyleIndex = 0,
+  eSyntheticSymbolsNameStyleFileAddress = 1,
+};
+
 } // namespace lldb
 
 #endif // LLDB_LLDB_ENUMERATIONS_H
diff --git a/lldb/source/Core/CoreProperties.td 
b/lldb/source/Core/CoreProperties.td
index a1a4e994c3b9c..7eaecb729c36d 100644
--- a/lldb/source/Core/CoreProperties.td
+++ b/lldb/source/Core/CoreProperties.td
@@ -46,6 +46,11 @@ let Definition = "modulelist" in {
 Global,
 DefaultFalse,
 Desc<"Enable on demand symbol loading in LLDB. LLDB will load debug info 
on demand for each module based on various conditions (e.g. matched breakpoint, 
resolved stack frame addresses and matched global variables/function symbols in 
symbol table) to improve performance. Please refer to docs/use/ondemand.rst for 
details.">;
+  def SyntheticSymbolsNameStyle: Property<"synthetic-symbols-name-style", 
"Enum">,
+Global,
+DefaultEnumValue<"eSyntheticSymbolsNameStyleIndex">,
+EnumValues<"OptionEnumValues(g_synthetic_symbols_name_style_values)">,
+Desc<"Determines the way synthetic symbol names are generated for unknown 
symbols">;
 }
 
 let Definition = "debugger" in {
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 6052cc151744d..c48c5bbfb5e92 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -115,6 +115,14 @@ SymbolDownload 
ModuleListProperties::GetSymbolAutoDownload() const {
g_modulelist_properties[idx].default_uint_value));
 }
 
+lldb::SyntheticSymbolsNameStyle
+ModuleListProperties::GetSyntheticSymbolsNameStyle() const {
+  const uint32_t idx = ePropertySyntheticSymbolsNameStyle;
+  return GetPropertyAtIndexAs(
+  idx, static_cast(
+   g_modulelist_properties[idx].default_uint_value));
+}
+
 FileSpec ModuleListProperties::GetClangModulesCachePath() const {
   const uint32_t idx = ePropertyClangModulesCachePath;
   return GetPropertyAtIndexAs(idx, {});
diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp
index 4828de4fdfa37..825ca5babe28e 100644
--- a/lldb/source/Symbol/Symbol.cpp
+++ b/lldb/source/Symbol/Symbol.cpp
@@ -639,7 +639,18 @@ void Symbol::SynthesizeNameIfNeeded() const {
 // breakpoints on them.
 llvm::SmallString<256> name;
 llvm::raw_svector_ostream os(name);
-os << GetSyntheticSymbolPrefix() << GetID();
+os << GetSyntheticSymbolPrefix();
+switch (ModuleList::GetGlobalModuleListProperties()
+.GetSyntheticSymbolsNameStyle()) {
+case eSyntheticSymbolsNameStyleIndex:
+  os << GetID();
+  break;
+case eSyntheticSymbolsNameStyleFileAddress:
+  os << "_"
+ << llvm::format_hex_no_prefix(
+m_addr_range.GetBaseAddress().GetFileAddress(), 0);
+  break;
+}
 m_mangled.SetDemangledName(ConstString(os.str()));

[Lldb-commits] [lldb] [lldb] Change synthetic symbol names to have file address (PR #137512)

2025-04-30 Thread Ely Ronnen via lldb-commits

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