Files
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

83 lines
3.0 KiB
Python

"""
Tests that LLDB can correctly set up a disassembler using extensions from the .riscv.attributes section.
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil
import os
class TestDisassembler(TestBase):
expected_zbb_instrs = ["andn", "orn", "xnor", "rol", "ror"]
@skipIfLLVMTargetMissing("RISCV")
def test_without_riscv_attributes(self):
"""
Tests disassembly of a riscv binary without the .riscv.attributes.
Without the .riscv.attributes section lldb won't set up a disassembler to
handle the bitmanip extension, so it is not expected to see zbb instructions
in the output.
"""
yaml = os.path.join(self.getSourceDir(), "stripped.out.yaml")
exe = self.getBuildArtifact("stripped.out")
self.yaml2obj(yaml, exe)
target = self.dbg.CreateTarget(exe)
self.expect("disassemble --name do_zbb_stuff")
output = self.res.GetOutput()
for instr in self.expected_zbb_instrs:
self.assertFalse(
instr in output, "Zbb instructions should not be disassembled"
)
self.assertEqual(
output.count("unknown"),
len(self.expected_zbb_instrs),
"Instructions from the Zbb extension should be displayed as <unknown>",
)
@skipIfLLVMTargetMissing("RISCV")
def test_with_riscv_attributes(self):
"""
Tests disassembly of a riscv binary with the .riscv.attributes.
"""
yaml = os.path.join(self.getSourceDir(), "a.out.yaml")
exe = self.getBuildArtifact("a.out")
self.yaml2obj(yaml, exe)
target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
self.expect("disassemble --name do_zbb_stuff")
output = self.res.GetOutput()
for instr in self.expected_zbb_instrs:
self.assertTrue(instr in output, "Invalid disassembler output")
@skipIfLLVMTargetMissing("RISCV")
def test_conflicting_extensions(self):
"""
This test demonstrates the scenario where:
1. file_with_zcd.c is compiled with rv64gc (includes C and D).
2. file_with_zcmp.c is compiled with rv64imad_zcmp (includes Zcmp).
3. The linker merges .riscv.attributes, creating the union: C + D + Zcmp.
The Zcmp extension is incompatible with the C extension when the D extension is enabled.
Therefore, the arch string contains conflicting extensions, and LLDB should
display an appropriate warning in this case.
"""
yaml = os.path.join(self.getSourceDir(), "conflicting.out.yaml")
exe = self.getBuildArtifact("conflicting.out")
self.yaml2obj(yaml, exe)
target = self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
output = self.res.GetOutput()
self.assertIn(
output,
"The .riscv.attributes section contains an invalid RISC-V arch string",
)