Commit 0febee5b by Jamie Madill Committed by Commit Bot

Break debugger on assertion failure.

This adds a few simple system utility functions. We can check if a debugger is attached and break into the debugger. Most of the code is adapted from Chromium's base/debug. Bug: angleproject:3162 Change-Id: I9cb39d42865a543fbf3201222dd8227318b32ad5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1615353Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent aefbea29
......@@ -23,6 +23,7 @@
#include "common/Optional.h"
#include "common/angleutils.h"
#include "common/system_utils.h"
namespace gl
{
......@@ -168,7 +169,14 @@ LogMessage::~LogMessage()
if (mSeverity == LOG_FATAL)
{
ANGLE_CRASH();
if (angle::IsDebuggerAttached())
{
angle::BreakDebugger();
}
else
{
ANGLE_CRASH();
}
}
}
......
......@@ -52,6 +52,12 @@ class Library : angle::NonCopyable
};
Library *OpenSharedLibrary(const char *libraryName);
// Returns true if the process is currently being debugged.
bool IsDebuggerAttached();
// Calls system APIs to break into the debugger.
void BreakDebugger();
} // namespace angle
#endif // COMMON_SYSTEM_UTILS_H_
......@@ -263,4 +263,18 @@ bool IsDirectory(const char *filename)
int result = stat(filename, &st);
return result == 0 && ((st.st_mode & S_IFDIR) == S_IFDIR);
}
bool IsDebuggerAttached()
{
// This could have a fuller implementation.
// See https://cs.chromium.org/chromium/src/base/debug/debugger_posix.cc
return false;
}
void BreakDebugger()
{
// This could have a fuller implementation.
// See https://cs.chromium.org/chromium/src/base/debug/debugger_posix.cc
abort();
}
} // namespace angle
......@@ -297,4 +297,14 @@ bool IsDirectory(const char *filename)
return false;
}
bool IsDebuggerAttached()
{
return !!::IsDebuggerPresent();
}
void BreakDebugger()
{
__debugbreak();
}
} // namespace angle
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment