Commit 808274cb authored by Pavel Vainerman's avatar Pavel Vainerman

(UniSetActivator): добавил возможность указать скрипт (или программу),

вызываемый при SIGSEGV или SIGABORT.
parent fd8b5280
#!/bin/sh
gdb --batch -n -ex "thread apply all bt" $1 $2
# | ssh xxxxxx
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
START=uniset2-start.sh START=uniset2-start.sh
${START} -f ./smemory-test --confile ./test.xml --dlog-add-levels level1 --localNode LocalhostNode \ ${START} -f ./smemory-test --confile ./test.xml --dlog-add-levels level1 --localNode LocalhostNode \
--sm-log-add-levels any $* --sm-run-logserver --TestProc1-run-logserver --sm-log-add-levels any $* --sm-run-logserver --TestProc1-run-logserver --uniset-abort-script ./abort-script-example.sh
#--ulog-add-levels crit,warn,info #--ulog-add-levels crit,warn,info
#system,level2,level8,level9 #system,level2,level8,level9
...@@ -47,6 +47,7 @@ typedef std::shared_ptr<UniSetActivator> UniSetActivatorPtr; ...@@ -47,6 +47,7 @@ typedef std::shared_ptr<UniSetActivator> UniSetActivatorPtr;
* Активатор в свою очередь сам является менеджером(и объектом) и обладает всеми его свойствами * Активатор в свою очередь сам является менеджером(и объектом) и обладает всеми его свойствами
* *
* --uniset-no-use-gdb-for-stacktrace - НЕ ИСПОЛЬЗОВАТЬ gdb для stacktrace * --uniset-no-use-gdb-for-stacktrace - НЕ ИСПОЛЬЗОВАТЬ gdb для stacktrace
* --uniset-abort-script - скрипт запускаемый при вылете, в качестве аргумента передаётся имя программы и pid
*/ */
class UniSetActivator: class UniSetActivator:
public UniSetManager public UniSetManager
...@@ -80,6 +81,11 @@ class UniSetActivator: ...@@ -80,6 +81,11 @@ class UniSetActivator:
return _noUseGdbForStackTrace; return _noUseGdbForStackTrace;
} }
inline const std::string getAbortScript()
{
return abortScript;
}
protected: protected:
virtual void work(); virtual void work();
...@@ -117,6 +123,8 @@ class UniSetActivator: ...@@ -117,6 +123,8 @@ class UniSetActivator:
pid_t thpid; // pid orb потока pid_t thpid; // pid orb потока
bool _noUseGdbForStackTrace = { false }; bool _noUseGdbForStackTrace = { false };
std::string abortScript = { "" }; // скрипт вызываемый при прерывании программы (SIGSEGV,SIGABRT)
}; };
//---------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------
#endif #endif
......
...@@ -266,9 +266,17 @@ bool gdb_print_trace() ...@@ -266,9 +266,17 @@ bool gdb_print_trace()
dup2(fileno(stdout), fileno(stderr)); dup2(fileno(stdout), fileno(stderr));
TRACELOG << "stack trace for " << name_buf << " pid=" << pid_buf << endl; TRACELOG << "stack trace for " << name_buf << " pid=" << pid_buf << endl;
// приходится выводить информацию по всем потокам, т.к. мы не знаем в каком сработал сигнал if( g_act && !g_act->getAbortScript().empty() )
// его надо смотреть по выводу "<signal handler called>" {
execlp("gdb", "gdb", "--batch", "-n", "-ex", "thread apply all bt", name_buf, pid_buf, NULL); TRACELOG << "run abort script " << g_act->getAbortScript() << endl;
execlp(g_act->getAbortScript().c_str(), g_act->getAbortScript().c_str(), name_buf, pid_buf, NULL);
}
else
{
// приходится выводить информацию по всем потокам, т.к. мы не знаем в каком сработал сигнал
// его надо смотреть по выводу "<signal handler called>"
execlp("gdb", "gdb", "--batch", "-n", "-ex", "thread apply all bt", name_buf, pid_buf, NULL);
}
//abort(); /* If gdb failed to start */ //abort(); /* If gdb failed to start */
return false; return false;
...@@ -534,6 +542,8 @@ void UniSetActivator::init() ...@@ -534,6 +542,8 @@ void UniSetActivator::init()
_noUseGdbForStackTrace = ( findArgParam("--uniset-no-use-gdb-for-stacktrace", conf->getArgc(), conf->getArgv()) != -1 ); _noUseGdbForStackTrace = ( findArgParam("--uniset-no-use-gdb-for-stacktrace", conf->getArgc(), conf->getArgv()) != -1 );
abortScript = conf->getArgParam("--uniset-abort-script","");
orb = conf->getORB(); orb = conf->getORB();
CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment