mirror of
https://github.com/nasa/trick.git
synced 2025-02-20 09:16:20 +00:00
Fix debugger attach when ptrace is restricted
Trick's backtrace or attach functionality fails on systems like Ubuntu where the use of ptrace(2) is restricted. Where it is defined, use the PR_SET_PTRACER prctl with the argument PR_SET_PTRACER_ANY to allow any process to attach.
This commit is contained in:
parent
ba2df0757e
commit
54fe22684a
@ -2,6 +2,9 @@
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <sys/stat.h>
|
||||
#if __linux
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
#include "trick/Executive.hh"
|
||||
#include "trick/ExecutiveException.hh"
|
||||
@ -48,6 +51,13 @@ Trick::Executive::Executive() {
|
||||
software_frame = 1.0;
|
||||
frame_count = 0 ;
|
||||
stack_trace = true ;
|
||||
/** @li (if on new-enough Linux) allow any process to ptrace this one.
|
||||
* This allows stack trace / debugger attach when ptrace is
|
||||
* restricted (e.g. on Ubuntu 16).
|
||||
*/
|
||||
#if defined(PR_SET_PTRACER) && defined(PR_SET_PTRACER_ANY)
|
||||
prctl(PR_SET_PTRACER, PR_SET_PTRACER_ANY);
|
||||
#endif
|
||||
/** @li Assign default terminate time to MAX_LONG_LONG tics. */
|
||||
terminate_time = TRICK_MAX_LONG_LONG - 1;
|
||||
time_last_pass_tics = 0 ;
|
||||
|
Loading…
x
Reference in New Issue
Block a user