RFC: Mark dylib/mach-o on Mac OS X
André Hentschel
nerv at dawncrow.de
Thu Aug 29 15:54:32 CDT 2013
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);
More information about the wine-devel
mailing list