Skip to content

Commit e6a9c71

Browse files
committed
[lldb][Mach-O] Initialize cputype/cpusubtype in test corefiles (llvm#120518)
TestFirmwareCorefiles.py has a helper utility, create-empty-corefile.cpp, which creates corefiles with different metadata to specify the binary that should be loaded. It normally uses an actual binary's UUID for the metadata, and it uses the binary's cputype/cpusubtype for the corefile's mach header. There is one test where it creates a corefile with metadata for a UUID that cannot be found -- it is given no binary -- and in that case, the cputype/cpusubtype it sets in the core file mach header was uninitialized data. Through luck, on Darwin systems, the uninitialized data typically matched a CPU_TYPE from machine.h and the test would work. But when the value doens't match one of thoes defines, lldb would reject the corefile entirely, and the test would fail. This has been an infrequent failure on the CI bots for a while and I couldn't ever repo it. There's a recent configuration where it was happening every time and I was able to track it down. rdar://141727563 (cherry picked from commit 527595f)
1 parent aed73c6 commit e6a9c71

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lldb/test/API/macosx/lc-note/firmware-corefile/create-empty-corefile.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ void add_lc_segment(std::vector<std::vector<uint8_t>> &loadcmds,
189189

190190
std::string get_uuid_from_binary(const char *fn, cpu_type_t &cputype,
191191
cpu_subtype_t &cpusubtype) {
192+
// We may be given a file, set reasonable values.
193+
#if defined(__x86_64__)
194+
cputype = CPU_TYPE_X86;
195+
cpusubtype = CPU_SUBTYPE_X86_ALL;
196+
#else
197+
cputype = CPU_TYPE_ARM64;
198+
cpusubtype = CPU_SUBTYPE_ARM64_ALL;
199+
#endif
192200
if (strlen(fn) == 0)
193201
return {};
194202

0 commit comments

Comments
 (0)