robotcode-debugger 0.108.1__tar.gz → 0.109.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/PKG-INFO +3 -3
  2. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/pyproject.toml +2 -2
  3. robotcode_debugger-0.109.1/src/robotcode/debugger/__version__.py +1 -0
  4. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/debugger.py +47 -36
  5. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/run.py +10 -9
  6. robotcode_debugger-0.108.1/src/robotcode/debugger/__version__.py +0 -1
  7. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/.gitignore +0 -0
  8. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/LICENSE.txt +0 -0
  9. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/README.md +0 -0
  10. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/__init__.py +0 -0
  11. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/cli.py +0 -0
  12. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/dap_types.py +0 -0
  13. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/default_capabilities.py +0 -0
  14. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/hooks.py +0 -0
  15. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/id_manager.py +0 -0
  16. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/launcher/__init__.py +0 -0
  17. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/launcher/cli.py +0 -0
  18. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/launcher/client.py +0 -0
  19. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/launcher/run.py +0 -0
  20. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/launcher/server.py +0 -0
  21. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/listeners.py +0 -0
  22. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/protocol.py +0 -0
  23. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/py.typed +0 -0
  24. {robotcode_debugger-0.108.1 → robotcode_debugger-0.109.1}/src/robotcode/debugger/server.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: robotcode-debugger
3
- Version: 0.108.1
3
+ Version: 0.109.1
4
4
  Summary: RobotCode Debugger for Robot Framework
5
5
  Project-URL: Homepage, https://robotcode.io
6
6
  Project-URL: Donate, https://opencollective.com/robotcode
@@ -25,8 +25,8 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
25
25
  Classifier: Topic :: Utilities
26
26
  Classifier: Typing :: Typed
27
27
  Requires-Python: >=3.8
28
- Requires-Dist: robotcode-jsonrpc2==0.108.1
29
- Requires-Dist: robotcode-runner==0.108.1
28
+ Requires-Dist: robotcode-jsonrpc2==0.109.1
29
+ Requires-Dist: robotcode-runner==0.109.1
30
30
  Requires-Dist: robotframework>=4.1.0
31
31
  Provides-Extra: debugpy
32
32
  Requires-Dist: debugpy; extra == 'debugpy'
