2009-11-22 01:44:31 +01:00
|
|
|
/* debugger.c - Some debugger utilities for the notmuch mail library
|
|
|
|
*
|
|
|
|
* Copyright © 2009 Chris Wilson
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-06-02 18:26:14 +02:00
|
|
|
* along with this program. If not, see https://www.gnu.org/licenses/ .
|
2009-11-22 01:44:31 +01:00
|
|
|
*
|
|
|
|
* Author: Chris Wilson <chris@chris-wilson.co.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "notmuch-client.h"
|
|
|
|
|
|
|
|
#include <libgen.h>
|
|
|
|
|
|
|
|
#if HAVE_VALGRIND
|
|
|
|
#include <valgrind.h>
|
|
|
|
#else
|
|
|
|
#define RUNNING_ON_VALGRIND 0
|
|
|
|
#endif
|
|
|
|
|
2017-10-07 10:44:04 +02:00
|
|
|
bool
|
2009-11-22 01:44:31 +01:00
|
|
|
debugger_is_active (void)
|
|
|
|
{
|
|
|
|
char buf[1024];
|
2018-10-06 22:34:49 +02:00
|
|
|
char buf2[1024];
|
2009-11-22 01:44:31 +01:00
|
|
|
|
|
|
|
if (RUNNING_ON_VALGRIND)
|
2017-10-07 10:44:04 +02:00
|
|
|
return true;
|
2009-11-22 01:44:31 +01:00
|
|
|
|
|
|
|
sprintf (buf, "/proc/%d/exe", getppid ());
|
2018-10-06 22:34:49 +02:00
|
|
|
if (readlink (buf, buf2, sizeof (buf2)) != -1 &&
|
|
|
|
strncmp (basename (buf2), "gdb", 3) == 0)
|
2009-11-22 01:44:31 +01:00
|
|
|
{
|
2017-10-07 10:44:04 +02:00
|
|
|
return true;
|
2009-11-22 01:44:31 +01:00
|
|
|
}
|
|
|
|
|
2017-10-07 10:44:04 +02:00
|
|
|
return false;
|
2009-11-22 01:44:31 +01:00
|
|
|
}
|