(case_setup_remote, reattach)
| 5214 | @pytest.mark.skipif(not IS_CPYTHON or IS_MAC, reason="Attach to pid only available in CPython (brittle on Mac).") |
| 5215 | @pytest.mark.skipif(not SUPPORT_ATTACH_TO_PID, reason="Attach to pid not supported.") |
| 5216 | def test_attach_to_pid(case_setup_remote, reattach): |
| 5217 | import threading |
| 5218 | |
| 5219 | with case_setup_remote.test_file("_debugger_case_attach_to_pid_simple.py", wait_for_port=False) as writer: |
| 5220 | time.sleep(1) # Give it some time to initialize to get to the while loop. |
| 5221 | _attach_to_writer_pid(writer) |
| 5222 | json_facade = JsonFacade(writer) |
| 5223 | |
| 5224 | bp_line = writer.get_line_index_with_content("break here") |
| 5225 | json_facade.write_set_breakpoints(bp_line) |
| 5226 | json_facade.write_make_initial_run() |
| 5227 | |
| 5228 | json_hit = json_facade.wait_for_thread_stopped(line=bp_line) |
| 5229 | |
| 5230 | if reattach: |
| 5231 | # This would be the same as a second attach to pid, so, the idea is closing the current |
| 5232 | # connection and then doing a new attach to pid. |
| 5233 | json_facade.write_set_breakpoints([]) |
| 5234 | json_facade.write_continue() |
| 5235 | |
| 5236 | writer.do_kill() # This will simply close the open sockets without doing anything else. |
| 5237 | time.sleep(1) |
| 5238 | |
| 5239 | t = threading.Thread(target=writer.start_socket) |
| 5240 | t.start() |
| 5241 | wait_for_condition(lambda: hasattr(writer, "port")) |
| 5242 | time.sleep(1) |
| 5243 | writer.process = writer.process |
| 5244 | _attach_to_writer_pid(writer) |
| 5245 | wait_for_condition(lambda: hasattr(writer, "reader_thread")) |
| 5246 | time.sleep(1) |
| 5247 | |
| 5248 | json_facade = JsonFacade(writer) |
| 5249 | json_facade.write_set_breakpoints(bp_line) |
| 5250 | json_facade.write_make_initial_run() |
| 5251 | |
| 5252 | json_hit = json_facade.wait_for_thread_stopped(line=bp_line) |
| 5253 | |
| 5254 | json_facade.write_set_variable(json_hit.frame_id, "wait", "0") |
| 5255 | |
| 5256 | json_facade.write_continue() |
| 5257 | |
| 5258 | writer.finished_ok = True |
| 5259 | |
| 5260 | |
| 5261 | def test_remote_debugger_basic(case_setup_remote_dap): |
nothing calls this directly
no test coverage detected