diff options
author | Tom Tromey <tromey@adacore.com> | 2023-05-16 09:51:51 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2023-06-12 12:10:10 -0600 |
commit | ad9cdfbcfdf9c7a679393d35adaf95e2b3cb6fd0 (patch) | |
tree | 4f1d81aded77693e686bf3969b8af972bdc3c1b5 /gdb/python | |
parent | 67efac36f17824b147b3d4645719404ccd662206 (diff) | |
download | gdb-ad9cdfbcfdf9c7a679393d35adaf95e2b3cb6fd0.zip gdb-ad9cdfbcfdf9c7a679393d35adaf95e2b3cb6fd0.tar.gz gdb-ad9cdfbcfdf9c7a679393d35adaf95e2b3cb6fd0.tar.bz2 |
Add "stop at main" extension to DAP launch request
Co-workers who work on a program that uses DAP asked for the ability
to have gdb stop at the main subprogram when launching. This patch
implements this extension.
Reviewed-By: Eli Zaretskii <eliz@gnu.org>
Diffstat (limited to 'gdb/python')
-rw-r--r-- | gdb/python/lib/gdb/dap/launch.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/gdb/python/lib/gdb/dap/launch.py b/gdb/python/lib/gdb/dap/launch.py index 2fec326..aee8c2f 100644 --- a/gdb/python/lib/gdb/dap/launch.py +++ b/gdb/python/lib/gdb/dap/launch.py @@ -20,7 +20,7 @@ from typing import Mapping, Optional, Sequence from .events import ExecutionInvoker from .server import request, capability -from .startup import send_gdb, send_gdb_with_response, in_gdb_thread +from .startup import send_gdb, send_gdb_with_response, in_gdb_thread, exec_and_log _program = None @@ -36,6 +36,14 @@ def _set_args_env(args, env): inf.set_env(name, value) +@in_gdb_thread +def _break_at_main(): + inf = gdb.selected_inferior() + main = inf.main_name + if main is not None: + exec_and_log("tbreak " + main) + + # Any parameters here are necessarily extensions -- DAP requires this # from implementations. Any additions or changes here should be # documented in the gdb manual. @@ -45,12 +53,15 @@ def launch( program: Optional[str] = None, args: Sequence[str] = (), env: Optional[Mapping[str, str]] = None, + stopAtBeginningOfMainSubprogram: bool = False, **extra, ): if program is not None: global _program _program = program send_gdb(f"file {_program}") + if stopAtBeginningOfMainSubprogram: + send_gdb(_break_at_main) if len(args) > 0 or env is not None: send_gdb(lambda: _set_args_env(args, env)) |