strace the current Oracle session process

Here is my way to trace system calls from the current session process. 
This must not be done in production.
An strace.log file will be generated with system calls

connect / as sysdba
column spid new_value pid
select spid from v$process join v$session on v$session.paddr=v$process.addr where sid=sys_context('userenv','sid');
column spid clear
set escape on
host strace -fy -p &pid -o strace.log \& :
select * from v$osstat;
disconnect

I add ‘:’ at the end of the command when used from sqlcl which adds a ‘;’ at the end of the line:

bash: -c: line 0: syntax error near unexpected token `;'
bash: -c: line 0: `SQLCLTERM=`stty -g 2>/dev/null` ; stty sane 2>/dev/null; export PATH="/media/sf_share/19c:$PATH" && strace -fy -p 5380 -o strace.log &; SQLCLEXIT=$? ; if test "M$SQLCLTERM" != "M" ; then stty "$SQLCLTERM" 2>/dev/null ; fi; exit $SQLCLEXIT'

I use ‘set escape on’ as I use the bash ‘&’ for background in the same command where I use the sqlplus ‘&’ for substitution.

An alternative to SET ESCAPE ON is the following:

define bg=&:
host strace -fy -p &pid -o strace.log &bg

Originally posted on Twitter, but improved here

https://twitter.com/FranckPachot/status/969898128030695424