Skip to content

Commit

Permalink
Use pathlib for paths
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewc12 committed Oct 21, 2023
1 parent ac8b46c commit 4a1830f
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions contrib/windows/parsedump/parsedump.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,32 @@

import re
import subprocess
import pathlib
import os

pf64 = pathlib.WindowsPath(os.environ["ProgramFiles"])
pf86 = pathlib.WindowsPath(os.environ["ProgramFiles(x86)"])


def find_first_existing_file(file_paths):
for file_path in file_paths:
if os.path.exists(file_path):
if file_path.exists():
return file_path
return None # Return None if no file is found


# List of file paths to check
cdb_file_paths_to_check = [
"%ProgramFiles%\\Windows Kits\\10\\Debuggers\\x64\\cdb.exe",
"%ProgramFiles(x86)%\\Windows Kits\\10\\Debuggers\\x64\\cdb.exe",
"%ProgramFiles%\\Windows Kits\\10\\Debuggers\\x86\\cdb.exe",
"%ProgramFiles(x86)%\\Windows Kits\\10\\Debuggers\\x86\\cdb.exe"
pf64 / "Windows Kits" / "10" / "Debuggers" / "x64" / "cdb.exe",
pf86 / "Windows Kits" / "10" / "Debuggers" / "x64" / "cdb.exe",
pf64 / "Windows Kits" / "10" / "Debuggers" / "x86" / "cdb.exe",
pf86 / "Windows Kits" / "10" / "Debuggers" / "x86" / "cdb.exe"
]

cdbstr = find_first_existing_file(cdb_file_paths_to_check)
cdb = find_first_existing_file(cdb_file_paths_to_check)

if cdbstr:
print(cdbstr)
if cdb:
print(cdb)
else:
print("cdb not found.")
exit()
Expand All @@ -37,7 +41,7 @@ def find_first_existing_file(file_paths):

def run(arg):
result = subprocess.run(
[cdbstr, "-z", dumpfilestr, "-c", arg, "-y", symbolstr],
[str(cdb), "-z", dumpfilestr, "-c", arg, "-y", symbolstr],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
Expand Down

0 comments on commit 4a1830f

Please sign in to comment.