MCPcopy Index your code
hub / github.com/fabioz/PyDev.Debugger / test_attach_to_pid

Function test_attach_to_pid

tests_python/test_debugger_json.py:5216–5258  ·  view source on GitHub ↗
(case_setup_remote, reattach)

Source from the content-addressed store, hash-verified

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.")
5216def 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
5261def test_remote_debugger_basic(case_setup_remote_dap):

Callers

nothing calls this directly

Calls 12

write_set_breakpointsMethod · 0.95
write_continueMethod · 0.95
write_set_variableMethod · 0.95
wait_for_conditionFunction · 0.90
JsonFacadeClass · 0.85
test_fileMethod · 0.80
_attach_to_writer_pidFunction · 0.70
do_killMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected