Files
clang-p2996/lldb/test/API/functionalities/disassemble/aarch64-adrp-add/TestAArch64AdrpAdd.py
Raphael Isemann fc5495c351 [lldb] Make TestAArch64AdrpAdd depend on the AArch64 target
LLDB is using LLVM's target-specific disassembler which is only available when
the respective LLVM target has been enabled in the build config.

This patch just skips the test if there is no arm64 target (and its
disassembler) available in the current build config.

Reviewed By: jasonmolenda

Differential Revision: https://reviews.llvm.org/D108145
2021-08-17 13:47:22 +02:00

71 lines
2.7 KiB
Python

"""
Test that the arm64 ADRP + ADD pc-relative addressing pair is symbolicated.
"""
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
class TestAArch64AdrpAdd(TestBase):
mydir = TestBase.compute_mydir(__file__)
@no_debug_info_test
@skipIfLLVMTargetMissing("AArch64")
def test_arm64(self):
src_dir = self.getSourceDir()
yaml_path = os.path.join(src_dir, "a.out-arm64.yaml")
obj_path = self.getBuildArtifact("a.out-arm64")
self.yaml2obj(yaml_path, obj_path)
target = self.dbg.CreateTarget(obj_path)
self.assertTrue(target, VALID_TARGET)
mains = target.FindFunctions("main")
for f in mains.symbols:
binaryname = f.GetStartAddress().GetModule().GetFileSpec().GetFilename()
if binaryname == "a.out-arm64":
self.disassemble_check_for_hi_and_foo(target, f, binaryname)
@no_debug_info_test
@skipIfLLVMTargetMissing("AArch64")
def test_arm64_32(self):
src_dir = self.getSourceDir()
yaml_path = os.path.join(src_dir, "a.out-arm64_32.yaml")
obj_path = self.getBuildArtifact("a.out-arm64_32")
self.yaml2obj(yaml_path, obj_path)
target = self.dbg.CreateTarget(obj_path)
self.assertTrue(target, VALID_TARGET)
mains = target.FindFunctions("main")
for f in mains.symbols:
binaryname = f.GetStartAddress().GetModule().GetFileSpec().GetFilename()
if binaryname == "a.out-arm64_32":
self.disassemble_check_for_hi_and_foo(target, f, binaryname)
def disassemble_check_for_hi_and_foo(self, target, func, binaryname):
insns = func.GetInstructions(target)
found_hi_string = False
found_foo = False
# The binary has an ADRP + ADD instruction pair which load
# the pc-relative address of a c-string, and loads the address
# of a function into a function pointer. lldb should show
# that c-string and the name of that function in the disassembly
# comment field.
for i in insns:
if "HI" in i.GetComment(target):
found_hi_string = True
if "foo" in i.GetComment(target):
found_foo = True
if found_hi_string == False or found_foo == False:
print('Did not find "HI" string or "foo" in disassembly symbolication in %s' % binaryname)
if self.TraceOn():
strm = lldb.SBStream()
insns.GetDescription(strm)
print('Disassembly of main(), looking for "HI" and "foo" in comments:')
print(strm.GetData())
self.assertTrue(found_hi_string)
self.assertTrue(found_foo)