update ./attach

i haven't tested this but i just copy and pasted ./attach-backtrace and put the gdb line from ./attach in it so
This commit is contained in:
no-boot-device 2017-03-25 11:05:18 -05:00 committed by GitHub
parent ab0e04bd95
commit eb3b38f9b8

15
attach
View File

@ -17,21 +17,24 @@ if [ $inst -gt ${#arr[@]} ] || [ $inst == ${#arr[@]} ]; then
exit exit
fi fi
echo Running instances: ${arr[@]} proc=${arr[$inst]}
echo Attaching to ${arr[$1]}
if grep -q $(realpath bin/libcathook.so) /proc/${arr[$1]}/maps; then echo Running instances: ${arr[@]}
echo Attaching to $proc
sudo ./detach $inst bin/libcathook.so
if grep -q $(realpath bin/libcathook.so) /proc/$proc/maps; then
echo already loaded echo already loaded
exit exit
fi fi
echo loading $(realpath bin/libcathook.so) to ${arr[$1]} echo loading $(realpath bin/libcathook.so) to $proc
gdb -n -q -batch \ gdb -n -q -batch \
-ex "attach ${arr[$1]}" \ -ex "attach $proc" \
-ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \ -ex "set \$dlopen = (void*(*)(char*, int)) dlopen" \
-ex "call \$dlopen(\"$(realpath bin/libcathook.so)\", 1)" \ -ex "call \$dlopen(\"$(realpath bin/libcathook.so)\", 1)" \
-ex "call dlerror()" \ -ex "call dlerror()" \
-ex 'print (char *) $2' \ -ex 'print (char *) $2' \
-ex "detach" \ -ex "detach" \
-ex "quit" -ex "quit"