Skip to content

Commit 4a66258

Browse files
committed
implement exception breakpoints, stop on entry. extend evaluation to execute keywords
1 parent 5e7434c commit 4a66258

File tree

6 files changed

+271
-57
lines changed

6 files changed

+271
-57
lines changed

robotcode/debug_adapter/launcher/__main__.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ async def run_robot(
120120
output_messages: bool = False,
121121
output_log: bool = False,
122122
group_output: bool = False,
123+
stop_on_entry: bool = False,
123124
) -> Any:
124125
import robot
125126

@@ -128,6 +129,25 @@ async def run_robot(
128129
from ..types import Event
129130
from .debugger import Debugger
130131

132+
@_logger.call
133+
async def start_debugpy_async() -> None:
134+
if debugpy:
135+
port = check_free_port(debugpy_port)
136+
if enable_debugpy(port):
137+
if await asyncio.wrap_future(
138+
asyncio.run_coroutine_threadsafe(
139+
server.protocol.wait_for_client(wait_for_client_timeout), loop=loop
140+
)
141+
):
142+
await asyncio.wrap_future(
143+
asyncio.run_coroutine_threadsafe(
144+
server.protocol.send_event_async(Event(event="debugpyStarted", body={"port": port})),
145+
loop=loop,
146+
)
147+
)
148+
if wait_for_debugpy_client:
149+
wait_for_debugpy_connected()
150+
131151
loop = asyncio.new_event_loop()
132152

133153
thread = threading.Thread(name="RobotCode Debug Launcher", target=run_server, args=(port, loop))
@@ -140,28 +160,8 @@ async def run_robot(
140160
if wait_for_client:
141161
try:
142162

143-
@_logger.call
144-
async def start_debugpy_async() -> None:
145-
if debugpy:
146-
port = check_free_port(debugpy_port)
147-
if enable_debugpy(port):
148-
if await asyncio.wrap_future(
149-
asyncio.run_coroutine_threadsafe(
150-
server.protocol.wait_for_client(wait_for_client_timeout), loop=loop
151-
)
152-
):
153-
await asyncio.wrap_future(
154-
asyncio.run_coroutine_threadsafe(
155-
server.protocol.send_event_async(
156-
Event(event="debugpyStarted", body={"port": port})
157-
),
158-
loop=loop,
159-
)
160-
)
161-
wait_for_debugpy_connected()
162-
163163
await asyncio.gather(
164-
start_debugpy_async(),
164+
# start_debugpy_async(),
165165
asyncio.wrap_future(
166166
asyncio.run_coroutine_threadsafe(
167167
server.protocol.wait_for_client(wait_for_client_timeout), loop=loop
@@ -186,23 +186,23 @@ async def start_debugpy_async() -> None:
186186
except asyncio.TimeoutError:
187187
raise ConnectionError("Timeout to get configuration from client.")
188188

189+
await start_debugpy_async()
190+
189191
args = [
190192
"--listener",
191193
f"robotcode.debug_adapter.launcher.listeners.ListenerV2:no_debug={repr(no_debug)}",
192194
*args,
193195
]
194196

197+
Debugger.instance().stop_on_entry = stop_on_entry
195198
Debugger.instance().output_messages = output_messages
196199
Debugger.instance().output_log = output_log
197200
Debugger.instance().group_output = group_output
198201

199202
Debugger.instance().set_main_thread(threading.current_thread())
200203
Debugger.instance().start()
201204

202-
exit_code = robot.run_cli(
203-
args,
204-
False,
205-
)
205+
exit_code = robot.run_cli(args, False)
206206

207207
if server.protocol.connected:
208208
await asyncio.wrap_future(
@@ -327,6 +327,7 @@ def main() -> None:
327327
parser.add_argument(
328328
"-og", "--group-output", action="store_true", help="Fold messages/log from robotframework to client."
329329
)
330+
parser.add_argument("-soe", "--stop-on-entry", action="store_true", help="Stops on entry.")
330331

331332
sys_args = sys.argv[1:]
332333

@@ -406,6 +407,7 @@ def main() -> None:
406407
args.output_messages,
407408
args.output_log,
408409
args.group_output,
410+
args.stop_on_entry,
409411
)
410412
)
411413

0 commit comments

Comments
 (0)