Skip to content

Commit

Permalink
pass arbitrary gdb arguments directly to gdb (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
cs01 committed Jul 15, 2018
1 parent 1297a2a commit 249f354
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
20 changes: 13 additions & 7 deletions gdbgui/backend.py
Expand Up @@ -28,6 +28,7 @@
from pygments.lexers import get_lexer_for_filename
from pygdbmi.gdbcontroller import NoGdbProcessError
import signal
import shlex
import sys
import socket
import traceback
Expand Down Expand Up @@ -785,21 +786,26 @@ def main():
"""Entry point from command line"""
parser = argparse.ArgumentParser(description=__doc__)

gdb_group = parser.add_argument_group(title="gdb commands")
gdb_group = parser.add_argument_group(title="gdb settings")
args_group = parser.add_mutually_exclusive_group()
network = parser.add_argument_group(title="gdbgui network settings")
security = parser.add_argument_group(title="security settings")
other = parser.add_argument_group(title="other settings")

gdb_group.add_argument(
"-x", "--gdb-cmd-file", help="Execute GDB commands from file."
)
gdb_group.add_argument(
"-g",
"--gdb",
help="Path to debugger. Default: %s" % DEFAULT_GDB_EXECUTABLE,
default=DEFAULT_GDB_EXECUTABLE,
)
gdb_group.add_argument(
"--gdb-args",
help=(
"Arguments passed directly to gdb when gdb is invoked. "
'For example,--gdb-args="--nx --tty=/dev/ttys002"'
),
default=""
)
gdb_group.add_argument(
"--rr",
action="store_true",
Expand All @@ -809,7 +815,6 @@ def main():
"i.e. gdbgui /recorded/dir --rr. See http://rr-project.org/."
),
)

network.add_argument(
"-p",
"--port",
Expand Down Expand Up @@ -920,9 +925,9 @@ def main():
exit(1)

app.config["initial_binary_and_args"] = cmd
app.config["gdb_args"] = shlex.split(args.gdb_args)
app.config["rr"] = args.rr
app.config["gdb_path"] = args.gdb
app.config["gdb_cmd_file"] = args.gdb_cmd_file
app.config["show_gdbgui_upgrades"] = not args.hide_gdbgui_upgrades
app.config["gdbgui_auth_user_credentials"] = get_gdbgui_auth_user_credentials(
args.auth_file, args.user, args.password
Expand All @@ -939,7 +944,8 @@ def main():
args.no_browser = True
if app.config["gdbgui_auth_user_credentials"] is None:
print(
"Warning: authentication is recommended when serving on a publicly accessible IP address. See gdbgui --help."
"Warning: authentication is recommended when serving on a publicly "
"accessible IP address. See gdbgui --help."
)

if args.debug:
Expand Down
5 changes: 1 addition & 4 deletions gdbgui/statemanager.py
Expand Up @@ -53,7 +53,7 @@ def connect_client(self, client_id, desired_gdbpid):
logger.info("new sid", client_id)

gdb_args = (
deepcopy(self.config["initial_binary_and_args"]) + REQUIRED_GDB_FLAGS
deepcopy(self.config["initial_binary_and_args"]) + deepcopy(self.config["gdb_args"]) + REQUIRED_GDB_FLAGS
)

if startup_with_shell_off:
Expand All @@ -62,9 +62,6 @@ def connect_client(self, client_id, desired_gdbpid):
# http://stackoverflow.com/questions/39702871/gdb-kind-of-doesnt-work-on-macos-sierra
gdb_args.append("--init-eval-command=set startup-with-shell off")

if self.config["gdb_cmd_file"]:
gdb_args.append("-x=%s" % self.config["gdb_cmd_file"])

controller = GdbController(
gdb_path=self.config["gdb_path"],
gdb_args=gdb_args,
Expand Down

0 comments on commit 249f354

Please sign in to comment.