summaryrefslogtreecommitdiffstats
path: root/lldb/tools/debugserver
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2017-12-08 01:09:40 +0000
committerVedant Kumar <vsk@apple.com>2017-12-08 01:09:40 +0000
commit9c36859b33b386fbfa9599646de1e2ae01158180 (patch)
treed37f048c2b764737a5fa211a6388f937785b4159 /lldb/tools/debugserver
parentb773e488c980bde0cb45ae061bf8c9a1058f897c (diff)
downloadbcm5719-llvm-9c36859b33b386fbfa9599646de1e2ae01158180.tar.gz
bcm5719-llvm-9c36859b33b386fbfa9599646de1e2ae01158180.zip
[MachException] Avoid alignment UB, NFC
Fix alignment UB in some Mach exception-handling logic. This lets us build lldb and debugserver with UBSan in trapping mode, and get further along in the testing process before a trap is encountered. rdar://35923991 llvm-svn: 320127
Diffstat (limited to 'lldb/tools/debugserver')
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachException.cpp6
-rw-r--r--lldb/tools/debugserver/source/MacOSX/MachException.h9
2 files changed, 11 insertions, 4 deletions
diff --git a/lldb/tools/debugserver/source/MacOSX/MachException.cpp b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
index 12479b8b7e8..cc309e47d86 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachException.cpp
+++ b/lldb/tools/debugserver/source/MacOSX/MachException.cpp
@@ -113,8 +113,7 @@ catch_mach_exception_raise(mach_port_t exc_port, mach_port_t thread_port,
g_message->task_port = task_port;
g_message->thread_port = thread_port;
g_message->exc_type = exc_type;
- for (mach_msg_type_number_t i=0; i<exc_data_count; ++i)
- g_message->exc_data.push_back(exc_data[i]);
+ g_message->AppendExceptionData(exc_data, exc_data_count);
return KERN_SUCCESS;
} else if (!MachTask::IsValid(g_message->task_port)) {
// Our original exception port isn't valid anymore check for a SIGTRAP
@@ -126,8 +125,7 @@ catch_mach_exception_raise(mach_port_t exc_port, mach_port_t thread_port,
g_message->task_port = task_port;
g_message->thread_port = thread_port;
g_message->exc_type = exc_type;
- for (mach_msg_type_number_t i=0; i<exc_data_count; ++i)
- g_message->exc_data.push_back(exc_data[i]);
+ g_message->AppendExceptionData(exc_data, exc_data_count);
return KERN_SUCCESS;
}
}
diff --git a/lldb/tools/debugserver/source/MacOSX/MachException.h b/lldb/tools/debugserver/source/MacOSX/MachException.h
index a45a41e01f4..e1af12def10 100644
--- a/lldb/tools/debugserver/source/MacOSX/MachException.h
+++ b/lldb/tools/debugserver/source/MacOSX/MachException.h
@@ -71,6 +71,15 @@ public:
return (exc_type == EXC_BREAKPOINT ||
((exc_type == EXC_SOFTWARE) && exc_data[0] == 1));
}
+ void AppendExceptionData(mach_exception_data_t Data,
+ mach_msg_type_number_t Count) {
+ mach_exception_data_type_t Buf;
+ for (mach_msg_type_number_t i = 0; i < Count; ++i) {
+ // Perform an unaligned copy.
+ memcpy(&Buf, Data + i, sizeof(mach_exception_data_type_t));
+ exc_data.push_back(Buf);
+ }
+ }
void Dump() const;
void DumpStopReason() const;
bool GetStopInfo(struct DNBThreadStopInfo *stop_info) const;
OpenPOWER on IntegriCloud