mirror of
https://github.com/nasa/trick.git
synced 2024-12-24 07:16:41 +00:00
Debugger command on mac is now lldb not gdb
Added a test to set the debugger command to gdb or lldb depending on availability. Created a new script for lldb to run. Modified the script for gdb to backtrace all threads. refs #227
This commit is contained in:
parent
c10d2897f9
commit
c4a5e8b310
@ -1,3 +1,3 @@
|
||||
where
|
||||
thread apply all bt
|
||||
echo \n
|
||||
quit
|
||||
|
2
bin/lldb_commands
Normal file
2
bin/lldb_commands
Normal file
@ -0,0 +1,2 @@
|
||||
bt
|
||||
quit
|
@ -1,6 +1,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "sim_services/Executive/include/Executive.hh"
|
||||
#include "sim_services/Executive/include/Exec_exception.hh"
|
||||
@ -16,7 +17,14 @@ Trick::Executive::Executive() {
|
||||
advance_sim_time_job = NULL ;
|
||||
attach_debugger = false ;
|
||||
curr_job = NULL ;
|
||||
debugger_command = std::string("/usr/bin/gdb") ;
|
||||
|
||||
struct stat st ;
|
||||
if ( stat("/usr/bin/gdb",&st) == 0 ) {
|
||||
debugger_command = std::string("/usr/bin/gdb") ;
|
||||
} else if ( stat("/usr/bin/lldb",&st) == 0 ) {
|
||||
debugger_command = std::string("/usr/bin/lldb") ;
|
||||
}
|
||||
|
||||
enable_freeze = false ;
|
||||
except_return = 0 ;
|
||||
exec_command = NoCmd ;
|
||||
|
@ -58,33 +58,35 @@ void Trick::Executive::signal_handler(int sig) {
|
||||
* Attempt to attach with debugger or print stack trace. Not a requirement.
|
||||
* sprintf and system are not async signal safe, but we don't have anything to lose.
|
||||
*/
|
||||
if ( ! debugger_command.empty() ) {
|
||||
#if __linux
|
||||
char command[1024];
|
||||
if (attach_debugger == true) {
|
||||
sprintf(command, "%s -silent /proc/%d/exe %d", debugger_command.c_str(), getpid(), getpid());
|
||||
system(command);
|
||||
} else if (stack_trace == true ) {
|
||||
sprintf(command, "%s -silent -batch -x ${TRICK_HOME}/bin/gdb_commands "
|
||||
"/proc/%d/exe %d | grep -A 20 \"signal handler\"", debugger_command.c_str(), getpid(), getpid());
|
||||
system(command);
|
||||
}
|
||||
#elif __APPLE__
|
||||
char command[2048];
|
||||
char path[1024] ;
|
||||
uint32_t size = sizeof(path) ;
|
||||
if (_NSGetExecutablePath(path, &size) == 0 ) {
|
||||
char command[1024];
|
||||
if (attach_debugger == true) {
|
||||
write( 2 , "Attempting to attach debugger... standby.\n" , 41 ) ;
|
||||
sprintf(command, "%s -silent %s %d", debugger_command.c_str(), path, getpid());
|
||||
sprintf(command, "%s -silent /proc/%d/exe %d", debugger_command.c_str(), getpid(), getpid());
|
||||
system(command);
|
||||
} else if (stack_trace == true ) {
|
||||
write( 2 , "Attempting to generate stack trace... standby.\n" , 47 ) ;
|
||||
sprintf(command, "%s -batch -x ${TRICK_HOME}/bin/gdb_commands "
|
||||
"%s %d", debugger_command.c_str(), path, getpid());
|
||||
sprintf(command, "%s -silent -batch -x ${TRICK_HOME}/share/trick/gdb_commands "
|
||||
"/proc/%d/exe %d", debugger_command.c_str(), getpid(), getpid());
|
||||
system(command);
|
||||
}
|
||||
}
|
||||
#elif __APPLE__
|
||||
char command[2048];
|
||||
char path[1024] ;
|
||||
uint32_t size = sizeof(path) ;
|
||||
if (_NSGetExecutablePath(path, &size) == 0 ) {
|
||||
if (attach_debugger == true) {
|
||||
write( 2 , "Attempting to attach debugger... standby.\n" , 41 ) ;
|
||||
sprintf(command, "%s -silent %s %d", debugger_command.c_str(), path, getpid());
|
||||
system(command);
|
||||
} else if (stack_trace == true ) {
|
||||
write( 2 , "Attempting to generate stack trace... standby.\n" , 47 ) ;
|
||||
sprintf(command, "%s -batch -s ${TRICK_HOME}/share/trick/lldb_commands -p %d",
|
||||
debugger_command.c_str(), getpid());
|
||||
system(command);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Sim state is unknown, don't return from handler.
|
||||
_exit(sig) ;
|
||||
|
Loading…
Reference in New Issue
Block a user