| 44 | |
| 45 | |
| 46 | def main(setup): |
| 47 | sys.path.append(os.path.dirname(__file__)) |
| 48 | import add_code_to_python_process |
| 49 | |
| 50 | show_debug_info_on_target_process = 0 |
| 51 | |
| 52 | pydevd_dirname = os.path.dirname(os.path.dirname(__file__)) |
| 53 | |
| 54 | if sys.platform == "win32": |
| 55 | setup["pythonpath"] = pydevd_dirname.replace("\\", "/") |
| 56 | setup["pythonpath2"] = os.path.dirname(__file__).replace("\\", "/") |
| 57 | python_code = ( |
| 58 | """import sys; |
| 59 | sys.path.append("%(pythonpath)s"); |
| 60 | sys.path.append("%(pythonpath2)s"); |
| 61 | import attach_script; |
| 62 | attach_script.attach(port=%(port)s, host="%(host)s", protocol="%(protocol)s", debug_mode="%(debug-mode)s"); |
| 63 | """.replace("\r\n", "") |
| 64 | .replace("\r", "") |
| 65 | .replace("\n", "") |
| 66 | ) |
| 67 | else: |
| 68 | setup["pythonpath"] = pydevd_dirname |
| 69 | setup["pythonpath2"] = os.path.dirname(__file__) |
| 70 | # We have to pass it a bit differently for gdb |
| 71 | python_code = ( |
| 72 | """import sys; |
| 73 | sys.path.append(\\\"%(pythonpath)s\\\"); |
| 74 | sys.path.append(\\\"%(pythonpath2)s\\\"); |
| 75 | import attach_script; |
| 76 | attach_script.attach(port=%(port)s, host=\\\"%(host)s\\\", protocol=\\\"%(protocol)s\\\", debug_mode=\\\"%(debug-mode)s\\\"); |
| 77 | """.replace("\r\n", "") |
| 78 | .replace("\r", "") |
| 79 | .replace("\n", "") |
| 80 | ) |
| 81 | |
| 82 | python_code = python_code % setup |
| 83 | add_code_to_python_process.run_python_code( |
| 84 | setup["pid"], python_code, connect_debugger_tracing=True, show_debug_info=show_debug_info_on_target_process |
| 85 | ) |
| 86 | |
| 87 | |
| 88 | if __name__ == "__main__": |