@@ -28,8 +28,8 @@ classifiers = [
28
28
  dynamic = ["version"]
29
29
  dependencies = [
30
30
  "robotframework>=4.1.0",
31
- "robotcode-jsonrpc2==0.108.1",
32
- "robotcode-runner==0.108.1",
31
+ "robotcode-jsonrpc2==0.109.1",
32
+ "robotcode-runner==0.109.1",
33
33
  ]
34
34
 
35
35
  [project.optional-dependencies]
@@ -0,0 +1 @@
1
+ __version__ = "0.109.1"
@@ -162,8 +162,11 @@ class StackTraceResult(NamedTuple):
162
162
 
163
163
 
164
164
  class InvalidThreadIdError(Exception):
165
- def __init__(self, thread_id: Any) -> None:
166
- super().__init__(f"Invalid thread id {thread_id}")
165
+ def __init__(self, current_thread_id: Any, expected_thread_id: Any = None) -> None:
166
+ super().__init__(
167
+ f"Invalid thread id {current_thread_id}"
168
+ + (f", expected {expected_thread_id}" if expected_thread_id is not None else "")
169
+ )
167
170
 
168
171
 
169
172
  class MarkerObject:
@@ -429,12 +432,12 @@ class Debugger:
429
432
  with self.condition:
430
433
  self.state = State.Stopped
431
434
 
432
- if self.main_thread is not None and self.main_thread.ident:
435
+ if self.main_thread_is_alive:
433
436
  self.send_event(
434
437
  self,
435
438
  ContinuedEvent(
436
439
  body=ContinuedEventBody(
437
- thread_id=self.main_thread.ident,
440
+ thread_id=self.main_thread_id,
438
441
  all_threads_continued=True,
439
442
  )
440
443
  ),
@@ -442,22 +445,24 @@ class Debugger:
442
445
 
443
446
  self.condition.notify_all()
444
447
 
448
+ def check_thread_id(self, thread_id: int) -> None:
449
+ if not self.main_thread_is_alive and thread_id != self.main_thread_id:
450
+ raise InvalidThreadIdError(thread_id, self.main_thread_id)
451
+
445
452
  def continue_all(self) -> None:
446
- if self.main_thread is not None and self.main_thread.ident is not None:
447
- self.continue_thread(self.main_thread.ident)
453
+ if self.main_thread_is_alive:
454
+ self.continue_thread(self.main_thread_id)
448
455
 
449
456
  def continue_thread(self, thread_id: int) -> None:
450
- if self.main_thread is None or thread_id != self.main_thread.ident:
451
- raise InvalidThreadIdError(thread_id)
457
+ self.check_thread_id(thread_id)
452
458
 
453
459
  with self.condition:
454
460
  self.requested_state = RequestedState.Running
455
461
  self.condition.notify_all()
456
462
 
457
463
  def pause_thread(self, thread_id: int) -> None:
458
- # thread_id 0 means all threads
459
- if self.main_thread is None or (thread_id != 0 and thread_id != self.main_thread.ident):
460
- raise InvalidThreadIdError(thread_id)
464
+ if thread_id != 0:
465
+ self.check_thread_id(thread_id)
461
466
 
462
467
  with self.condition:
463
468
  self.requested_state = RequestedState.Pause
@@ -465,8 +470,7 @@ class Debugger:
465
470
  self.condition.notify_all()
466
471
 
467
472
  def next(self, thread_id: int, granularity: Optional[SteppingGranularity] = None) -> None:
468
- if self.main_thread is None or thread_id != self.main_thread.ident:
469
- raise InvalidThreadIdError(thread_id)
473
+ self.check_thread_id(thread_id)
470
474
 
471
475
  with self.condition:
472
476
  if self.full_stack_frames and self.full_stack_frames[0].type in [
@@ -500,8 +504,7 @@ class Debugger:
500
504
  target_id: Optional[int] = None,
501
505
  granularity: Optional[SteppingGranularity] = None,
502
506
  ) -> None:
503
- if self.main_thread is None or thread_id != self.main_thread.ident:
504
- raise InvalidThreadIdError(thread_id)
507
+ self.check_thread_id(thread_id)
505
508
 
506
509
  with self.condition:
507
510
  self.requested_state = RequestedState.StepIn
@@ -509,8 +512,7 @@ class Debugger:
509
512
  self.condition.notify_all()
510
513
 
511
514
  def step_out(self, thread_id: int, granularity: Optional[SteppingGranularity] = None) -> None:
512
- if self.main_thread is None or thread_id != self.main_thread.ident:
513
- raise InvalidThreadIdError(thread_id)
515
+ self.check_thread_id(thread_id)
514
516
 
515
517
  with self.condition:
516
518
  self.requested_state = RequestedState.StepOut
@@ -589,7 +591,7 @@ class Debugger:
589
591
  body=StoppedEventBody(
590
592
  description="Paused",
591
593
  reason=StoppedReason.PAUSE,
592
- thread_id=threading.current_thread().ident,
594
+ thread_id=self.main_thread_id,
593
595
  )
594
596
  ),
595
597
  )
@@ -605,7 +607,7 @@ class Debugger:
605
607
  body=StoppedEventBody(
606
608
  description="Next step",
607
609
  reason=StoppedReason.STEP,
608
- thread_id=threading.current_thread().ident,
610
+ thread_id=self.main_thread_id,
609
611
  )
610
612
  ),
611
613
  )
@@ -620,7 +622,7 @@ class Debugger:
620
622
  body=StoppedEventBody(
621
623
  description="Step in",
622
624
  reason=StoppedReason.STEP,
623
- thread_id=threading.current_thread().ident,
625
+ thread_id=self.main_thread_id,
624
626
  )
625
627
  ),
626
628
  )
@@ -635,7 +637,7 @@ class Debugger:
635
637
  body=StoppedEventBody(
636
638
  description="Step out",
637
639
  reason=StoppedReason.STEP,
638
- thread_id=threading.current_thread().ident,
640
+ thread_id=self.main_thread_id,
639
641
  )
640
642
  ),
641
643
  )
@@ -708,7 +710,7 @@ class Debugger:
708
710
  body=StoppedEventBody(
709
711
  description="Breakpoint hit",
710
712
  reason=StoppedReason.BREAKPOINT,
711
- thread_id=threading.current_thread().ident,
713
+ thread_id=self.main_thread_id,
712
714
  hit_breakpoint_ids=[breakpoint_id_manager.get_id(v) for v in breakpoints],
713
715
  )
714
716
  ),
@@ -747,7 +749,7 @@ class Debugger:
747
749
  StoppedEvent(
748
750
  body=StoppedEventBody(
749
751
  reason=reason,
750
- thread_id=threading.current_thread().ident,
752
+ thread_id=self.main_thread_id,
751
753
  description=description,
752
754
  text=text,
753
755
  )
@@ -782,12 +784,12 @@ class Debugger:
782
784
  if self.requested_state == RequestedState.Running:
783
785
  self.requested_state = RequestedState.Nothing
784
786
  self.state = State.Running
785
- if self.main_thread is not None and self.main_thread.ident is not None:
787
+ if self.main_thread_is_alive:
786
788
  self.send_event(
787
789
  self,
788
790
  ContinuedEvent(
789
791
  body=ContinuedEventBody(
790
- thread_id=self.main_thread.ident,
792
+ thread_id=self.main_thread_id,
791
793
  all_threads_continued=True,
792
794
  )
793
795
  ),
@@ -947,7 +949,7 @@ class Debugger:
947
949
  StoppedEvent(
948
950
  body=StoppedEventBody(
949
951
  reason=StoppedReason.ENTRY,
950
- thread_id=threading.current_thread().ident,
952
+ thread_id=self.main_thread_id,
951
953
  )
952
954
  ),
953
955
  )
@@ -1221,15 +1223,25 @@ class Debugger:
1221
1223
  def set_main_thread(self, thread: threading.Thread) -> None:
1222
1224
  self.main_thread = thread
1223
1225
 
1224
- def get_threads(self) -> List[Thread]:
1225
- main_thread = self.main_thread or threading.main_thread()
1226
+ @property
1227
+ def main_thread_id(self) -> int:
1228
+ return 1 if self.main_thread_is_alive else 0
1226
1229
 
1227
- return [
1228
- Thread(
1229
- id=main_thread.ident if main_thread.ident else 0,
1230
- name=main_thread.name or "",
1231
- )
1232
- ]
1230
+ @property
1231
+ def main_thread_is_alive(self) -> bool:
1232
+ return self.main_thread is not None and self.main_thread.is_alive()
1233
+
1234
+ def get_threads(self) -> List[Thread]:
1235
+ return (
1236
+ [
1237
+ Thread(
1238
+ id=self.main_thread_id,
1239
+ name="RobotMain",
1240
+ )
1241
+ ]
1242
+ if self.main_thread_is_alive
1243
+ else []
1244
+ )
1233
1245
 
1234
1246
  WINDOW_PATH_REGEX: ClassVar = re.compile(r"^(([a-z]:[\\/])|(\\\\)).*$", re.RegexFlag.IGNORECASE)
1235
1247
 
@@ -1281,8 +1293,7 @@ class Debugger:
1281
1293
  levels: Optional[int] = None,
1282
1294
  format: Optional[StackFrameFormat] = None,
1283
1295
  ) -> StackTraceResult:
1284
- if self.main_thread is None or thread_id != self.main_thread.ident:
1285
- raise InvalidThreadIdError(thread_id)
1296
+ self.check_thread_id(thread_id)
1286
1297
 
1287
1298
  start_frame = start_frame or 0
1288
1299
  levels = start_frame + (levels or len(self.stack_frames))
@@ -118,16 +118,17 @@ def start_debugpy(
118
118
  global config_done_callback
119
119
 
120
120
  def connect_debugpy(server: "DebugAdapterServer") -> None:
121
- server.protocol.send_event(
122
- Event(
123
- event="debugpyStarted",
124
- body={
125
- "port": port,
126
- "addresses": addresses,
127
- "processId": os.getpid(),
128
- },
121
+ if not os.environ.get("DEBUGPY_ADAPTER_ENDPOINTS", None):
122
+ server.protocol.send_event(
123
+ Event(
124
+ event="debugpyStarted",
125
+ body={
126
+ "port": port,
127
+ "addresses": addresses,
128
+ "processId": os.getpid(),
129
+ },
130
+ )
129
131
  )
130
- )
131
132
 
132
133
  if wait_for_debugpy_client:
133
134
  app.verbose(f"Wait for debugpy incomming connections listening on {addresses}:{port}")
@@ -1 +0,0 @@
1
- __version__ = "0.108.1"