Skip to content

Commit

Permalink
set inferior process to debug from command line
Browse files Browse the repository at this point in the history
  • Loading branch information
Chad Smith committed Feb 7, 2017
1 parent edc993d commit 6e41929
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
8 changes: 7 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ A browser-based frontend/gui for GDB
.. image:: https://travis-ci.org/cs01/gdbgui.svg?branch=master
:target: https://travis-ci.org/cs01/gdbgui

.. image:: https://img.shields.io/badge/pypi-v0.7.3.3-blue.svg
.. image:: https://img.shields.io/badge/pypi-v0.7.3.4-blue.svg
:target: https://pypi.python.org/pypi/gdbgui/

.. image:: https://img.shields.io/badge/python-2.7, 3.3, 3.4, 3.5, pypy-blue.svg
Expand Down Expand Up @@ -40,6 +40,12 @@ Run

A new tab in your browser will open with gdbgui in it.

To immediately set the inferior binary and arguments and have them load when the page is loaded

::

gdbgui --cmd '/path/to/binary -arg myaarg -flag'

Help
~~~~

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Release v\ |version|
.. image:: https://travis-ci.org/cs01/gdbgui.svg?branch=master
:target: https://travis-ci.org/cs01/gdbgui

.. image:: https://img.shields.io/badge/pypi-v0.7.3.3-blue.svg
.. image:: https://img.shields.io/badge/pypi-v0.7.3.4-blue.svg
:target: https://pypi.python.org/pypi/gdbgui/

.. image:: https://img.shields.io/badge/python-2.7, 3.3, 3.4, 3.5, pypy-blue.svg
Expand Down
2 changes: 1 addition & 1 deletion gdbgui/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__title__ = 'gdbgui'
__version__ = '0.7.3.3'
__version__ = '0.7.3.4'
__author__ = 'Chad Smith'
__copyright__ = 'Copyright Chad Smith'
13 changes: 11 additions & 2 deletions gdbgui/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
DEFAULT_PORT = 5000
DEFAULT_GDB_EXECUTABLE = 'gdb'
IS_A_TTY = sys.stdout.isatty()

INITIAL_BINARY_AND_ARGS = None # global

app = Flask(__name__, template_folder=TEMPLATE_DIR, static_folder=STATIC_DIR)
socketio = SocketIO(async_mode='eventlet')
Expand Down Expand Up @@ -134,7 +134,11 @@ def gdbgui():
time_sec = 0
else:
time_sec = int((datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds())
return render_template('gdbgui.jade', timetag_to_prevent_caching=time_sec, debug=json.dumps(app.debug), gdbgui_version=__version__)
return render_template('gdbgui.jade',
timetag_to_prevent_caching=time_sec,
debug=json.dumps(app.debug),
gdbgui_version=__version__,
initial_binary_and_args=json.dumps(INITIAL_BINARY_AND_ARGS))


@app.route('/shutdown')
Expand Down Expand Up @@ -217,14 +221,19 @@ def setup_backend(serve=True, host=DEFAULT_HOST, port=DEFAULT_PORT, debug=False,

def main():
"""Entry point from command line"""
global INITIAL_BINARY_AND_ARGS
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--port", help='The port on which gdbgui will be hosted', default=DEFAULT_PORT)
parser.add_argument("--host", help='The host ip address on which gdbgui serve. ', default=DEFAULT_HOST)
parser.add_argument("--gdb", help='Path to gdb executable.', default=DEFAULT_GDB_EXECUTABLE)
parser.add_argument("--cmd", help='The binary and arguments to run in gdb. This is a way to script the intial loading of the inferior'
' binary you wish to debug.', default=INITIAL_BINARY_AND_ARGS)
parser.add_argument("--debug", help='The debug flag of this Flask application. '
'Pass this flag when debugging gdbgui itself to automatically reload the server when changes are detected', action='store_true')
parser.add_argument("--no_browser", help='By default, the browser will open with gdb gui. Pass this flag so the browser does not open.', action='store_true')
args = parser.parse_args()

INITIAL_BINARY_AND_ARGS = args.cmd or None
setup_backend(serve=True, host=args.host, port=int(args.port), debug=bool(args.debug), open_browser=(not args.no_browser), gdb_path=args.gdb)


Expand Down
9 changes: 7 additions & 2 deletions gdbgui/static/js/gdbgui.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* the extent that it's possible).
*/

(function ($, _, Awesomplete, io, moment, debug, gdbgui_version) {
(function ($, _, Awesomplete, io, moment, debug, gdbgui_version, initial_binary_and_args) {
"use strict";

/**
Expand Down Expand Up @@ -2322,7 +2322,12 @@ ShutdownGdbgui.init()
WebSocket.init()
Settings.init()

if(_.isString(initial_binary_and_args) && _.trim(initial_binary_and_args).length > 0){
BinaryLoader.el.val(_.trim(initial_binary_and_args))
BinaryLoader.set_target_app()

}

window.addEventListener("beforeunload", BinaryLoader.onclose)

})(jQuery, _, Awesomplete, io, moment, debug, gdbgui_version)
})(jQuery, _, Awesomplete, io, moment, debug, gdbgui_version, initial_binary_and_args)
1 change: 1 addition & 0 deletions gdbgui/templates/gdbgui.jade
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ body(style='margin: 0')
button.btn.btn-success(type='button', data-dismiss='modal') Close

script.
initial_binary_and_args = JSON.parse('!{initial_binary_and_args}')
debug = #{debug}
gdbgui_version = '#{gdbgui_version}'
script(type="text/javascript" src='static/js/gdbgui.js?_=#{timetag_to_prevent_caching}')

0 comments on commit 6e41929

Please sign in to comment.