debug: Improve the functionality greatly.
This is a much improved debugging implementation (Linux).
This commit is contained in:
parent
80647989b0
commit
c40b46455a
|
@ -9,6 +9,12 @@
|
||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__linux__)
|
||||||
|
# include <sys/types.h>
|
||||||
|
# include <dirent.h>
|
||||||
|
# include <ctype.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <Eo.h>
|
#include <Eo.h>
|
||||||
#include <Eina.h>
|
#include <Eina.h>
|
||||||
#include <Elementary.h>
|
#include <Elementary.h>
|
||||||
|
@ -19,13 +25,13 @@
|
||||||
#include "edi_private.h"
|
#include "edi_private.h"
|
||||||
|
|
||||||
Edi_Debug_Tool _debugger_tools[] = {
|
Edi_Debug_Tool _debugger_tools[] = {
|
||||||
{ "gdb", "gdb", NULL, "run\n", "c\n", "set args %s" },
|
{ "gdb", "gdb", NULL, "run\n", "c\n", "set args %s\n", "set follow-fork-mode child\n"},
|
||||||
{ "lldb", "lldb", NULL, "run\n", "c\n", "settings set target.run-args %s" },
|
{ "lldb", "lldb", NULL, "run\n", "c\n", "settings set target.run-args %s", NULL },
|
||||||
{ "pdb", "pdb", NULL, NULL, "c\n", "run %s" },
|
{ "pdb", "pdb", NULL, NULL, "c\n", "run %s", NULL },
|
||||||
{ "memcheck", "valgrind", "--tool=memcheck", NULL, NULL, NULL },
|
{ "memcheck", "valgrind", "--tool=memcheck", NULL, NULL, NULL, NULL },
|
||||||
{ "massif", "valgrind", "--tool=massif", NULL, NULL, NULL },
|
{ "massif", "valgrind", "--tool=massif", NULL, NULL, NULL, NULL },
|
||||||
{ "callgrind", "valgrind", "--tool=callgrind", NULL, NULL, NULL },
|
{ "callgrind", "valgrind", "--tool=callgrind", NULL, NULL, NULL, NULL },
|
||||||
{ NULL, NULL, NULL, NULL, NULL, NULL },
|
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
Edi_Debug *_debugger = NULL;
|
Edi_Debug *_debugger = NULL;
|
||||||
|
@ -106,6 +112,46 @@ int edi_debug_process_id(Edi_Debug *debugger)
|
||||||
if (!debugger->exe) return -1;
|
if (!debugger->exe) return -1;
|
||||||
|
|
||||||
debugger_pid = ecore_exe_pid_get(debugger->exe);
|
debugger_pid = ecore_exe_pid_get(debugger->exe);
|
||||||
|
#if defined(__linux__)
|
||||||
|
DIR *dir;
|
||||||
|
struct dirent *dh;
|
||||||
|
|
||||||
|
dir = opendir("/proc");
|
||||||
|
if (!dir) return -1;
|
||||||
|
|
||||||
|
while ((dh = readdir(dir)))
|
||||||
|
{
|
||||||
|
const char *c = dh->d_name;
|
||||||
|
while (*c)
|
||||||
|
{
|
||||||
|
if (!isdigit(*c)) break;
|
||||||
|
++c;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*c) continue;
|
||||||
|
|
||||||
|
p = edi_process_stats_by_pid(atoi(dh->d_name));
|
||||||
|
if (!p) continue;
|
||||||
|
|
||||||
|
if (p->ppid == debugger_pid)
|
||||||
|
{
|
||||||
|
if (!strcmp(debugger->program_name, p->command))
|
||||||
|
{
|
||||||
|
child_pid = p->pid;
|
||||||
|
if (!strcmp(p->state, "RUN") ||!strcmp(p->state, "SLEEP"))
|
||||||
|
debugger->state = EDI_DEBUG_PROCESS_ACTIVE;
|
||||||
|
else
|
||||||
|
debugger->state = EDI_DEBUG_PROCESS_SLEEPING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
closedir(dir);
|
||||||
|
|
||||||
|
return child_pid;
|
||||||
|
#endif
|
||||||
|
|
||||||
pid_max = _system_pid_max_get();
|
pid_max = _system_pid_max_get();
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ typedef struct _Edi_Debug_Tool {
|
||||||
const char *command_start;
|
const char *command_start;
|
||||||
const char *command_continue;
|
const char *command_continue;
|
||||||
const char *command_arguments;
|
const char *command_arguments;
|
||||||
|
const char *command_settings;
|
||||||
} Edi_Debug_Tool;
|
} Edi_Debug_Tool;
|
||||||
|
|
||||||
typedef struct _Edi_Debug {
|
typedef struct _Edi_Debug {
|
||||||
|
|
Loading…
Reference in New Issue