···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2020 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#include <CoreServices/MacErrors.h>
2121+#include <iostream>
2222+#include "UserBreak.h"
2323+2424+void SysError(short errorCode)
2525+{
2626+ std::cerr << "SysError(" << errorCode << ") was called!\n";
2727+ doUserBreak();
2828+}
+40
src/frameworks/CoreServices/UserBreak.cpp
···11+22+/*
33+This file is part of Darling.
44+55+Copyright (C) 2020 Lubos Dolezel
66+77+Darling is free software: you can redistribute it and/or modify
88+it under the terms of the GNU General Public License as published by
99+the Free Software Foundation, either version 3 of the License, or
1010+(at your option) any later version.
1111+1212+Darling is distributed in the hope that it will be useful,
1313+but WITHOUT ANY WARRANTY; without even the implied warranty of
1414+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1515+GNU General Public License for more details.
1616+1717+You should have received a copy of the GNU General Public License
1818+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1919+*/
2020+2121+#include <pthread.h>
2222+#include <cstdlib>
2323+2424+static bool doBreak = false;
2525+2626+static void initUserBreak()
2727+{
2828+ const char* userbreak = getenv("USERBREAK");
2929+ if (userbreak && atoi(userbreak))
3030+ doBreak = true;
3131+}
3232+3333+__attribute__((visibility("hidden")))
3434+void doUserBreak()
3535+{
3636+ static pthread_once_t once = PTHREAD_ONCE_INIT;
3737+ pthread_once(&once, initUserBreak);
3838+ if (doBreak)
3939+ __builtin_debugtrap();
4040+}
+25
src/frameworks/CoreServices/UserBreak.h
···11+/*
22+This file is part of Darling.
33+44+Copyright (C) 2020 Lubos Dolezel
55+66+Darling is free software: you can redistribute it and/or modify
77+it under the terms of the GNU General Public License as published by
88+the Free Software Foundation, either version 3 of the License, or
99+(at your option) any later version.
1010+1111+Darling is distributed in the hope that it will be useful,
1212+but WITHOUT ANY WARRANTY; without even the implied warranty of
1313+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1414+GNU General Public License for more details.
1515+1616+You should have received a copy of the GNU General Public License
1717+along with Darling. If not, see <http://www.gnu.org/licenses/>.
1818+*/
1919+2020+#ifndef _USERBREAK_H
2121+#define _USERBREAK_H
2222+2323+void doUserBreak();
2424+2525+#endif