]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/python/lib/gdb/dap/next.py
x86: ld: sframe: Remove SFrame NULL FRE template
[thirdparty/binutils-gdb.git] / gdb / python / lib / gdb / dap / next.py
CommitLineData
d01e8234 1# Copyright 2022-2025 Free Software Foundation, Inc.
de7d7cb5
TT
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
fc2d72af
TT
16import gdb
17
7729e7c0 18from .events import exec_and_expect_stop
cbaa41b3 19from .server import capability, request
fd09caf4 20from .startup import in_gdb_thread
de7d7cb5
TT
21from .state import set_thread
22
23
fc2d72af
TT
24# Helper function to set the current thread and the scheduler-locking
25# mode. Returns True if scheduler-locking was successfully set to
91c7233d
TT
26# 'on', False in all other cases, including error. When SELECT is
27# True, also select that thread's newest frame.
fc2d72af 28@in_gdb_thread
91c7233d 29def _handle_thread_step(thread_id, single_thread, select=False):
de7d7cb5 30 # Ensure we're going to step the correct thread.
fc2d72af
TT
31 set_thread(thread_id)
32 if single_thread:
33 result = True
34 arg = "on"
35 else:
36 result = False
37 arg = "off"
38 try:
39 # This can fail, depending on the target, so catch the error
40 # and report to our caller. We can't use exec_and_log because
41 # that does not propagate exceptions.
42 gdb.execute("set scheduler-locking " + arg, from_tty=True, to_string=True)
43 except gdb.error:
44 result = False
91c7233d
TT
45 # Other DAP code may select a frame, and the "finish" command uses
46 # the selected frame.
47 if select:
48 gdb.newest_frame().select()
fc2d72af 49 return result
de7d7cb5
TT
50
51
c98921b2 52@request("next", response=False)
51058658
TT
53def next(
54 *, threadId: int, singleThread: bool = False, granularity: str = "statement", **args
55):
c98921b2 56 _handle_thread_step(threadId, singleThread)
de7d7cb5
TT
57 cmd = "next"
58 if granularity == "instruction":
59 cmd += "i"
7729e7c0 60 exec_and_expect_stop(cmd)
de7d7cb5
TT
61
62
63@capability("supportsSteppingGranularity")
fc2d72af 64@capability("supportsSingleThreadExecutionRequests")
c98921b2 65@request("stepIn", response=False)
51058658
TT
66def step_in(
67 *, threadId: int, singleThread: bool = False, granularity: str = "statement", **args
68):
c98921b2 69 _handle_thread_step(threadId, singleThread)
de7d7cb5
TT
70 cmd = "step"
71 if granularity == "instruction":
72 cmd += "i"
7729e7c0 73 exec_and_expect_stop(cmd)
de7d7cb5
TT
74
75
cbaa41b3 76@request("stepOut")
d2266b23 77def step_out(*, threadId: int, singleThread: bool = False, **args):
c98921b2 78 _handle_thread_step(threadId, singleThread, True)
61e60869 79 exec_and_expect_stop("finish &", propagate_exception=True)
3eb64586
TT
80
81
cbaa41b3 82@request("continue")
51058658 83def continue_request(*, threadId: int, singleThread: bool = False, **args):
cbaa41b3
TT
84 locked = _handle_thread_step(threadId, singleThread)
85 exec_and_expect_stop("continue &")
fc2d72af 86 return {"allThreadsContinued": not locked}