Commit 7493eada authored by Juergen Schmied's avatar Juergen Schmied Committed by Alexandre Julliard

- enable loading of pdb files named in NB10 records of a dbg file

- disable timestamp check for pdb files
parent ad2b103b
...@@ -2883,6 +2883,7 @@ static int DEBUG_ProcessPDBFile( DBG_MODULE* module, const char *full_filename ) ...@@ -2883,6 +2883,7 @@ static int DEBUG_ProcessPDBFile( DBG_MODULE* module, const char *full_filename )
int header_size = 0; int header_size = 0;
char *modimage, *file; char *modimage, *file;
DEBUG_Printf(DBG_CHN_TRACE, "Processing PDB file %s\n", full_filename);
/* /*
* Open and map() .PDB file * Open and map() .PDB file
...@@ -2945,11 +2946,13 @@ static int DEBUG_ProcessPDBFile( DBG_MODULE* module, const char *full_filename ) ...@@ -2945,11 +2946,13 @@ static int DEBUG_ProcessPDBFile( DBG_MODULE* module, const char *full_filename )
* Check .PDB time stamp * Check .PDB time stamp
*/ */
if ( root->TimeDateStamp if ( root->TimeDateStamp
!= ((struct CodeViewDebug *)MSC_INFO(module)->dbg_info)->cv_timestamp ) != ((struct CodeViewDebug *)MSC_INFO(module)->dbg_info)->cv_timestamp )
{ {
DEBUG_Printf(DBG_CHN_ERR, "-Wrong time stamp of .PDB file %s\n", full_filename); /* the timestamp seems to be wrong often (we may read the file wrong)*/
goto leave; DEBUG_Printf(DBG_CHN_MESG, "-Wrong time stamp of .PDB file %s (0x%08lx, 0x%08x)\n",
full_filename, root->TimeDateStamp,
((struct CodeViewDebug *)MSC_INFO(module)->dbg_info)->cv_timestamp);
} }
/* /*
...@@ -3057,14 +3060,10 @@ DEBUG_ProcessDBGFile(DBG_MODULE* module, const char* filename) ...@@ -3057,14 +3060,10 @@ DEBUG_ProcessDBGFile(DBG_MODULE* module, const char* filename)
{ {
HANDLE hFile, hMap; HANDLE hFile, hMap;
char * addr; char * addr;
char * codeview;
struct CV4_DirHead * codeview_dir;
struct CV4_DirEnt * codeview_dent;
PIMAGE_DEBUG_DIRECTORY dbghdr; PIMAGE_DEBUG_DIRECTORY dbghdr;
DBG_MODULE module2; DBG_MODULE module2;
int i; int i;
int j; int j;
struct codeview_linetab_hdr * linetab;
int nsect; int nsect;
PIMAGE_SEPARATE_DEBUG_HEADER pdbg = NULL; PIMAGE_SEPARATE_DEBUG_HEADER pdbg = NULL;
IMAGE_SECTION_HEADER * sectp; IMAGE_SECTION_HEADER * sectp;
...@@ -3115,47 +3114,62 @@ DEBUG_ProcessDBGFile(DBG_MODULE* module, const char* filename) ...@@ -3115,47 +3114,62 @@ DEBUG_ProcessDBGFile(DBG_MODULE* module, const char* filename)
DEBUG_ProcessCoff(&module2); DEBUG_ProcessCoff(&module2);
break; break;
case IMAGE_DEBUG_TYPE_CODEVIEW: case IMAGE_DEBUG_TYPE_CODEVIEW:
/* {
* This is the older format by which codeview stuff is char * codeview;
* stored, known as the 'NB09' format. Newer executables struct CV4_DirHead * codeview_dir;
* and dlls created by VC++ use PDB files instead, which struct CV4_DirEnt * codeview_dent;
* have lots of internal similarities, but the overall struct codeview_linetab_hdr * linetab;
* format and structure is quite different. struct CodeViewDebug * cvd;
*/
codeview = (addr + dbghdr->PointerToRawData); cvd = (struct CodeViewDebug *) (addr + dbghdr->PointerToRawData);
/* /*
* The first thing in the codeview section should be * see msdn.microsoft.com/library/specs/S66EA.HTM
* an 'NB09' identifier. As a sanity check, make sure * for desriptions of more NBxx formats
* it is there. */
*/ if( strcmp(cvd->cv_nbtype, "NB10") == 0 )
if( *((unsigned int*) codeview) != 0x3930424e )
{ {
break; /*
* The debug information resides in a seperate pdb file.
* This section contains only a filename.
*/
DEBUG_ProcessPDBFile(module, cvd->cv_name);
} }
else if (strcmp(cvd->cv_nbtype, "NB09") == 0 )
/*
* Next we need to find the directory. This is easy too.
*/
codeview_dir = (struct CV4_DirHead *)
(codeview + ((unsigned int*) codeview)[1]);
/*
* Some more sanity checks. Make sure that everything
* is as we expect it.
*/
if( codeview_dir->next_offset != 0
|| codeview_dir->dhsize != sizeof(*codeview_dir)
|| codeview_dir->desize != sizeof(*codeview_dent) )
{ {
break; /*
} * CodeView 4.10
codeview_dent = (struct CV4_DirEnt *) (codeview_dir + 1); * This is the older format by which codeview stuff is
* stored, known as the 'NB09' format. Newer executables
* and dlls created by VC++ use PDB files instead, which
* have lots of internal similarities, but the overall
* format and structure is quite different.
*/
codeview = (addr + dbghdr->PointerToRawData);
for(j=0; j < codeview_dir->ndir; j++, codeview_dent++)
{ /*
if( codeview_dent->subsect_number == sstAlignSym ) * We need to find the directory. This is easy too.
{ */
codeview_dir = (struct CV4_DirHead *)
(codeview + ((unsigned int*) codeview)[1]);
/*
* Some more sanity checks. Make sure that everything
* is as we expect it.
*/
if( codeview_dir->next_offset != 0
|| codeview_dir->dhsize != sizeof(*codeview_dir)
|| codeview_dir->desize != sizeof(*codeview_dent) )
{
break;
}
codeview_dent = (struct CV4_DirEnt *) (codeview_dir + 1);
for(j=0; j < codeview_dir->ndir; j++, codeview_dent++)
{
if( codeview_dent->subsect_number == sstAlignSym )
{
/* /*
* Check the previous entry. If it is a * Check the previous entry. If it is a
* sstSrcModule, it contains the line number * sstSrcModule, it contains the line number
...@@ -3163,30 +3177,36 @@ DEBUG_ProcessDBGFile(DBG_MODULE* module, const char* filename) ...@@ -3163,30 +3177,36 @@ DEBUG_ProcessDBGFile(DBG_MODULE* module, const char* filename)
*/ */
linetab = NULL; linetab = NULL;
if( codeview_dent[1].module_number == codeview_dent[0].module_number if( codeview_dent[1].module_number == codeview_dent[0].module_number
&& codeview_dent[1].subsect_number == sstSrcModule ) && codeview_dent[1].subsect_number == sstSrcModule )
{ {
linetab = DEBUG_SnarfLinetab( linetab = DEBUG_SnarfLinetab(
codeview + codeview_dent[1].offset, codeview + codeview_dent[1].offset,
codeview_dent[1].size); codeview_dent[1].size);
} }
if( codeview_dent[-1].module_number == codeview_dent[0].module_number if( codeview_dent[-1].module_number == codeview_dent[0].module_number
&& codeview_dent[-1].subsect_number == sstSrcModule ) && codeview_dent[-1].subsect_number == sstSrcModule )
{ {
linetab = DEBUG_SnarfLinetab( linetab = DEBUG_SnarfLinetab(
codeview + codeview_dent[-1].offset, codeview + codeview_dent[-1].offset,
codeview_dent[-1].size); codeview_dent[-1].size);
} }
/* /*
* Now process the CV stuff. * Now process the CV stuff.
*/ */
DEBUG_SnarfCodeView(module, DEBUG_SnarfCodeView(module,
codeview + codeview_dent->offset + sizeof(DWORD), codeview + codeview_dent->offset + sizeof(DWORD),
codeview_dent->size - sizeof(DWORD), codeview_dent->size - sizeof(DWORD),
linetab); linetab);
} }
}
} }
else
{
DEBUG_Printf(DBG_CHN_ERR, "Unknown CODEVIEW type %s in module %s\n",
cvd->cv_nbtype, module->module_name);
}
}
break; break;
default: default:
break; break;
...@@ -3230,10 +3250,11 @@ DEBUG_ProcessMSCDebugInfo(DBG_MODULE* module) ...@@ -3230,10 +3250,11 @@ DEBUG_ProcessMSCDebugInfo(DBG_MODULE* module)
* it yet. * it yet.
*/ */
sts = FALSE; sts = FALSE;
DEBUG_Printf(DBG_CHN_ERR, "Unknown CODEVIEW type %s in module %s\n",
cvd->cv_nbtype, module->module_name);
break; break;
} }
sts = DEBUG_ProcessPDBFile(module, cvd->cv_name); sts = DEBUG_ProcessPDBFile(module, cvd->cv_name);
DEBUG_Printf(DBG_CHN_TRACE, "Processing PDB file %s\n", cvd->cv_name);
break; break;
case IMAGE_DEBUG_TYPE_MISC: case IMAGE_DEBUG_TYPE_MISC:
/* /*
......
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