mirror of https://github.com/pwndbg/pwndbg.git
feature(profile): use a simple module based approach to define profiles
parent
fbfd47f770
commit
f1aa0c8f5c
@ -0,0 +1,9 @@
|
|||||||
|
import pwndbg.commands.context
|
||||||
|
|
||||||
|
|
||||||
|
def warmup():
|
||||||
|
pwndbg.commands.context.context()
|
||||||
|
|
||||||
|
|
||||||
|
def run():
|
||||||
|
pwndbg.commands.context.context()
|
||||||
@ -1,21 +1,39 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
if ! (( $# )); then
|
||||||
|
cat <<- _EOF_
|
||||||
|
$0: [profile-script]
|
||||||
|
|
||||||
|
Example: $0 context.py
|
||||||
|
_EOF_
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
module=$(basename "${1/.py/}")
|
||||||
|
basedir=$(dirname "$0")
|
||||||
|
|
||||||
# Quick and dirty script to profile pwndbg using cProfile.
|
# Quick and dirty script to profile pwndbg using cProfile.
|
||||||
make test > /dev/null
|
make -C "${basedir}" test > /dev/null
|
||||||
git log --abbrev-commit --pretty=oneline HEAD^..HEAD
|
|
||||||
# To profile first run, remove -ex "context".
|
gdb "${basedir}/test" \
|
||||||
gdb ./test \
|
-ex "source ${basedir}/../gdbinit.py" \
|
||||||
-ex "source ../gdbinit.py" \
|
-ex "b main" \
|
||||||
-ex "b main" -ex "r" \
|
-ex "r" \
|
||||||
-ex "context" \
|
-ex "python
|
||||||
-ex "python import cProfile; cProfile.run('pwndbg.commands.context.context()', 'stats')" \
|
import cProfile;
|
||||||
-ex "quit"
|
import profiling.${module} as profile;
|
||||||
|
profile.warmup();
|
||||||
|
cProfile.run('profile.run()', '${basedir}/stats')" \
|
||||||
|
-ex "quit"
|
||||||
|
|
||||||
python3 -c "
|
python3 -c "
|
||||||
import pstats
|
import pstats
|
||||||
p = pstats.Stats('stats')
|
p = pstats.Stats('${basedir}/stats')
|
||||||
p.strip_dirs().sort_stats('tottime').print_stats(20)
|
p.strip_dirs().sort_stats('tottime').print_stats(20)
|
||||||
"
|
"
|
||||||
|
|
||||||
if command -v pyprof2calltree >/dev/null 2>&1 && command -v kcachegrind >/dev/null 2>&1; then
|
if command -v pyprof2calltree >/dev/null 2>&1 && command -v kcachegrind >/dev/null 2>&1; then
|
||||||
pyprof2calltree -k -i stats
|
pyprof2calltree -k -i "${basedir}/stats"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# vim: ts=4 sw=4 noet
|
||||||
|
|||||||
Loading…
Reference in new issue