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:
Alex Lin 2016-04-20 14:23:16 -05:00
parent c10d2897f9
commit c4a5e8b310
4 changed files with 34 additions and 22 deletions

View File

@ -1,3 +1,3 @@
where
thread apply all bt
echo \n
quit

2
bin/lldb_commands Normal file
View File

@ -0,0 +1,2 @@
bt
quit

View File

@ -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 ;
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 ;

View File

@ -58,14 +58,15 @@ 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());
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__
@ -79,12 +80,13 @@ void Trick::Executive::signal_handler(int sig) {
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 -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) ;