Skip to content
Permalink
Browse files
Use None for architecture when dump-class-layout does not have -a o…
…ption

https://bugs.webkit.org/show_bug.cgi?id=240395

Reviewed by Saam Barati and Simon Fraser.

We can pass None to architecture, then SBDebugger::CreateTargetWithFileAndArch
will call CreateTarget with nullptr architecture string. Then, TargetList constructs
ArchSpec based on currently selected platform automatically and it covers most of cases.
I tried it, and it worked with watchOS, macOS, iOS so far.
So, we should just pass None to CreateTargetWithFileAndArch by default.

* Tools/lldb/lldb_dump_class_layout.py:
(LLDBDebuggerInstance.__init__):
(LLDBDebuggerInstance.__del__):
(LLDBDebuggerInstance._get_first_file_architecture): Deleted.

Canonical link: https://commits.webkit.org/250539@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294171 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Constellation committed May 13, 2022
1 parent d4a075e commit 4ee336e7e2ab6d097624ea7ad3c451d262723570
Showing with 19 additions and 19 deletions.
  1. +18 −0 Tools/ChangeLog
  2. +1 −19 Tools/lldb/lldb_dump_class_layout.py
@@ -1,3 +1,21 @@
2022-05-13 Yusuke Suzuki <ysuzuki@apple.com>

Use None for architecture when dump-class-layout does not have `-a` option
https://bugs.webkit.org/show_bug.cgi?id=240395

Reviewed by Saam Barati and Simon Fraser.

We can pass None to architecture, then SBDebugger::CreateTargetWithFileAndArch
will call CreateTarget with nullptr architecture string. Then, TargetList constructs
ArchSpec based on currently selected platform automatically and it covers most of cases.
I tried it, and it worked with watchOS, macOS, iOS so far.
So, we should just pass None to CreateTargetWithFileAndArch by default.

* lldb/lldb_dump_class_layout.py:
(LLDBDebuggerInstance.__init__):
(LLDBDebuggerInstance.__del__):
(LLDBDebuggerInstance._get_first_file_architecture): Deleted.

2022-05-13 Commit Queue <commit-queue@webkit.org>

Unreviewed, reverting r294113.
@@ -381,11 +381,7 @@ def __init__(self, binary_path, architecture):

self.debugger = lldb.SBDebugger.Create()
self.debugger.SetAsync(False)
architecture = self.architecture
if not architecture:
architecture = self._get_first_file_architecture()

self.target = self.debugger.CreateTargetWithFileAndArch(str(self.binary_path), architecture)
self.target = self.debugger.CreateTargetWithFileAndArch(str(self.binary_path), self.architecture)
if not self.target:
print("Failed to make target for " + self.binary_path)

@@ -397,20 +393,6 @@ def __del__(self):
if lldb:
lldb.SBDebugger.Destroy(self.debugger)

def _get_first_file_architecture(self):
p = re.compile(r'shared library +(\w+)$')
file_result = subprocess.check_output(["file", self.binary_path], encoding='UTF-8').split('\n')
arches = []
for line in file_result:
match = p.search(line)
if match:
arches.append(match.group(1))

if len(arches) > 0:
return arches[0]

return lldb.LLDB_ARCH_DEFAULT

def layout_for_classname(self, classname):
types = self.module.FindTypes(classname)
if types.GetSize():

0 comments on commit 4ee336e

Please sign in to comment.