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.
pwndbg/tests/common.py

32 lines
740 B
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
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)