mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
core file is now given from CrashDialog
Added run_program() Added new splash image New spawn_program() error codes
This commit is contained in:
parent
a80b5dcb2a
commit
25b80eaffa
@ -16,7 +16,6 @@
|
||||
#include <FL/Fl.h>
|
||||
#include <FL/Fl_Pixmap.h>
|
||||
#include <edelib/Nls.h>
|
||||
#include <edelib/File.h>
|
||||
|
||||
#include <stdio.h> // snprintf
|
||||
|
||||
@ -47,6 +46,7 @@ CrashDialog::CrashDialog() : Fl_Window(DIALOG_W, DIALOG_H, _("World is going dow
|
||||
icon_box->image(pix);
|
||||
|
||||
txt_box = new Fl_Box(85, 10, 285, 75);
|
||||
txt_box->label(_("Program just crashed !!!\n\nYou can inspect details about this crash by clicking on 'Show backtrace' below"));
|
||||
txt_box->align(FL_ALIGN_WRAP | FL_ALIGN_LEFT | FL_ALIGN_INSIDE);
|
||||
|
||||
close = new Fl_Button(280, 95, 90, 25, _("&Close"));
|
||||
@ -90,25 +90,15 @@ void CrashDialog::show_details(void) {
|
||||
|
||||
if(!trace_loaded) {
|
||||
trace_buff->remove(0, trace_buff->length());
|
||||
|
||||
// read core
|
||||
spawn_backtrace(cmd.c_str(), "core", "/tmp/gdb_output", "/tmp/gdb_script");
|
||||
|
||||
trace_buff->appendfile("/tmp/gdb_output");
|
||||
trace_loaded = 1;
|
||||
|
||||
// delete core
|
||||
edelib::file_remove("core");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CrashDialog::set_data(const char* command) {
|
||||
cmd = command;
|
||||
|
||||
char txt[1024];
|
||||
snprintf(txt, sizeof(txt), _("Program just crashed !!!\n\nYou can inspect details about this crash by clicking on 'Show backtrace' below"));
|
||||
txt_box->copy_label(txt);
|
||||
trace_loaded = 0;
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <unistd.h> //
|
||||
#include <stdlib.h> // free
|
||||
#include <string.h> // strdup, memset
|
||||
#include <errno.h> // error codes
|
||||
|
||||
void resolve_path(const edelib::String& imgdir, edelib::String& img, bool have_imgdir) {
|
||||
if(img.empty())
|
||||
@ -329,9 +330,10 @@ void EvokeService::quit_x11(void) {
|
||||
* attach gdb on it pid and run backtrace.
|
||||
*/
|
||||
void EvokeService::service_watcher(int pid, int signum) {
|
||||
//if(signum == 11) {
|
||||
if(signum == 139) {
|
||||
printf("got %i\n", signum);
|
||||
if(signum == SPAWN_CHILD_CRASHED) {
|
||||
EvokeProcess pc;
|
||||
|
||||
if(find_and_unregister_process(pid, pc)) {
|
||||
printf("%s crashed with core dump\n", pc.cmd.c_str());
|
||||
|
||||
@ -340,13 +342,31 @@ void EvokeService::service_watcher(int pid, int signum) {
|
||||
cdialog.run();
|
||||
return;
|
||||
}
|
||||
} else if(signum == 32512) {
|
||||
fl_alert("No such file");
|
||||
} else if(signum == SPAWN_CHILD_KILLED) {
|
||||
printf("child %i killed\n", pid);
|
||||
} else {
|
||||
printf("child %i exited with %i \n", pid, signum);
|
||||
}
|
||||
|
||||
unregister_process(pid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute program. It's return status
|
||||
* will be reported via service_watcher()
|
||||
*/
|
||||
void EvokeService::run_program(const char* cmd) {
|
||||
EASSERT(cmd != NULL);
|
||||
|
||||
pid_t child;
|
||||
int r = spawn_program_with_core(cmd, service_watcher_cb, &child);
|
||||
|
||||
if(r != 0)
|
||||
fl_alert("Unable to start %s. Got code %i", cmd, r);
|
||||
else
|
||||
register_process(cmd, child);
|
||||
}
|
||||
|
||||
void EvokeService::register_process(const char* cmd, pid_t pid) {
|
||||
EvokeProcess pc;
|
||||
pc.cmd = cmd;
|
||||
@ -414,15 +434,7 @@ int EvokeService::handle(const XEvent* ev) {
|
||||
char buff[1024];
|
||||
if(get_string_property_value(_ede_spawn, buff, sizeof(buff))) {
|
||||
logfile->printf("Got _EVOKE_SPAWN with %s. Starting client...\n", buff);
|
||||
|
||||
pid_t child;
|
||||
int r = spawn_program_with_core(buff, service_watcher_cb, &child);
|
||||
|
||||
if(r != 0)
|
||||
fl_alert("Unable to start %s. Got code %i", buff, r);
|
||||
else
|
||||
register_process(buff, child);
|
||||
|
||||
run_program(buff);
|
||||
} else {
|
||||
logfile->printf("Got _EVOKE_SPAWN with malformed data. Ignoring...\n");
|
||||
}
|
||||
@ -448,7 +460,7 @@ int EvokeService::handle(const XEvent* ev) {
|
||||
int dh = DisplayHeight(fl_display, fl_screen);
|
||||
|
||||
printf("got %i\n", logout_dialog(dw, dh));
|
||||
//quit_x11();
|
||||
// quit_x11();
|
||||
} else
|
||||
logfile->printf("Got _EDE_EVOKE_SHUTDOWN_ALL with bad code (%i). Ignoring...\n", val);
|
||||
return 1;
|
||||
|
@ -78,12 +78,12 @@ class EvokeService {
|
||||
void register_top(Fl_Double_Window* win) { top_win = win; }
|
||||
void unregister_top(void) { top_win = NULL; }
|
||||
|
||||
void service_watcher(int pid, int signum);
|
||||
void run_program(const char* cmd);
|
||||
void register_process(const char* cmd, pid_t pid);
|
||||
void unregister_process(pid_t pid);
|
||||
bool find_and_unregister_process(pid_t pid, EvokeProcess& pc);
|
||||
|
||||
void service_watcher(int pid, int signum);
|
||||
|
||||
void quit_x11(void);
|
||||
};
|
||||
|
||||
|
@ -16,5 +16,3 @@ EdeProgram evoke : $(SOURCE) ;
|
||||
FltkProgramBare test/evoke_test : test/evoke_test.cpp ;
|
||||
#TranslationStrings locale : $(SOURCE) ;
|
||||
EdeManual doc/evoke.txt ;
|
||||
|
||||
#EdeProgram crash : Crash.cpp ;
|
||||
|
@ -35,8 +35,16 @@ void sigchld_handler(int sig) {
|
||||
errno = 0;
|
||||
pid = waitpid(WAIT_ANY, &status, WNOHANG);
|
||||
|
||||
if(global_watch != 0)
|
||||
if(global_watch != 0) {
|
||||
if(WIFEXITED(status))
|
||||
status = WEXITSTATUS(status);
|
||||
else if(WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)
|
||||
status = SPAWN_CHILD_CRASHED;
|
||||
else
|
||||
status = SPAWN_CHILD_KILLED;
|
||||
|
||||
global_watch(pid, status);
|
||||
}
|
||||
|
||||
} while(pid <= 0 && errno == EINTR);
|
||||
}
|
||||
@ -126,7 +134,7 @@ int spawn_program_with_core(const char* cmd, SignalWatch* wf, pid_t* child_pid_r
|
||||
return ret;
|
||||
}
|
||||
|
||||
int spawn_backtrace(const char* program, const char* core_path, const char* output, const char* script) {
|
||||
int spawn_backtrace(const char* program, const char* core, const char* output, const char* script) {
|
||||
const char* gdb_script = "bt\nquit\n";
|
||||
const int gdb_script_len = 8;
|
||||
|
||||
@ -158,11 +166,9 @@ int spawn_backtrace(const char* program, const char* core_path, const char* outp
|
||||
argv[3] = "-x";
|
||||
argv[4] = (char*)script;
|
||||
argv[5] = (char*)program;
|
||||
argv[6] = (char*)core_path;
|
||||
argv[6] = (char*)core;
|
||||
argv[7] = 0;
|
||||
|
||||
//printf("%s %s %s %s %s %s %s\n", argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]);
|
||||
|
||||
execvp(argv[0], argv);
|
||||
return -1;
|
||||
} else {
|
||||
|
@ -21,22 +21,19 @@
|
||||
* is that edelib run_program(), at some time, consult evoke
|
||||
* for running programs.
|
||||
*/
|
||||
#define SPAWN_NOT_FOUND 65535 // executable not found
|
||||
#define SPAWN_EMPTY 65534 // given parameter is NULL
|
||||
#define SPAWN_NOT_EXEC 65533 // given parameter is not executable on system
|
||||
#define SPAWN_FORK_FAILED 65532 // internal fork failed
|
||||
#define SPAWN_WAITPID_FAILED 65531 // internal waitpid failed
|
||||
#define SPAWN_EXECVE_FAILED 65530 // internal execve failed
|
||||
#define SPAWN_PTY_FAILED 65529 // TODO
|
||||
#define SPAWN_USER_CANCELED 65528 // TODO
|
||||
#define SPAWN_CRASHED 65527 // executable crashed
|
||||
#define SPAWN_KILLED 65526 // executable crashed
|
||||
#define SPAWN_NOEXITED 65525
|
||||
|
||||
#define SPAWN_OK 0
|
||||
#define SPAWN_FORK_FAILED 1
|
||||
#define SPAWN_EMPTY 2
|
||||
#define SPAWN_EXECVE_FAILED 3
|
||||
|
||||
#define SPAWN_CHILD_CRASHED -2
|
||||
#define SPAWN_CHILD_KILLED -3
|
||||
|
||||
typedef void (SignalWatch)(int pid, int status);
|
||||
|
||||
int spawn_program(const char* cmd, SignalWatch* wf = 0, pid_t* child_pid_ret = 0);
|
||||
int spawn_program_with_core(const char* cmd, SignalWatch* wf = 0, pid_t* child_pid_ret = 0);
|
||||
int spawn_backtrace(const char* program, const char* core_path, const char* output, const char* script);
|
||||
int spawn_backtrace(const char* program, const char* core, const char* output, const char* script);
|
||||
|
||||
#endif
|
||||
|
@ -3,13 +3,13 @@
|
||||
[evoke]
|
||||
Startup = edewm,eiconman,eworkpanel,xscreensaver
|
||||
ImagesDirectory = images
|
||||
# ImagesDirectory = /home/sanel/blentavo/EDE/ede2/evoke/images
|
||||
Splash = splash-alpha1.png
|
||||
#ImagesDirectory = /home/sanel/blentavo/EDE/ede2/evoke/images
|
||||
Splash = splash-alpha1.png
|
||||
|
||||
[edewm]
|
||||
Icon = edewm.png
|
||||
Exec = gvim
|
||||
# Exec = edewm
|
||||
#Exec = edewm
|
||||
Description = window manager
|
||||
|
||||
[eiconman]
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 163 KiB |
Binary file not shown.
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 12 KiB |
Loading…
Reference in New Issue
Block a user