[llvm] r327077 - For llvm-objdump and Mach-O files, update the printing of some thread states
Kevin Enderby via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 8 15:10:38 PST 2018
Author: enderby
Date: Thu Mar 8 15:10:38 2018
New Revision: 327077
URL: http://llvm.org/viewvc/llvm-project?rev=327077&view=rev
Log:
For llvm-objdump and Mach-O files, update the printing of some thread states
from core files. I tested this against the couple of core files that were
getting errors about unknown thread flavors and it now produce the same output as
the Xcode otool-classic(1) tool. Since the core files are huge I didn’t include
them as test cases.
rdar://38216356
Modified:
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/tools/llvm-objdump/MachODump.cpp
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=327077&r1=327076&r2=327077&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Thu Mar 8 15:10:38 2018
@@ -1011,7 +1011,43 @@ static Error checkThreadCommand(const Ma
CmdName + " command");
}
} else if (cputype == MachO::CPU_TYPE_X86_64) {
- if (flavor == MachO::x86_THREAD_STATE64) {
+ if (flavor == MachO::x86_THREAD_STATE) {
+ if (count != MachO::x86_THREAD_STATE_COUNT)
+ return malformedError("load command " + Twine(LoadCommandIndex) +
+ " count not x86_THREAD_STATE_COUNT for "
+ "flavor number " + Twine(nflavor) + " which is "
+ "a x86_THREAD_STATE flavor in " + CmdName +
+ " command");
+ if (state + sizeof(MachO::x86_thread_state_t) > end)
+ return malformedError("load command " + Twine(LoadCommandIndex) +
+ " x86_THREAD_STATE extends past end of "
+ "command in " + CmdName + " command");
+ state += sizeof(MachO::x86_thread_state_t);
+ } else if (flavor == MachO::x86_FLOAT_STATE) {
+ if (count != MachO::x86_FLOAT_STATE_COUNT)
+ return malformedError("load command " + Twine(LoadCommandIndex) +
+ " count not x86_FLOAT_STATE_COUNT for "
+ "flavor number " + Twine(nflavor) + " which is "
+ "a x86_FLOAT_STATE flavor in " + CmdName +
+ " command");
+ if (state + sizeof(MachO::x86_float_state_t) > end)
+ return malformedError("load command " + Twine(LoadCommandIndex) +
+ " x86_FLOAT_STATE extends past end of "
+ "command in " + CmdName + " command");
+ state += sizeof(MachO::x86_float_state_t);
+ } else if (flavor == MachO::x86_EXCEPTION_STATE) {
+ if (count != MachO::x86_EXCEPTION_STATE_COUNT)
+ return malformedError("load command " + Twine(LoadCommandIndex) +
+ " count not x86_EXCEPTION_STATE_COUNT for "
+ "flavor number " + Twine(nflavor) + " which is "
+ "a x86_EXCEPTION_STATE flavor in " + CmdName +
+ " command");
+ if (state + sizeof(MachO::x86_exception_state_t) > end)
+ return malformedError("load command " + Twine(LoadCommandIndex) +
+ " x86_EXCEPTION_STATE extends past end of "
+ "command in " + CmdName + " command");
+ state += sizeof(MachO::x86_exception_state_t);
+ } else if (flavor == MachO::x86_THREAD_STATE64) {
if (count != MachO::x86_THREAD_STATE64_COUNT)
return malformedError("load command " + Twine(LoadCommandIndex) +
" count not x86_THREAD_STATE64_COUNT for "
@@ -1023,6 +1059,18 @@ static Error checkThreadCommand(const Ma
" x86_THREAD_STATE64 extends past end of "
"command in " + CmdName + " command");
state += sizeof(MachO::x86_thread_state64_t);
+ } else if (flavor == MachO::x86_EXCEPTION_STATE64) {
+ if (count != MachO::x86_EXCEPTION_STATE64_COUNT)
+ return malformedError("load command " + Twine(LoadCommandIndex) +
+ " count not x86_EXCEPTION_STATE64_COUNT for "
+ "flavor number " + Twine(nflavor) + " which is "
+ "a x86_EXCEPTION_STATE64 flavor in " + CmdName +
+ " command");
+ if (state + sizeof(MachO::x86_exception_state64_t) > end)
+ return malformedError("load command " + Twine(LoadCommandIndex) +
+ " x86_EXCEPTION_STATE64 extends past end of "
+ "command in " + CmdName + " command");
+ state += sizeof(MachO::x86_exception_state64_t);
} else {
return malformedError("load command " + Twine(LoadCommandIndex) +
" unknown flavor (" + Twine(flavor) + ") for "
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=327077&r1=327076&r2=327077&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Thu Mar 8 15:10:38 2018
@@ -9328,6 +9328,26 @@ static void PrintThreadCommand(MachO::th
outs() << "\t esh.flavor " << es.esh.flavor << " esh.count "
<< es.esh.count << "\n";
}
+ } else if (flavor == MachO::x86_EXCEPTION_STATE64) {
+ outs() << " flavor x86_EXCEPTION_STATE64\n";
+ if (count == MachO::x86_EXCEPTION_STATE64_COUNT)
+ outs() << " count x86_EXCEPTION_STATE64_COUNT\n";
+ else
+ outs() << " count " << count
+ << " (not x86_EXCEPTION_STATE64_COUNT)\n";
+ struct MachO::x86_exception_state64_t es64;
+ left = end - begin;
+ if (left >= sizeof(MachO::x86_exception_state64_t)) {
+ memcpy(&es64, begin, sizeof(MachO::x86_exception_state64_t));
+ begin += sizeof(MachO::x86_exception_state64_t);
+ } else {
+ memset(&es64, '\0', sizeof(MachO::x86_exception_state64_t));
+ memcpy(&es64, begin, left);
+ begin += left;
+ }
+ if (isLittleEndian != sys::IsLittleEndianHost)
+ swapStruct(es64);
+ Print_x86_exception_state_t(es64);
} else {
outs() << " flavor " << flavor << " (unknown)\n";
outs() << " count " << count << "\n";
More information about the llvm-commits
mailing list