Hi, at [1] i noticed that dylibs are printed as PEs. This intents to fix that, but i have no Mac, could someone please review/test?
[1] http://test.winehq.org/data/8ef3a142263e6db11f1514f77b3de84c8b08d7a0/mac_fg-...
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 6bea436..41fa7e6 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -33,6 +33,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
const WCHAR S_ElfW[] = {'<','e','l','f','>','\0'}; +const WCHAR S_MachoW[] = {'<','m','a','c','h','o','>','\0'}; const WCHAR S_WineLoaderW[] = {'<','w','i','n','e','-','l','o','a','d','e','r','>','\0'}; static const WCHAR S_DotSoW[] = {'.','s','o','\0'}; static const WCHAR S_DotDylibW[] = {'.','d','y','l','i','b','\0'}; @@ -94,6 +95,9 @@ static void module_fill_module(const WCHAR* in, WCHAR* out, size_t size) if (len > 3 && !strcmpiW(&out[len - 3], S_DotSoW) && (l = match_ext(out, len - 3))) strcpyW(&out[len - l - 3], S_ElfW); + else if (len > 6 && !strcmpiW(&out[len - 6], S_DotDylibW) && + (l = match_ext(out, len - 6))) + strcpyW(&out[len - l - 6], S_MachoW); } while ((*out = tolowerW(*out))) out++; } diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index c0b86ba..c2c7c08 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -244,6 +244,11 @@ void info_win32_module(DWORD64 base) } } } + else if (strstr(im.mi[i].ModuleName, "<macho>")) + { + dbg_printf("MACH-O\t"); + module_print_info(&im.mi[i], FALSE); + } else { /* check module is not embedded in another module */ @@ -253,8 +258,11 @@ void info_win32_module(DWORD64 base) break; } if (j < im.num_used) continue; - if (strstr(im.mi[i].ModuleName, ".so") || strchr(im.mi[i].ModuleName, '<')) + if (strstr(im.mi[i].ModuleName, ".so") || strstr(im.mi[i].ModuleName, "<elf>") || + strstr(im.mi[i].ModuleName, "<wine-loader>")) dbg_printf("ELF\t"); + else if (strstr(im.mi[i].ModuleName, ".dylib") || strstr(im.mi[i].ModuleName, "<macho>")) + dbg_printf("MACH-O\t"); else dbg_printf("PE\t"); module_print_info(&im.mi[i], FALSE);
Hi,
On Aug 27, 2013, at 4:08 PM, André Hentschel wrote:
@@ -94,6 +95,9 @@ static void module_fill_module(const WCHAR* in, WCHAR* out, size_t size) if (len > 3 && !strcmpiW(&out[len - 3], S_DotSoW) && (l = match_ext(out, len - 3))) strcpyW(&out[len - l - 3], S_ElfW);
else if (len > 6 && !strcmpiW(&out[len - 6], S_DotDylibW) &&
(l = match_ext(out, len - 6)))
strcpyW(&out[len - l - 6], S_MachoW);
This isn't sufficient. Even though the native dynamic library extension is .dylib on Mac OS X, Wine actually still uses .so as the extension for its libraries. For example, kernel32.dll.so.
So, you have to change the earlier branch matching S_DotSoW, too. Probably, it should just use "#ifdef __APPLE__" to pick the tag to apply, as module_get_type_by_name() does in a similar situation.
You do still need the test for .dylib for platform libraries.
dbg_printf("MACH-O\t");
I think it should be "Mach-O", not "MACH-O".
dbg_printf("MACH-O\t");
Same here.
I believe you missed a check for "<elf>" in symbols_info_cb() in symbol.c. I'm not sure under what circumstances that would be important, though.
-Ken
On Aug 27, 2013, at 3:08 PM, André Hentschel wrote:
Hi, at [1] i noticed that dylibs are printed as PEs. This intents to fix that, but i have no Mac, could someone please review/test?
[1] http://test.winehq.org/data/8ef3a142263e6db11f1514f77b3de84c8b08d7a0/mac_fg-...
I generally agree with Ken's comments. In addition:
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 6bea436..41fa7e6 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -33,6 +33,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
const WCHAR S_ElfW[] = {'<','e','l','f','>','\0'}; +const WCHAR S_MachoW[] = {'<','m','a','c','h','o','>','\0'};
Personally, I'd prefer: const WCHAR S_MachOW[] = {'<','m','a','c','h','-','o','>','\0'};
diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index c0b86ba..c2c7c08 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -253,8 +258,11 @@ void info_win32_module(DWORD64 base) break; } if (j < im.num_used) continue;
if (strstr(im.mi[i].ModuleName, ".so") || strchr(im.mi[i].ModuleName, '<'))
if (strstr(im.mi[i].ModuleName, ".so") || strstr(im.mi[i].ModuleName, "<elf>") ||
strstr(im.mi[i].ModuleName, "<wine-loader>"))
The 'wine' binary (the module whose name is "<wine-loader>") is a Mach-O file, too, on Mac OS.
Chip
Hi, thank you both for the comments, i'll see what i can do.
Am 29.08.2013 19:52, schrieb André Hentschel:
Hi, thank you both for the comments, i'll see what i can do.
How about that?
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 6bea436..ed1d9c0 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -33,6 +33,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
const WCHAR S_ElfW[] = {'<','e','l','f','>','\0'}; +const WCHAR S_MachoW[] = {'<','m','a','c','h','-','o','>','\0'}; const WCHAR S_WineLoaderW[] = {'<','w','i','n','e','-','l','o','a','d','e','r','>','\0'}; static const WCHAR S_DotSoW[] = {'.','s','o','\0'}; static const WCHAR S_DotDylibW[] = {'.','d','y','l','i','b','\0'}; @@ -89,12 +90,19 @@ static void module_fill_module(const WCHAR* in, WCHAR* out, size_t size) out[len - l] = '\0'; else if (len > strlenW(loader) && !strcmpiW(out + len - strlenW(loader), loader)) lstrcpynW(out, S_WineLoaderW, size); - else - { - if (len > 3 && !strcmpiW(&out[len - 3], S_DotSoW) && - (l = match_ext(out, len - 3))) - strcpyW(&out[len - l - 3], S_ElfW); - } + else if (len > 3 && !strcmpiW(&out[len - 3], S_DotSoW) && (l = match_ext(out, len - 3))) + switch (module_get_type_by_name(out)) + { + case DMT_ELF: + strcpyW(&out[len - l - 3], S_ElfW); + break; + case DMT_MACHO: + strcpyW(&out[len - l - 3], S_MachoW); + break; + default: + break; + } + while ((*out = tolowerW(*out))) out++; }
diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index c0b86ba..0667ad7 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -244,6 +244,11 @@ void info_win32_module(DWORD64 base) } } } + else if (strstr(im.mi[i].ModuleName, "<mach-o>")) + { + dbg_printf("Mach-O\t"); + module_print_info(&im.mi[i], FALSE); + } else { /* check module is not embedded in another module */ @@ -253,7 +258,15 @@ void info_win32_module(DWORD64 base) break; } if (j < im.num_used) continue; - if (strstr(im.mi[i].ModuleName, ".so") || strchr(im.mi[i].ModuleName, '<')) + if (strstr(im.mi[i].ModuleName, "<wine-loader>")) +#ifdef __APPLE__ + dbg_printf("Mach-O\t"); +#else + dbg_printf("ELF\t"); +#endif + else if (strstr(im.mi[i].ModuleName, ".dylib") || strstr(im.mi[i].ModuleName, "<mach-o>")) + dbg_printf("Mach-O\t"); + else if (strstr(im.mi[i].ModuleName, ".so") || strstr(im.mi[i].ModuleName, "<elf>")) dbg_printf("ELF\t"); else dbg_printf("PE\t"); diff --git a/programs/winedbg/symbol.c b/programs/winedbg/symbol.c index 99b382d..b8092ae 100644 --- a/programs/winedbg/symbol.c +++ b/programs/winedbg/symbol.c @@ -779,6 +779,8 @@ static BOOL CALLBACK symbols_info_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx) size_t len = strlen(mi.ModuleName); if (len > 5 && !strcmp(mi.ModuleName + len - 5, "<elf>")) mi.ModuleName[len - 5] = '\0'; + else if (len > 8 && !strcmp(mi.ModuleName + len - 8, "<mach-o>")) + mi.ModuleName[len - 8] = '\0'; }
dbg_printf("%08lx: %s!%s", (ULONG_PTR)sym->Address, mi.ModuleName, sym->Name);
On Aug 29, 2013, at 2:35 PM, André Hentschel wrote:
Am 29.08.2013 19:52, schrieb André Hentschel:
Hi, thank you both for the comments, i'll see what i can do.
How about that?
Much better, but...
diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index c0b86ba..0667ad7 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -244,6 +244,11 @@ void info_win32_module(DWORD64 base) } } }
else if (strstr(im.mi[i].ModuleName, "<mach-o>"))
{
dbg_printf("Mach-O\t");
module_print_info(&im.mi[i], FALSE);
If there are any modules embedded in a Mach-O file (i.e. the PE DLLs embedded in a Wine built-in DLL), this will no longer print them.
} else { /* check module is not embedded in another module */
Chip
Am 29.08.2013 22:46, schrieb Charles Davis:
On Aug 29, 2013, at 2:35 PM, André Hentschel wrote:
Am 29.08.2013 19:52, schrieb André Hentschel:
Hi, thank you both for the comments, i'll see what i can do.
How about that?
Much better, but...
diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index c0b86ba..0667ad7 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -244,6 +244,11 @@ void info_win32_module(DWORD64 base) } } }
else if (strstr(im.mi[i].ModuleName, "<mach-o>"))
{
dbg_printf("Mach-O\t");
module_print_info(&im.mi[i], FALSE);
If there are any modules embedded in a Mach-O file (i.e. the PE DLLs embedded in a Wine built-in DLL), this will no longer print them.
Oops, true.
changes since last one:
dbg_printf("Mach-O\t"); module_print_info(&im.mi[i], FALSE);
/* print all modules embedded in this one */
for (j = 0; j < im.num_used; j++)
{
if (!strstr(im.mi[j].ModuleName, "<mach-o>") && module_is_container(&im.mi[i], &im.mi[j]))
{
dbg_printf(" \\-PE\t");
module_print_info(&im.mi[j], TRUE);
}
} } else { /* check module is not embedded in another module */ for (j = 0; j < im.num_used; j++) {
if (strstr(im.mi[j].ModuleName, "<elf>") && module_is_container(&im.mi[j], &im.mi[i]))
if ((strstr(im.mi[j].ModuleName, "<elf>") || strstr(im.mi[j].ModuleName, "<mach-o>")) &&
module_is_container(&im.mi[j], &im.mi[i])) break;
Could you test that please? Maybe some ideas regarding code duplication?
diff --git a/dlls/dbghelp/module.c b/dlls/dbghelp/module.c index 6bea436..ed1d9c0 100644 --- a/dlls/dbghelp/module.c +++ b/dlls/dbghelp/module.c @@ -33,6 +33,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
const WCHAR S_ElfW[] = {'<','e','l','f','>','\0'}; +const WCHAR S_MachoW[] = {'<','m','a','c','h','-','o','>','\0'}; const WCHAR S_WineLoaderW[] = {'<','w','i','n','e','-','l','o','a','d','e','r','>','\0'}; static const WCHAR S_DotSoW[] = {'.','s','o','\0'}; static const WCHAR S_DotDylibW[] = {'.','d','y','l','i','b','\0'}; @@ -89,12 +90,19 @@ static void module_fill_module(const WCHAR* in, WCHAR* out, size_t size) out[len - l] = '\0'; else if (len > strlenW(loader) && !strcmpiW(out + len - strlenW(loader), loader)) lstrcpynW(out, S_WineLoaderW, size); - else - { - if (len > 3 && !strcmpiW(&out[len - 3], S_DotSoW) && - (l = match_ext(out, len - 3))) - strcpyW(&out[len - l - 3], S_ElfW); - } + else if (len > 3 && !strcmpiW(&out[len - 3], S_DotSoW) && (l = match_ext(out, len - 3))) + switch (module_get_type_by_name(out)) + { + case DMT_ELF: + strcpyW(&out[len - l - 3], S_ElfW); + break; + case DMT_MACHO: + strcpyW(&out[len - l - 3], S_MachoW); + break; + default: + break; + } + while ((*out = tolowerW(*out))) out++; }
diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index c0b86ba..79cadc0 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -244,16 +244,39 @@ void info_win32_module(DWORD64 base) } } } + else if (strstr(im.mi[i].ModuleName, "<mach-o>")) + { + dbg_printf("Mach-O\t"); + module_print_info(&im.mi[i], FALSE); + /* print all modules embedded in this one */ + for (j = 0; j < im.num_used; j++) + { + if (!strstr(im.mi[j].ModuleName, "<mach-o>") && module_is_container(&im.mi[i], &im.mi[j])) + { + dbg_printf(" \-PE\t"); + module_print_info(&im.mi[j], TRUE); + } + } + } else { /* check module is not embedded in another module */ for (j = 0; j < im.num_used; j++) { - if (strstr(im.mi[j].ModuleName, "<elf>") && module_is_container(&im.mi[j], &im.mi[i])) + if ((strstr(im.mi[j].ModuleName, "<elf>") || strstr(im.mi[j].ModuleName, "<mach-o>")) && + module_is_container(&im.mi[j], &im.mi[i])) break; } if (j < im.num_used) continue; - if (strstr(im.mi[i].ModuleName, ".so") || strchr(im.mi[i].ModuleName, '<')) + if (strstr(im.mi[i].ModuleName, "<wine-loader>")) +#ifdef __APPLE__ + dbg_printf("Mach-O\t"); +#else + dbg_printf("ELF\t"); +#endif + else if (strstr(im.mi[i].ModuleName, ".dylib") || strstr(im.mi[i].ModuleName, "<mach-o>")) + dbg_printf("Mach-O\t"); + else if (strstr(im.mi[i].ModuleName, ".so") || strstr(im.mi[i].ModuleName, "<elf>")) dbg_printf("ELF\t"); else dbg_printf("PE\t"); diff --git a/programs/winedbg/symbol.c b/programs/winedbg/symbol.c index 99b382d..b8092ae 100644 --- a/programs/winedbg/symbol.c +++ b/programs/winedbg/symbol.c @@ -779,6 +779,8 @@ static BOOL CALLBACK symbols_info_cb(PSYMBOL_INFO sym, ULONG size, PVOID ctx) size_t len = strlen(mi.ModuleName); if (len > 5 && !strcmp(mi.ModuleName + len - 5, "<elf>")) mi.ModuleName[len - 5] = '\0'; + else if (len > 8 && !strcmp(mi.ModuleName + len - 8, "<mach-o>")) + mi.ModuleName[len - 8] = '\0'; }
dbg_printf("%08lx: %s!%s", (ULONG_PTR)sym->Address, mi.ModuleName, sym->Name);
André Hentschel nerv@dawncrow.de writes:
Am 29.08.2013 19:52, schrieb André Hentschel:
Hi, thank you both for the comments, i'll see what i can do.
How about that?
I don't see the point at all. There's no reason to add all that complexity for a purely cosmetic detail.
Am 29.08.2013 23:15, schrieb Alexandre Julliard:
André Hentschel nerv@dawncrow.de writes:
Am 29.08.2013 19:52, schrieb André Hentschel:
Hi, thank you both for the comments, i'll see what i can do.
How about that?
I don't see the point at all. There's no reason to add all that complexity for a purely cosmetic detail.
OK, one use case is when we want to automatically parse the BTs, e.g. when sending them over to a server at winehq. (wasn't that one idea when the crash dialog was discussed?)
André Hentschel nerv@dawncrow.de writes:
Am 29.08.2013 23:15, schrieb Alexandre Julliard:
André Hentschel nerv@dawncrow.de writes:
Am 29.08.2013 19:52, schrieb André Hentschel:
Hi, thank you both for the comments, i'll see what i can do.
How about that?
I don't see the point at all. There's no reason to add all that complexity for a purely cosmetic detail.
OK, one use case is when we want to automatically parse the BTs, e.g. when sending them over to a server at winehq. (wasn't that one idea when the crash dialog was discussed?)
We have system information in the crash logs already.