]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/python/lib/gdb/dap/next.py
Initial implementation of Debugger Adapter Protocol
[thirdparty/binutils-gdb.git] / gdb / python / lib / gdb / dap / next.py
1 # Copyright 2022 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
12 #
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16 from .events import StopKinds, ExecutionInvoker
17 from .server import capability, request
18 from .startup import send_gdb
19 from .state import set_thread
20
21
22 # Helper function to set the current thread.
23 def _handle_thread_step(threadId):
24 # Ensure we're going to step the correct thread.
25 send_gdb(lambda: set_thread(threadId))
26
27
28 @request("next")
29 def next(*, threadId, granularity="statement", **args):
30 _handle_thread_step(threadId)
31 cmd = "next"
32 if granularity == "instruction":
33 cmd += "i"
34 send_gdb(ExecutionInvoker(cmd, StopKinds.STEP))
35
36
37 @capability("supportsSteppingGranularity")
38 @request("stepIn")
39 def stepIn(*, threadId, granularity="statement", **args):
40 _handle_thread_step(threadId)
41 cmd = "step"
42 if granularity == "instruction":
43 cmd += "i"
44 send_gdb(ExecutionInvoker(cmd, StopKinds.STEP))
45
46
47 @request("continue")
48 def continue_request(**args):
49 send_gdb(ExecutionInvoker("continue", None))
50 # FIXME Just ignore threadId for the time being, and assume all-stop.
51 return {"allThreadsContinued": True}