Browse files

add bugreport cmd (#533)

* add bugreport cmd

* add newline, fix imports ordering

* fix stuff in bugreport

* add info about bugreport to exception handler

* open browser with body

* isort fix

* bugreport change arg name

* Update
  • Loading branch information...
GrosQuildu authored and disconnect3d committed Sep 30, 2018
1 parent 2f36260 commit b847f1d384ed9a4ea07e08c3c61ac1d80ad7644c
Showing with 132 additions and 8 deletions.
  1. +128 −6 pwndbg/commands/
  2. +4 −2 pwndbg/
@@ -9,7 +9,11 @@
from __future__ import print_function
from __future__ import unicode_literals
import argparse
import os
import sys
from platform import platform
from subprocess import check_output
import gdb
@@ -18,6 +22,11 @@
import pwndbg.ida
from pwndbg.color import message
from urllib import quote
from urllib.parse import quote
def _gdb_version():
@@ -46,11 +55,7 @@ def unicorn_version():
return 'not found'
def version():
Displays gdb, python and pwndbg versions.
def all_versions():
gdb_str = 'Gdb: %s' % _gdb_version()
py_str = 'Python: %s' % _py_version()
pwndbg_str = 'Pwndbg: %s' % pwndbg.__version__
@@ -67,5 +72,122 @@ def version():
ida_py_ver = 'IDA Py: %s' % ida_versions['python']
ida_hr_ver = 'Hexrays: %s' % ida_versions['hexrays']
all_versions += (ida_version, ida_py_ver, ida_hr_ver)
return all_versions
def version():
Displays gdb, python and pwndbg versions.
print('\n'.join(map(message.system, all_versions())))
bugreport_parser = argparse.ArgumentParser(description='''
Generate bugreport
bugreport_parser.add_argument('--run-browser', '-b', action='store_true', help='Open browser on github/issues/new')
def bugreport(run_browser=False):
Before reporting a new issue, make sure that we do not have any duplicates already open.
If there is one it might be good to take part in the discussion there.
Please make sure you have checked that the issue persists on LATEST pwndbg version.
Below is a template for BUG REPORTS.
Don't include it if this is a FEATURE REQUEST.
### Description
Briefly describe the problem you are having in a few paragraphs.
### Steps to reproduce
What do we have to do to reproduce the problem?
If this is connected to particular C/asm code,
please provide the smallest C code that reproduces the issue.
Gdb session history:
### My setup
Show us your gdb/python/pwndbg/OS/IDA Pro version (depending on your case).
NOTE: We are currently supporting only Ubuntu installations.
It is known that pwndbg is not fully working e.g. on Arch Linux (the heap stuff is not working there).
If you would like to change this situation - help us improving pwndbg and supporting other distros!
This can be displayed in pwndbg through `version` command.
If it is somehow unavailable, use:
* `show version` - for gdb
* `py import sys; print(sys.version)` - for python
* pwndbg version/git commit id
gdb_config = gdb.execute('show configuration', to_string=True).split('\n')
all_info = all_versions()
current_setup = 'Platform: %s\n' % platform()
current_setup += '\n'.join(all_info)
current_setup += '\n' + '\n'.join(gdb_config)
# get saved history size (not including current gdb session)
gdb_history_file = gdb.execute('show history filename', to_string=True)
gdb_history_file = gdb_history_file[gdb_history_file.index('"')+1:gdb_history_file.rindex('"')]
gdb_history_len = 0
with open(gdb_history_file, 'r') as f:
gdb_history_len = len(f.readlines())
except FileNotFoundError:
max_command_no = int(gdb.execute('show commands', to_string=True).split('\n')[-2].split()[0]) - 1
show_command_size = 10 # 'show command' returns 10 commands
gdb_current_session_history = {}
current_command_no = gdb_history_len + 1
while current_command_no <= max_command_no:
cmds = gdb.execute('show commands ' + str(current_command_no + (show_command_size//2)+1), to_string=True).split('\n')[:-1]
for cmd in cmds:
cmd_no, cmd = cmd.split(maxsplit=1)
cmd_no = int(cmd_no)
if cmd_no <= gdb_history_len:
if current_command_no > max_command_no:
gdb_current_session_history[cmd_no] = cmd
current_command_no += 1
gdb_current_session_history = (v for (k, v) in sorted(gdb_current_session_history.items()))
gdb_current_session_history = '\n'.join(gdb_current_session_history)
issue_bugreport = ISSUE_TEMPLATE.format(gdb_history=gdb_current_session_history, setup=current_setup)
please_please_submit = 'Please submit the bugreport generated above at '
github_issue_url = ''
github_issue_body = '?body=' + quote(issue_bugreport)
if run_browser:
check_output(['xdg-open', github_issue_url + github_issue_body])
print(please_please_submit + github_issue_url)
print(please_please_submit + github_issue_url)
print('\n'.join(map(message.system, all_versions)))
@@ -33,9 +33,11 @@ def inform_report_issue(exception_msg):
The use of `memoize` makes it reporting only once for a given exception message.
'If that is an issue, you can report it on\n'
"If that is an issue, you can report it on\n"
"(Please don't forget to search if it hasn't been reported before)\n"
"PS: Pull requests are welcome")
"To generate the report and open a browser, you may run ") +
message.hint("`bugreport --run-browser`") +
message.notice("\nPS: Pull requests are welcome")

0 comments on commit b847f1d

Please sign in to comment.