From f4319af6c0f7a58779db3799068515edb8ae48c0 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Thu, 2 Nov 2023 09:38:46 +0100 Subject: [PATCH] debug --- src/core/opamStd.ml | 6 ++++++ src/stubs/win32/opamWindows.c | 9 ++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/core/opamStd.ml b/src/core/opamStd.ml index ffbf788f9cf..c1cd919f8e4 100644 --- a/src/core/opamStd.ml +++ b/src/core/opamStd.ml @@ -1086,15 +1086,21 @@ module OpamSys = struct | "cmd.exe" -> Some (Accept SH_cmd) | "env.exe" -> Some (Accept SH_sh) | name -> + if not (Filename.check_suffix name ".exe") then + Printf.printf "Unexpected: %S\n%!" name; Option.map (fun shell -> Accept shell) (shell_of_string (Filename.chop_suffix name ".exe")) in lazy ( let lazy ancestors = windows_process_ancestry in + try match OpamList.filter_map categorize_process ancestors with | [] -> None | Accept most_relevant_shell :: _ -> Some most_relevant_shell + with e -> + Printf.eprintf "Trace:\n %s\n%!" (String.concat "\n " (List.map snd ancestors)); + raise e ) let guess_shell_compat () = diff --git a/src/stubs/win32/opamWindows.c b/src/stubs/win32/opamWindows.c index c4132f72102..adc62e2127b 100644 --- a/src/stubs/win32/opamWindows.c +++ b/src/stubs/win32/opamWindows.c @@ -696,11 +696,14 @@ CAMLprim value OPAMW_GetProcessAncestry(value unit) hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, target); if (hProcess != NULL) { dwSize = MAX_PATH + 1; - if (!QueryFullProcessImageName(hProcess, 0, ExeName, &dwSize)) - ExeName[0] = L'\0'; + if (!QueryFullProcessImageName(hProcess, 0, ExeName, &dwSize)) { + ExeName[0] = L'a'; + ExeName[1] = L'\0'; + } CloseHandle(hProcess); } else { - ExeName[0] = L'\0'; + ExeName[0] = L'b'; + ExeName[1] = L'\0'; } info = caml_alloc_tuple(2); Store_field(info, 0, caml_copy_int32(target));