When fission is enabled, we were indexing the skeleton CU _and_ the .dwo CU. Issues arise when users enable compiler options that add extra data to the skeleton CU (like -fsplit-dwarf-inlining) and there can end up being types in the skeleton CU due to template parameters. We never want to index this information since the .dwo file has the real definition, and we really don't want function prototypes from this info since all parameters are removed. The index doesn't work correctly if it does index the skeleton CU as the DIE offset will assume it is from the .dwo file, so even if we do index the skeleton CU, the index entries will try and grab information from the .dwo file using the wrong DIE offset which can cause errors to be displayed or even worse, if the DIE offsets is valid in the .dwo CU, the wrong DIE will be used. We also fix DWO ID detection to use llvm::Optional<uint64_t> to make sure we can load a .dwo file with a DWO ID of zero. Differential Revision: https://reviews.llvm.org/D131437
50 lines
2.1 KiB
Python
50 lines
2.1 KiB
Python
"""
|
|
Test things related to the fission debug information style where the main object
|
|
file contains a skeleton compile unit and the main debug info is in .dwo files.
|
|
"""
|
|
|
|
import lldb
|
|
from lldbsuite.test.decorators import *
|
|
from lldbsuite.test.lldbtest import *
|
|
from lldbsuite.test import lldbutil
|
|
import os
|
|
|
|
class ExecTestCase(TestBase):
|
|
|
|
NO_DEBUG_INFO_TESTCASE = True
|
|
|
|
def test_zero_dwo_id (self):
|
|
'''
|
|
Test that we can load a .o file that has a skeleton compile unit
|
|
with a DWO ID of zero. We do this by hacking up the yaml to emit
|
|
zero as a DWO ID is both the .o file and .dwo file. Then we make
|
|
sure we can resolve something in the debug information to verify
|
|
that we were able to load the .dwo file corrrectly since that is
|
|
the only place that has this information.
|
|
'''
|
|
src_dir = self.getSourceDir()
|
|
dwo_yaml_path = os.path.join(src_dir, "main.dwo.yaml")
|
|
obj_yaml_path = os.path.join(src_dir, "main.o.yaml")
|
|
dwo_path = self.getBuildArtifact("main.dwo")
|
|
obj_path = self.getBuildArtifact("main.o")
|
|
self.yaml2obj(dwo_yaml_path, dwo_path)
|
|
self.yaml2obj(obj_yaml_path, obj_path)
|
|
|
|
# We need the current working directory to be set to the build directory
|
|
os.chdir(self.getBuildDir())
|
|
# Create a target with the object file we just created from YAML
|
|
target = self.dbg.CreateTarget(obj_path)
|
|
self.assertTrue(target, VALID_TARGET)
|
|
|
|
# Set a breakpoint by file and line, this doesn't require anything from
|
|
# the .dwo file.
|
|
bp = target.BreakpointCreateByLocation('main.cpp', 6)
|
|
self.assertTrue(bp.GetNumLocations() == 1)
|
|
bp_loc = bp.GetLocationAtIndex(0)
|
|
self.assertTrue(bp_loc.IsValid())
|
|
|
|
# We will use the address of the location to resolve the function "main"
|
|
# to make sure we were able to open the .dwo file since this is the only
|
|
# place that contains debug info for the function.
|
|
self.assertTrue(bp_loc.GetAddress().GetFunction().IsValid())
|