Commit 416d29e2 authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

dbghelp: Remove DMT_ entries for .DBG and .PDB files.

parent 79b6d8d9
...@@ -401,8 +401,6 @@ enum module_type ...@@ -401,8 +401,6 @@ enum module_type
DMT_ELF, /* a real ELF shared module */ DMT_ELF, /* a real ELF shared module */
DMT_PE, /* a native or builtin PE module */ DMT_PE, /* a native or builtin PE module */
DMT_MACHO, /* a real Mach-O shared module */ DMT_MACHO, /* a real Mach-O shared module */
DMT_PDB, /* .PDB file */
DMT_DBG, /* .DBG file */
}; };
struct process; struct process;
...@@ -775,7 +773,7 @@ extern DWORD pdb_get_file_indexinfo(void* image, DWORD size, SYMSRV_INDEX_INFOW* ...@@ -775,7 +773,7 @@ extern DWORD pdb_get_file_indexinfo(void* image, DWORD size, SYMSRV_INDEX_INFOW*
/* path.c */ /* path.c */
extern BOOL path_find_symbol_file(const struct process* pcs, const struct module* module, extern BOOL path_find_symbol_file(const struct process* pcs, const struct module* module,
PCSTR full_path, enum module_type type, const GUID* guid, DWORD dw1, DWORD dw2, PCSTR full_path, BOOL is_pdb, const GUID* guid, DWORD dw1, DWORD dw2,
WCHAR *buffer, BOOL* is_unmatched); WCHAR *buffer, BOOL* is_unmatched);
extern WCHAR *get_dos_file_name(const WCHAR *filename) __WINE_DEALLOC(HeapFree, 3) __WINE_MALLOC; extern WCHAR *get_dos_file_name(const WCHAR *filename) __WINE_DEALLOC(HeapFree, 3) __WINE_MALLOC;
extern BOOL search_dll_path(const struct process* process, const WCHAR *name, WORD machine, extern BOOL search_dll_path(const struct process* process, const WCHAR *name, WORD machine,
......
...@@ -3317,11 +3317,11 @@ static HANDLE map_pdb_file(const struct process* pcs, ...@@ -3317,11 +3317,11 @@ static HANDLE map_pdb_file(const struct process* pcs,
switch (lookup->kind) switch (lookup->kind)
{ {
case PDB_JG: case PDB_JG:
ret = path_find_symbol_file(pcs, module, lookup->filename, DMT_PDB, NULL, lookup->timestamp, ret = path_find_symbol_file(pcs, module, lookup->filename, TRUE, NULL, lookup->timestamp,
lookup->age, dbg_file_path, &module->module.PdbUnmatched); lookup->age, dbg_file_path, &module->module.PdbUnmatched);
break; break;
case PDB_DS: case PDB_DS:
ret = path_find_symbol_file(pcs, module, lookup->filename, DMT_PDB, &lookup->guid, 0, ret = path_find_symbol_file(pcs, module, lookup->filename, TRUE, &lookup->guid, 0,
lookup->age, dbg_file_path, &module->module.PdbUnmatched); lookup->age, dbg_file_path, &module->module.PdbUnmatched);
break; break;
} }
......
...@@ -461,13 +461,12 @@ BOOL WINAPI SymFindFileInPath(HANDLE hProcess, PCSTR searchPath, PCSTR full_path ...@@ -461,13 +461,12 @@ BOOL WINAPI SymFindFileInPath(HANDLE hProcess, PCSTR searchPath, PCSTR full_path
struct module_find struct module_find
{ {
enum module_type kind; BOOL is_pdb;
/* pe: dw1 DWORD:timestamp /* pdb: guid PDB guid (if DS PDB file)
* dw2 size of image (from PE header)
* pdb: guid PDB guid (if DS PDB file)
* or dw1 PDB timestamp (if JG PDB file) * or dw1 PDB timestamp (if JG PDB file)
* dw2 PDB age * dw2 PDB age
* elf: dw1 DWORD:CRC 32 of ELF image (Wine only) * dbg: dw1 DWORD:timestamp
* dw2 size of image (from PE header)
*/ */
const GUID* guid; const GUID* guid;
DWORD dw1; DWORD dw1;
...@@ -484,7 +483,7 @@ struct module_find ...@@ -484,7 +483,7 @@ struct module_find
static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user) static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user)
{ {
struct module_find* mf = user; struct module_find* mf = user;
DWORD size, timestamp; DWORD timestamp;
unsigned matched = 0; unsigned matched = 0;
/* the matching weights: /* the matching weights:
...@@ -492,107 +491,60 @@ static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user) ...@@ -492,107 +491,60 @@ static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user)
* +1 if first parameter and second parameter match * +1 if first parameter and second parameter match
*/ */
/* FIXME: should check that id/two match the file pointed if (mf->is_pdb)
* by buffer
*/
switch (mf->kind)
{ {
case DMT_PE: struct pdb_lookup pdb_lookup;
char fn[MAX_PATH];
WideCharToMultiByte(CP_ACP, 0, buffer, -1, fn, MAX_PATH, NULL, NULL);
pdb_lookup.filename = fn;
if (mf->guid)
{ {
HANDLE hFile, hMap; pdb_lookup.kind = PDB_DS;
void* mapping; pdb_lookup.timestamp = 0;
pdb_lookup.guid = *mf->guid;
timestamp = ~mf->dw1;
size = ~mf->dw2;
hFile = CreateFileW(buffer, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) return FALSE;
if ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL)
{
if ((mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL)
{
IMAGE_NT_HEADERS* nth = RtlImageNtHeader(mapping);
if (!nth)
{
UnmapViewOfFile(mapping);
CloseHandle(hMap);
CloseHandle(hFile);
return FALSE;
}
matched++;
timestamp = nth->FileHeader.TimeDateStamp;
size = nth->OptionalHeader.SizeOfImage;
UnmapViewOfFile(mapping);
}
CloseHandle(hMap);
}
CloseHandle(hFile);
if (timestamp != mf->dw1)
WARN("Found %s, but wrong timestamp\n", debugstr_w(buffer));
if (size != mf->dw2)
WARN("Found %s, but wrong size\n", debugstr_w(buffer));
if (timestamp == mf->dw1 && size == mf->dw2) matched++;
} }
break; else
case DMT_PDB:
{ {
struct pdb_lookup pdb_lookup; pdb_lookup.kind = PDB_JG;
char fn[MAX_PATH]; pdb_lookup.timestamp = mf->dw1;
/* pdb_loopkup.guid = */
WideCharToMultiByte(CP_ACP, 0, buffer, -1, fn, MAX_PATH, NULL, NULL);
pdb_lookup.filename = fn;
if (mf->guid)
{
pdb_lookup.kind = PDB_DS;
pdb_lookup.timestamp = 0;
pdb_lookup.guid = *mf->guid;
}
else
{
pdb_lookup.kind = PDB_JG;
pdb_lookup.timestamp = mf->dw1;
/* pdb_loopkup.guid = */
}
pdb_lookup.age = mf->dw2;
if (!pdb_fetch_file_info(&pdb_lookup, &matched)) return FALSE;
} }
break; pdb_lookup.age = mf->dw2;
case DMT_DBG:
if (!pdb_fetch_file_info(&pdb_lookup, &matched)) return FALSE;
}
else
{
HANDLE hFile, hMap;
void* mapping;
timestamp = ~mf->dw1;
hFile = CreateFileW(buffer, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) return FALSE;
if ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL)
{ {
HANDLE hFile, hMap; if ((mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL)
void* mapping;
timestamp = ~mf->dw1;
hFile = CreateFileW(buffer, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) return FALSE;
if ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != NULL)
{ {
if ((mapping = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) != NULL) const IMAGE_SEPARATE_DEBUG_HEADER* hdr;
hdr = mapping;
if (hdr->Signature == IMAGE_SEPARATE_DEBUG_SIGNATURE)
{ {
const IMAGE_SEPARATE_DEBUG_HEADER* hdr; matched++;
hdr = mapping; timestamp = hdr->TimeDateStamp;
if (hdr->Signature == IMAGE_SEPARATE_DEBUG_SIGNATURE)
{
matched++;
timestamp = hdr->TimeDateStamp;
}
UnmapViewOfFile(mapping);
} }
CloseHandle(hMap); UnmapViewOfFile(mapping);
} }
CloseHandle(hFile); CloseHandle(hMap);
if (timestamp == mf->dw1) matched++;
else WARN("Found %s, but wrong timestamp\n", debugstr_w(buffer));
} }
break; CloseHandle(hFile);
default: if (timestamp == mf->dw1) matched++;
FIXME("What the heck??\n"); else WARN("Found %s, but wrong timestamp\n", debugstr_w(buffer));
return FALSE;
} }
if (matched > mf->matched) if (matched > mf->matched)
{ {
lstrcpyW(mf->filename, buffer); lstrcpyW(mf->filename, buffer);
...@@ -605,7 +557,7 @@ static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user) ...@@ -605,7 +557,7 @@ static BOOL CALLBACK module_find_cb(PCWSTR buffer, PVOID user)
} }
BOOL path_find_symbol_file(const struct process* pcs, const struct module* module, BOOL path_find_symbol_file(const struct process* pcs, const struct module* module,
PCSTR full_path, enum module_type type, const GUID* guid, DWORD dw1, DWORD dw2, PCSTR full_path, BOOL is_pdb, const GUID* guid, DWORD dw1, DWORD dw2,
WCHAR *buffer, BOOL* is_unmatched) WCHAR *buffer, BOOL* is_unmatched)
{ {
struct module_find mf; struct module_find mf;
...@@ -624,7 +576,7 @@ BOOL path_find_symbol_file(const struct process* pcs, const struct module* modul ...@@ -624,7 +576,7 @@ BOOL path_find_symbol_file(const struct process* pcs, const struct module* modul
MultiByteToWideChar(CP_ACP, 0, full_path, -1, full_pathW, MAX_PATH); MultiByteToWideChar(CP_ACP, 0, full_path, -1, full_pathW, MAX_PATH);
filename = file_name(full_pathW); filename = file_name(full_pathW);
mf.kind = type; mf.is_pdb = is_pdb;
*is_unmatched = FALSE; *is_unmatched = FALSE;
/* first check full path to file */ /* first check full path to file */
......
...@@ -550,7 +550,7 @@ static BOOL pe_load_dbg_file(const struct process* pcs, struct module* module, ...@@ -550,7 +550,7 @@ static BOOL pe_load_dbg_file(const struct process* pcs, struct module* module,
TRACE("Processing DBG file %s\n", debugstr_a(dbg_name)); TRACE("Processing DBG file %s\n", debugstr_a(dbg_name));
if (path_find_symbol_file(pcs, module, dbg_name, DMT_DBG, NULL, timestamp, 0, tmp, &module->module.DbgUnmatched) && if (path_find_symbol_file(pcs, module, dbg_name, FALSE, NULL, timestamp, 0, tmp, &module->module.DbgUnmatched) &&
(hFile = CreateFileW(tmp, GENERIC_READ, FILE_SHARE_READ, NULL, (hFile = CreateFileW(tmp, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE && OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE &&
((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) && ((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) != 0) &&
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment