2011-09-09 23:24:18 +04:00
|
|
|
#include "assert.hh"
|
|
|
|
|
2012-10-17 19:01:08 +04:00
|
|
|
#include "exception.hh"
|
|
|
|
|
2013-01-23 16:45:44 +04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
2011-09-09 23:24:18 +04:00
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2012-10-17 19:01:08 +04:00
|
|
|
struct assert_failed : logic_error
|
2011-09-09 23:24:18 +04:00
|
|
|
{
|
2012-10-17 19:01:08 +04:00
|
|
|
assert_failed(const String& message)
|
|
|
|
: m_message(message) {}
|
2011-09-09 23:24:18 +04:00
|
|
|
|
2012-10-17 19:01:08 +04:00
|
|
|
String description() const override { return m_message; }
|
|
|
|
private:
|
|
|
|
String m_message;
|
|
|
|
};
|
2011-09-09 23:24:18 +04:00
|
|
|
|
2012-10-17 19:01:08 +04:00
|
|
|
void on_assert_failed(const char* message)
|
2012-10-16 18:16:32 +04:00
|
|
|
{
|
2013-01-23 16:45:44 +04:00
|
|
|
String debug_info = "pid: " + int_to_str(getpid());
|
|
|
|
int res = system(("xmessage -buttons 'quit:0,ignore:1' '"_str +
|
|
|
|
message + "\n[Debug Infos]\n" + debug_info + "'").c_str());
|
2012-10-16 18:16:32 +04:00
|
|
|
switch (res)
|
|
|
|
{
|
2012-10-19 05:53:10 +04:00
|
|
|
case -1:
|
|
|
|
case 0:
|
2012-10-16 18:16:32 +04:00
|
|
|
throw assert_failed(message);
|
|
|
|
case 1:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-09 23:24:18 +04:00
|
|
|
}
|