mirror of https://github.com/pwndbg/pwndbg.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
694 B
Python
30 lines
694 B
Python
from __future__ import unicode_literals
|
|
|
|
import subprocess
|
|
import tempfile
|
|
import unittest
|
|
|
|
|
|
def pywrite(data):
|
|
return write(data, suffix='.py')
|
|
|
|
def write(data, suffix=''):
|
|
t = tempfile.NamedTemporaryFile(delete=False, suffix=suffix)
|
|
t.write(data.encode('utf-8'))
|
|
return t
|
|
|
|
def run_gdb_with_script(pybefore='', pyafter=''):
|
|
command = ['gdb','--silent','--nx','--nh']
|
|
|
|
if pybefore:
|
|
command += ['--command', pywrite(pybefore).name]
|
|
|
|
command += ['--command', 'gdbinit.py']
|
|
|
|
if pyafter:
|
|
command += ['--command', pywrite(pyafter).name]
|
|
|
|
command += ['--eval-command', 'quit']
|
|
|
|
return subprocess.check_output(command, stderr=subprocess.STDOUT)
|