| 159 | |
| 160 | |
| 161 | def get_python_helper_lib_filename(): |
| 162 | # Note: we have an independent (and similar -- but not equal) version of this method in |
| 163 | # `add_code_to_python_process.py` which should be kept synchronized with this one (we do a copy |
| 164 | # because the `pydevd_attach_to_process` is mostly independent and shouldn't be imported in the |
| 165 | # debugger -- the only situation where it's imported is if the user actually does an attach to |
| 166 | # process, through `attach_pydevd.py`, but this should usually be called from the IDE directly |
| 167 | # and not from the debugger). |
| 168 | libdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "pydevd_attach_to_process") |
| 169 | |
| 170 | if not os.path.exists(libdir): |
| 171 | pydev_log.critical("Expected the directory: %s to exist!", libdir) |
| 172 | |
| 173 | arch = "" |
| 174 | if IS_WINDOWS: |
| 175 | # prefer not using platform.machine() when possible (it's a bit heavyweight as it may |
| 176 | # spawn a subprocess). |
| 177 | arch = os.environ.get("PROCESSOR_ARCHITEW6432", os.environ.get("PROCESSOR_ARCHITECTURE", "")) |
| 178 | |
| 179 | if not arch: |
| 180 | arch = platform.machine() |
| 181 | if not arch: |
| 182 | pydev_log.info("platform.machine() did not return valid value.") # This shouldn't happen... |
| 183 | return None |
| 184 | |
| 185 | if IS_WINDOWS: |
| 186 | extension = ".dll" |
| 187 | suffix_64 = "amd64" |
| 188 | suffix_32 = "x86" |
| 189 | |
| 190 | elif IS_LINUX: |
| 191 | extension = ".so" |
| 192 | suffix_64 = "amd64" |
| 193 | suffix_32 = "x86" |
| 194 | |
| 195 | elif IS_MAC: |
| 196 | extension = ".dylib" |
| 197 | suffix_64 = "x86_64" |
| 198 | suffix_32 = "x86" |
| 199 | |
| 200 | else: |
| 201 | pydev_log.info("Unable to set trace to all threads in platform: %s", sys.platform) |
| 202 | return None |
| 203 | |
| 204 | if arch.lower() not in ("arm64", "amd64", "x86", "x86_64", "i386", "x86"): |
| 205 | # We don't support this processor by default. Still, let's support the case where the |
| 206 | # user manually compiled it himself with some heuristics. |
| 207 | # |
| 208 | # Ideally the user would provide a library in the format: "attach_<arch>.<extension>" |
| 209 | # based on the way it's currently compiled -- see: |
| 210 | # - windows/compile_windows.bat |
| 211 | # - linux_and_mac/compile_linux.sh |
| 212 | # - linux_and_mac/compile_mac.sh |
| 213 | |
| 214 | try: |
| 215 | found = [name for name in os.listdir(libdir) if name.startswith("attach_") and name.endswith(extension)] |
| 216 | except: |
| 217 | if DebugInfoHolder.DEBUG_TRACE_LEVEL >= 1: |
| 218 | # There is no need to show this unless debug tracing is enabled. |