forked from OSchip/llvm-project
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 llvm-svn: 327077
This commit is contained in:
parent
f96b1b88f8
commit
299cd890fe
|
@ -1011,7 +1011,43 @@ static Error checkThreadCommand(const MachOObjectFile &Obj,
|
||||||
CmdName + " command");
|
CmdName + " command");
|
||||||
}
|
}
|
||||||
} else if (cputype == MachO::CPU_TYPE_X86_64) {
|
} 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)
|
if (count != MachO::x86_THREAD_STATE64_COUNT)
|
||||||
return malformedError("load command " + Twine(LoadCommandIndex) +
|
return malformedError("load command " + Twine(LoadCommandIndex) +
|
||||||
" count not x86_THREAD_STATE64_COUNT for "
|
" count not x86_THREAD_STATE64_COUNT for "
|
||||||
|
@ -1023,6 +1059,18 @@ static Error checkThreadCommand(const MachOObjectFile &Obj,
|
||||||
" x86_THREAD_STATE64 extends past end of "
|
" x86_THREAD_STATE64 extends past end of "
|
||||||
"command in " + CmdName + " command");
|
"command in " + CmdName + " command");
|
||||||
state += sizeof(MachO::x86_thread_state64_t);
|
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 {
|
} else {
|
||||||
return malformedError("load command " + Twine(LoadCommandIndex) +
|
return malformedError("load command " + Twine(LoadCommandIndex) +
|
||||||
" unknown flavor (" + Twine(flavor) + ") for "
|
" unknown flavor (" + Twine(flavor) + ") for "
|
||||||
|
|
|
@ -9328,6 +9328,26 @@ static void PrintThreadCommand(MachO::thread_command t, const char *Ptr,
|
||||||
outs() << "\t esh.flavor " << es.esh.flavor << " esh.count "
|
outs() << "\t esh.flavor " << es.esh.flavor << " esh.count "
|
||||||
<< es.esh.count << "\n";
|
<< 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 {
|
} else {
|
||||||
outs() << " flavor " << flavor << " (unknown)\n";
|
outs() << " flavor " << flavor << " (unknown)\n";
|
||||||
outs() << " count " << count << "\n";
|
outs() << " count " << count << "\n";
|
||||||
|
|
Loading…
Reference in New Issue