2004-04-06 00:21:27 +02:00
|
|
|
/*
|
|
|
|
* File msc.c - read VC++ debug information from COFF and eventually
|
|
|
|
* from PDB files.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1996, Eric Youngdale.
|
|
|
|
* Copyright (C) 1999-2000, Ulrich Weigand.
|
2008-09-29 21:32:38 +02:00
|
|
|
* Copyright (C) 2004-2009, Eric Pouech.
|
2004-04-06 00:21:27 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-04-06 00:21:27 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note - this handles reading debug information for 32 bit applications
|
|
|
|
* that run under Windows-NT for example. I doubt that this would work well
|
|
|
|
* for 16 bit applications, but I don't think it really matters since the
|
|
|
|
* file format is different, and we should never get in here in such cases.
|
|
|
|
*
|
|
|
|
* TODO:
|
|
|
|
* Get 16 bit CV stuff working.
|
|
|
|
* Add symbol size to internal symbol table.
|
|
|
|
*/
|
|
|
|
|
2008-02-21 17:44:17 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
#include <assert.h>
|
2004-11-21 16:51:47 +01:00
|
|
|
#include <stdio.h>
|
2004-04-06 00:21:27 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2011-10-11 19:13:40 +02:00
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winternl.h"
|
|
|
|
|
|
|
|
#include "wine/exception.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "dbghelp_private.h"
|
2006-11-29 21:40:30 +01:00
|
|
|
#include "wine/mscvpdb.h"
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_msc);
|
|
|
|
|
2011-01-17 21:54:04 +01:00
|
|
|
struct pdb_stream_name
|
|
|
|
{
|
|
|
|
const char* name;
|
|
|
|
unsigned index;
|
|
|
|
};
|
|
|
|
|
2011-01-08 14:04:01 +01:00
|
|
|
struct pdb_file_info
|
|
|
|
{
|
|
|
|
enum pdb_kind kind;
|
|
|
|
DWORD age;
|
2011-01-08 14:04:14 +01:00
|
|
|
HANDLE hMap;
|
|
|
|
const char* image;
|
2011-01-17 21:54:04 +01:00
|
|
|
struct pdb_stream_name* stream_dict;
|
2011-01-17 21:54:17 +01:00
|
|
|
unsigned fpoext_stream;
|
2011-01-08 14:04:01 +01:00
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
DWORD timestamp;
|
|
|
|
struct PDB_JG_TOC* toc;
|
|
|
|
} jg;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
GUID guid;
|
|
|
|
struct PDB_DS_TOC* toc;
|
|
|
|
} ds;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
2011-01-08 14:04:08 +01:00
|
|
|
/* FIXME: don't make it static */
|
|
|
|
#define CV_MAX_MODULES 32
|
|
|
|
struct pdb_module_info
|
|
|
|
{
|
|
|
|
unsigned used_subfiles;
|
|
|
|
struct pdb_file_info pdb_files[CV_MAX_MODULES];
|
|
|
|
};
|
|
|
|
|
2021-11-08 14:58:39 +01:00
|
|
|
#define loc_cv_local_range (loc_user + 0) /* loc.offset contain the copy of all defrange* Codeview records following S_LOCAL */
|
|
|
|
|
2021-11-08 14:59:20 +01:00
|
|
|
struct cv_module_snarf
|
|
|
|
{
|
|
|
|
const struct codeview_type_parse* ipi_ctp;
|
|
|
|
const struct CV_DebugSSubsectionHeader_t* dbgsubsect;
|
|
|
|
unsigned dbgsubsect_size;
|
|
|
|
const char* strimage;
|
|
|
|
unsigned strsize;
|
|
|
|
};
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/*========================================================================
|
|
|
|
* Debug file access helper routines
|
|
|
|
*/
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
static void dump(const void* ptr, unsigned len)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2008-09-24 21:50:05 +02:00
|
|
|
unsigned int i, j;
|
2005-09-02 16:47:36 +02:00
|
|
|
char msg[128];
|
2004-11-21 16:51:47 +01:00
|
|
|
const char* hexof = "0123456789abcdef";
|
2009-01-19 10:24:06 +01:00
|
|
|
const BYTE* x = ptr;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
for (i = 0; i < len; i += 16)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
sprintf(msg, "%08x: ", i);
|
|
|
|
memset(msg + 10, ' ', 3 * 16 + 1 + 16);
|
|
|
|
for (j = 0; j < min(16, len - i); j++)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
msg[10 + 3 * j + 0] = hexof[x[i + j] >> 4];
|
|
|
|
msg[10 + 3 * j + 1] = hexof[x[i + j] & 15];
|
|
|
|
msg[10 + 3 * j + 2] = ' ';
|
|
|
|
msg[10 + 3 * 16 + 1 + j] = (x[i + j] >= 0x20 && x[i + j] < 0x7f) ?
|
|
|
|
x[i + j] : '.';
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2004-11-21 16:51:47 +01:00
|
|
|
msg[10 + 3 * 16] = ' ';
|
|
|
|
msg[10 + 3 * 16 + 1 + 16] = '\0';
|
|
|
|
FIXME("%s\n", msg);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*========================================================================
|
|
|
|
* Process CodeView type information.
|
|
|
|
*/
|
|
|
|
|
2010-10-09 08:51:02 +02:00
|
|
|
#define MAX_BUILTIN_TYPES 0x06FF
|
2004-11-21 16:51:47 +01:00
|
|
|
#define FIRST_DEFINABLE_TYPE 0x1000
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
static struct symt* cv_basic_types[MAX_BUILTIN_TYPES];
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
struct cv_defined_module
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
BOOL allowed;
|
|
|
|
unsigned int num_defined_types;
|
|
|
|
struct symt** defined_types;
|
2004-04-06 00:21:27 +02:00
|
|
|
};
|
2004-11-21 16:51:47 +01:00
|
|
|
/* FIXME: don't make it static */
|
|
|
|
#define CV_MAX_MODULES 32
|
|
|
|
static struct cv_defined_module cv_zmodules[CV_MAX_MODULES];
|
|
|
|
static struct cv_defined_module*cv_current_module;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
static void codeview_init_basic_types(struct module* module)
|
|
|
|
{
|
2021-11-08 14:57:59 +01:00
|
|
|
unsigned ptrsz = module->cpu->word_size;
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/*
|
|
|
|
* These are the common builtin types that are used by VC++.
|
|
|
|
*/
|
|
|
|
cv_basic_types[T_NOTYPE] = NULL;
|
|
|
|
cv_basic_types[T_ABS] = NULL;
|
|
|
|
cv_basic_types[T_VOID] = &symt_new_basic(module, btVoid, "void", 0)->symt;
|
|
|
|
cv_basic_types[T_CHAR] = &symt_new_basic(module, btChar, "char", 1)->symt;
|
|
|
|
cv_basic_types[T_SHORT] = &symt_new_basic(module, btInt, "short int", 2)->symt;
|
|
|
|
cv_basic_types[T_LONG] = &symt_new_basic(module, btInt, "long int", 4)->symt;
|
|
|
|
cv_basic_types[T_QUAD] = &symt_new_basic(module, btInt, "long long int", 8)->symt;
|
2004-04-19 04:58:27 +02:00
|
|
|
cv_basic_types[T_UCHAR] = &symt_new_basic(module, btUInt, "unsigned char", 1)->symt;
|
2004-04-06 00:21:27 +02:00
|
|
|
cv_basic_types[T_USHORT] = &symt_new_basic(module, btUInt, "unsigned short", 2)->symt;
|
|
|
|
cv_basic_types[T_ULONG] = &symt_new_basic(module, btUInt, "unsigned long", 4)->symt;
|
|
|
|
cv_basic_types[T_UQUAD] = &symt_new_basic(module, btUInt, "unsigned long long", 8)->symt;
|
2008-02-06 21:55:04 +01:00
|
|
|
cv_basic_types[T_BOOL08] = &symt_new_basic(module, btBool, "BOOL08", 1)->symt;
|
|
|
|
cv_basic_types[T_BOOL16] = &symt_new_basic(module, btBool, "BOOL16", 2)->symt;
|
|
|
|
cv_basic_types[T_BOOL32] = &symt_new_basic(module, btBool, "BOOL32", 4)->symt;
|
|
|
|
cv_basic_types[T_BOOL64] = &symt_new_basic(module, btBool, "BOOL64", 8)->symt;
|
2004-04-06 00:21:27 +02:00
|
|
|
cv_basic_types[T_REAL32] = &symt_new_basic(module, btFloat, "float", 4)->symt;
|
|
|
|
cv_basic_types[T_REAL64] = &symt_new_basic(module, btFloat, "double", 8)->symt;
|
2008-09-29 21:32:00 +02:00
|
|
|
cv_basic_types[T_REAL80] = &symt_new_basic(module, btFloat, "long double", 10)->symt;
|
2004-04-06 00:21:27 +02:00
|
|
|
cv_basic_types[T_RCHAR] = &symt_new_basic(module, btInt, "signed char", 1)->symt;
|
|
|
|
cv_basic_types[T_WCHAR] = &symt_new_basic(module, btWChar, "wchar_t", 2)->symt;
|
2017-05-04 08:16:40 +02:00
|
|
|
cv_basic_types[T_CHAR16] = &symt_new_basic(module, btChar16,"char16_t", 2)->symt;
|
2017-05-04 08:16:41 +02:00
|
|
|
cv_basic_types[T_CHAR32] = &symt_new_basic(module, btChar32,"char32_t", 4)->symt;
|
2021-11-08 14:58:26 +01:00
|
|
|
cv_basic_types[T_CHAR8] = &symt_new_basic(module, btChar8, "char8_t", 1)->symt;
|
2008-02-06 21:55:04 +01:00
|
|
|
cv_basic_types[T_INT2] = &symt_new_basic(module, btInt, "INT2", 2)->symt;
|
|
|
|
cv_basic_types[T_UINT2] = &symt_new_basic(module, btUInt, "UINT2", 2)->symt;
|
2004-04-06 00:21:27 +02:00
|
|
|
cv_basic_types[T_INT4] = &symt_new_basic(module, btInt, "INT4", 4)->symt;
|
|
|
|
cv_basic_types[T_UINT4] = &symt_new_basic(module, btUInt, "UINT4", 4)->symt;
|
2008-02-06 21:55:04 +01:00
|
|
|
cv_basic_types[T_INT8] = &symt_new_basic(module, btInt, "INT8", 8)->symt;
|
|
|
|
cv_basic_types[T_UINT8] = &symt_new_basic(module, btUInt, "UINT8", 8)->symt;
|
2008-02-06 21:55:22 +01:00
|
|
|
cv_basic_types[T_HRESULT]= &symt_new_basic(module, btUInt, "HRESULT", 4)->symt;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2011-01-13 20:09:44 +01:00
|
|
|
cv_basic_types[T_32PVOID] = &symt_new_pointer(module, cv_basic_types[T_VOID], 4)->symt;
|
|
|
|
cv_basic_types[T_32PCHAR] = &symt_new_pointer(module, cv_basic_types[T_CHAR], 4)->symt;
|
|
|
|
cv_basic_types[T_32PSHORT] = &symt_new_pointer(module, cv_basic_types[T_SHORT], 4)->symt;
|
|
|
|
cv_basic_types[T_32PLONG] = &symt_new_pointer(module, cv_basic_types[T_LONG], 4)->symt;
|
|
|
|
cv_basic_types[T_32PQUAD] = &symt_new_pointer(module, cv_basic_types[T_QUAD], 4)->symt;
|
|
|
|
cv_basic_types[T_32PUCHAR] = &symt_new_pointer(module, cv_basic_types[T_UCHAR], 4)->symt;
|
|
|
|
cv_basic_types[T_32PUSHORT] = &symt_new_pointer(module, cv_basic_types[T_USHORT], 4)->symt;
|
|
|
|
cv_basic_types[T_32PULONG] = &symt_new_pointer(module, cv_basic_types[T_ULONG], 4)->symt;
|
|
|
|
cv_basic_types[T_32PUQUAD] = &symt_new_pointer(module, cv_basic_types[T_UQUAD], 4)->symt;
|
|
|
|
cv_basic_types[T_32PBOOL08] = &symt_new_pointer(module, cv_basic_types[T_BOOL08], 4)->symt;
|
|
|
|
cv_basic_types[T_32PBOOL16] = &symt_new_pointer(module, cv_basic_types[T_BOOL16], 4)->symt;
|
|
|
|
cv_basic_types[T_32PBOOL32] = &symt_new_pointer(module, cv_basic_types[T_BOOL32], 4)->symt;
|
|
|
|
cv_basic_types[T_32PBOOL64] = &symt_new_pointer(module, cv_basic_types[T_BOOL64], 4)->symt;
|
|
|
|
cv_basic_types[T_32PREAL32] = &symt_new_pointer(module, cv_basic_types[T_REAL32], 4)->symt;
|
|
|
|
cv_basic_types[T_32PREAL64] = &symt_new_pointer(module, cv_basic_types[T_REAL64], 4)->symt;
|
|
|
|
cv_basic_types[T_32PREAL80] = &symt_new_pointer(module, cv_basic_types[T_REAL80], 4)->symt;
|
|
|
|
cv_basic_types[T_32PRCHAR] = &symt_new_pointer(module, cv_basic_types[T_RCHAR], 4)->symt;
|
|
|
|
cv_basic_types[T_32PWCHAR] = &symt_new_pointer(module, cv_basic_types[T_WCHAR], 4)->symt;
|
2017-05-04 08:16:40 +02:00
|
|
|
cv_basic_types[T_32PCHAR16] = &symt_new_pointer(module, cv_basic_types[T_CHAR16], 4)->symt;
|
2017-05-04 08:16:41 +02:00
|
|
|
cv_basic_types[T_32PCHAR32] = &symt_new_pointer(module, cv_basic_types[T_CHAR32], 4)->symt;
|
2021-11-08 14:58:26 +01:00
|
|
|
cv_basic_types[T_32PCHAR8] = &symt_new_pointer(module, cv_basic_types[T_CHAR8], 4)->symt;
|
2011-01-13 20:09:44 +01:00
|
|
|
cv_basic_types[T_32PINT2] = &symt_new_pointer(module, cv_basic_types[T_INT2], 4)->symt;
|
|
|
|
cv_basic_types[T_32PUINT2] = &symt_new_pointer(module, cv_basic_types[T_UINT2], 4)->symt;
|
|
|
|
cv_basic_types[T_32PINT4] = &symt_new_pointer(module, cv_basic_types[T_INT4], 4)->symt;
|
|
|
|
cv_basic_types[T_32PUINT4] = &symt_new_pointer(module, cv_basic_types[T_UINT4], 4)->symt;
|
|
|
|
cv_basic_types[T_32PINT8] = &symt_new_pointer(module, cv_basic_types[T_INT8], 4)->symt;
|
|
|
|
cv_basic_types[T_32PUINT8] = &symt_new_pointer(module, cv_basic_types[T_UINT8], 4)->symt;
|
|
|
|
cv_basic_types[T_32PHRESULT]= &symt_new_pointer(module, cv_basic_types[T_HRESULT], 4)->symt;
|
|
|
|
|
|
|
|
cv_basic_types[T_64PVOID] = &symt_new_pointer(module, cv_basic_types[T_VOID], 8)->symt;
|
|
|
|
cv_basic_types[T_64PCHAR] = &symt_new_pointer(module, cv_basic_types[T_CHAR], 8)->symt;
|
|
|
|
cv_basic_types[T_64PSHORT] = &symt_new_pointer(module, cv_basic_types[T_SHORT], 8)->symt;
|
|
|
|
cv_basic_types[T_64PLONG] = &symt_new_pointer(module, cv_basic_types[T_LONG], 8)->symt;
|
|
|
|
cv_basic_types[T_64PQUAD] = &symt_new_pointer(module, cv_basic_types[T_QUAD], 8)->symt;
|
|
|
|
cv_basic_types[T_64PUCHAR] = &symt_new_pointer(module, cv_basic_types[T_UCHAR], 8)->symt;
|
|
|
|
cv_basic_types[T_64PUSHORT] = &symt_new_pointer(module, cv_basic_types[T_USHORT], 8)->symt;
|
|
|
|
cv_basic_types[T_64PULONG] = &symt_new_pointer(module, cv_basic_types[T_ULONG], 8)->symt;
|
|
|
|
cv_basic_types[T_64PUQUAD] = &symt_new_pointer(module, cv_basic_types[T_UQUAD], 8)->symt;
|
|
|
|
cv_basic_types[T_64PBOOL08] = &symt_new_pointer(module, cv_basic_types[T_BOOL08], 8)->symt;
|
|
|
|
cv_basic_types[T_64PBOOL16] = &symt_new_pointer(module, cv_basic_types[T_BOOL16], 8)->symt;
|
|
|
|
cv_basic_types[T_64PBOOL32] = &symt_new_pointer(module, cv_basic_types[T_BOOL32], 8)->symt;
|
|
|
|
cv_basic_types[T_64PBOOL64] = &symt_new_pointer(module, cv_basic_types[T_BOOL64], 8)->symt;
|
|
|
|
cv_basic_types[T_64PREAL32] = &symt_new_pointer(module, cv_basic_types[T_REAL32], 8)->symt;
|
|
|
|
cv_basic_types[T_64PREAL64] = &symt_new_pointer(module, cv_basic_types[T_REAL64], 8)->symt;
|
|
|
|
cv_basic_types[T_64PREAL80] = &symt_new_pointer(module, cv_basic_types[T_REAL80], 8)->symt;
|
|
|
|
cv_basic_types[T_64PRCHAR] = &symt_new_pointer(module, cv_basic_types[T_RCHAR], 8)->symt;
|
|
|
|
cv_basic_types[T_64PWCHAR] = &symt_new_pointer(module, cv_basic_types[T_WCHAR], 8)->symt;
|
2017-05-04 08:16:40 +02:00
|
|
|
cv_basic_types[T_64PCHAR16] = &symt_new_pointer(module, cv_basic_types[T_CHAR16], 8)->symt;
|
2017-05-04 08:16:41 +02:00
|
|
|
cv_basic_types[T_64PCHAR32] = &symt_new_pointer(module, cv_basic_types[T_CHAR32], 8)->symt;
|
2021-11-08 14:58:26 +01:00
|
|
|
cv_basic_types[T_64PCHAR8] = &symt_new_pointer(module, cv_basic_types[T_CHAR8], 8)->symt;
|
2011-01-13 20:09:44 +01:00
|
|
|
cv_basic_types[T_64PINT2] = &symt_new_pointer(module, cv_basic_types[T_INT2], 8)->symt;
|
|
|
|
cv_basic_types[T_64PUINT2] = &symt_new_pointer(module, cv_basic_types[T_UINT2], 8)->symt;
|
|
|
|
cv_basic_types[T_64PINT4] = &symt_new_pointer(module, cv_basic_types[T_INT4], 8)->symt;
|
|
|
|
cv_basic_types[T_64PUINT4] = &symt_new_pointer(module, cv_basic_types[T_UINT4], 8)->symt;
|
|
|
|
cv_basic_types[T_64PINT8] = &symt_new_pointer(module, cv_basic_types[T_INT8], 8)->symt;
|
|
|
|
cv_basic_types[T_64PUINT8] = &symt_new_pointer(module, cv_basic_types[T_UINT8], 8)->symt;
|
|
|
|
cv_basic_types[T_64PHRESULT]= &symt_new_pointer(module, cv_basic_types[T_HRESULT], 8)->symt;
|
2015-10-12 22:40:45 +02:00
|
|
|
|
2021-11-08 14:57:59 +01:00
|
|
|
cv_basic_types[T_PVOID] = &symt_new_pointer(module, cv_basic_types[T_VOID], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PCHAR] = &symt_new_pointer(module, cv_basic_types[T_CHAR], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PSHORT] = &symt_new_pointer(module, cv_basic_types[T_SHORT], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PLONG] = &symt_new_pointer(module, cv_basic_types[T_LONG], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PQUAD] = &symt_new_pointer(module, cv_basic_types[T_QUAD], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PUCHAR] = &symt_new_pointer(module, cv_basic_types[T_UCHAR], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PUSHORT] = &symt_new_pointer(module, cv_basic_types[T_USHORT], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PULONG] = &symt_new_pointer(module, cv_basic_types[T_ULONG], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PUQUAD] = &symt_new_pointer(module, cv_basic_types[T_UQUAD], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PBOOL08] = &symt_new_pointer(module, cv_basic_types[T_BOOL08], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PBOOL16] = &symt_new_pointer(module, cv_basic_types[T_BOOL16], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PBOOL32] = &symt_new_pointer(module, cv_basic_types[T_BOOL32], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PBOOL64] = &symt_new_pointer(module, cv_basic_types[T_BOOL64], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PREAL32] = &symt_new_pointer(module, cv_basic_types[T_REAL32], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PREAL64] = &symt_new_pointer(module, cv_basic_types[T_REAL64], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PREAL80] = &symt_new_pointer(module, cv_basic_types[T_REAL80], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PRCHAR] = &symt_new_pointer(module, cv_basic_types[T_RCHAR], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PWCHAR] = &symt_new_pointer(module, cv_basic_types[T_WCHAR], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PCHAR16] = &symt_new_pointer(module, cv_basic_types[T_CHAR16], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PCHAR32] = &symt_new_pointer(module, cv_basic_types[T_CHAR32], ptrsz)->symt;
|
2021-11-08 14:58:26 +01:00
|
|
|
cv_basic_types[T_PCHAR8] = &symt_new_pointer(module, cv_basic_types[T_CHAR8], ptrsz)->symt;
|
2021-11-08 14:57:59 +01:00
|
|
|
cv_basic_types[T_PINT2] = &symt_new_pointer(module, cv_basic_types[T_INT2], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PUINT2] = &symt_new_pointer(module, cv_basic_types[T_UINT2], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PINT4] = &symt_new_pointer(module, cv_basic_types[T_INT4], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PUINT4] = &symt_new_pointer(module, cv_basic_types[T_UINT4], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PINT8] = &symt_new_pointer(module, cv_basic_types[T_INT8], ptrsz)->symt;
|
|
|
|
cv_basic_types[T_PUINT8] = &symt_new_pointer(module, cv_basic_types[T_UINT8], ptrsz)->symt;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2008-09-29 21:31:53 +02:00
|
|
|
static int leaf_as_variant(VARIANT* v, const unsigned short int* leaf)
|
|
|
|
{
|
|
|
|
unsigned short int type = *leaf++;
|
|
|
|
int length = 2;
|
|
|
|
|
|
|
|
if (type < LF_NUMERIC)
|
|
|
|
{
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_UINT;
|
|
|
|
V_UINT(v) = type;
|
2008-09-29 21:31:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case LF_CHAR:
|
|
|
|
length += 1;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_I1;
|
|
|
|
V_I1(v) = *(const char*)leaf;
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_SHORT:
|
|
|
|
length += 2;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_I2;
|
|
|
|
V_I2(v) = *(const short*)leaf;
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_USHORT:
|
|
|
|
length += 2;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_UI2;
|
|
|
|
V_UI2(v) = *leaf;
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_LONG:
|
|
|
|
length += 4;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_I4;
|
|
|
|
V_I4(v) = *(const int*)leaf;
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_ULONG:
|
|
|
|
length += 4;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_UI4;
|
|
|
|
V_UI4(v) = *(const unsigned int*)leaf;
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_QUADWORD:
|
|
|
|
length += 8;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_I8;
|
|
|
|
V_I8(v) = *(const long long int*)leaf;
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_UQUADWORD:
|
|
|
|
length += 8;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_UI8;
|
|
|
|
V_UI8(v) = *(const long long unsigned int*)leaf;
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_REAL32:
|
|
|
|
length += 4;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_R4;
|
|
|
|
V_R4(v) = *(const float*)leaf;
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_REAL48:
|
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
|
|
|
length += 6;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_EMPTY; /* FIXME */
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_REAL64:
|
|
|
|
length += 8;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_R8;
|
|
|
|
V_R8(v) = *(const double*)leaf;
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_REAL80:
|
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
|
|
|
length += 10;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_EMPTY; /* FIXME */
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_REAL128:
|
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
|
|
|
length += 16;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_EMPTY; /* FIXME */
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_COMPLEX32:
|
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
|
|
|
length += 4;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_EMPTY; /* FIXME */
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_COMPLEX64:
|
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
|
|
|
length += 8;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_EMPTY; /* FIXME */
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_COMPLEX80:
|
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
|
|
|
length += 10;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_COMPLEX128:
|
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
|
|
|
length += 16;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_EMPTY; /* FIXME */
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_VARSTRING:
|
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
|
|
|
length += 2 + *leaf;
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_EMPTY; /* FIXME */
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unknown numeric leaf type %04x\n", type);
|
2021-10-13 15:17:20 +02:00
|
|
|
V_VT(v) = VT_EMPTY; /* FIXME */
|
2008-09-29 21:31:53 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
static int numeric_leaf(int* value, const unsigned short int* leaf)
|
|
|
|
{
|
|
|
|
unsigned short int type = *leaf++;
|
|
|
|
int length = 2;
|
|
|
|
|
|
|
|
if (type < LF_NUMERIC)
|
|
|
|
{
|
|
|
|
*value = type;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case LF_CHAR:
|
|
|
|
length += 1;
|
2004-05-18 23:29:09 +02:00
|
|
|
*value = *(const char*)leaf;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_SHORT:
|
|
|
|
length += 2;
|
2004-05-18 23:29:09 +02:00
|
|
|
*value = *(const short*)leaf;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_USHORT:
|
|
|
|
length += 2;
|
2007-12-04 22:45:11 +01:00
|
|
|
*value = *leaf;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_LONG:
|
|
|
|
length += 4;
|
2004-05-18 23:29:09 +02:00
|
|
|
*value = *(const int*)leaf;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_ULONG:
|
|
|
|
length += 4;
|
2004-05-18 23:29:09 +02:00
|
|
|
*value = *(const unsigned int*)leaf;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_QUADWORD:
|
|
|
|
case LF_UQUADWORD:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
2004-04-06 00:21:27 +02:00
|
|
|
length += 8;
|
|
|
|
*value = 0; /* FIXME */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_REAL32:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
2004-04-06 00:21:27 +02:00
|
|
|
length += 4;
|
|
|
|
*value = 0; /* FIXME */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_REAL48:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
2004-04-06 00:21:27 +02:00
|
|
|
length += 6;
|
|
|
|
*value = 0; /* FIXME */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_REAL64:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
2004-04-06 00:21:27 +02:00
|
|
|
length += 8;
|
|
|
|
*value = 0; /* FIXME */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_REAL80:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
2004-04-06 00:21:27 +02:00
|
|
|
length += 10;
|
|
|
|
*value = 0; /* FIXME */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_REAL128:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
2004-04-06 00:21:27 +02:00
|
|
|
length += 16;
|
|
|
|
*value = 0; /* FIXME */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_COMPLEX32:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
2004-04-06 00:21:27 +02:00
|
|
|
length += 4;
|
|
|
|
*value = 0; /* FIXME */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_COMPLEX64:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
2004-04-06 00:21:27 +02:00
|
|
|
length += 8;
|
|
|
|
*value = 0; /* FIXME */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_COMPLEX80:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
2004-04-06 00:21:27 +02:00
|
|
|
length += 10;
|
|
|
|
*value = 0; /* FIXME */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_COMPLEX128:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
2004-04-06 00:21:27 +02:00
|
|
|
length += 16;
|
|
|
|
*value = 0; /* FIXME */
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_VARSTRING:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported numeric leaf type %04x\n", type);
|
2004-04-06 00:21:27 +02:00
|
|
|
length += 2 + *leaf;
|
|
|
|
*value = 0; /* FIXME */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unknown numeric leaf type %04x\n", type);
|
|
|
|
*value = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
/* convert a pascal string (as stored in debug information) into
|
|
|
|
* a C string (null terminated).
|
|
|
|
*/
|
|
|
|
static const char* terminate_string(const struct p_string* p_name)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
static char symname[256];
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
memcpy(symname, p_name->name, p_name->namelen);
|
|
|
|
symname[p_name->namelen] = '\0';
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
return (!*symname || strcmp(symname, "__unnamed") == 0) ? NULL : symname;
|
|
|
|
}
|
|
|
|
|
2006-03-18 13:32:56 +01:00
|
|
|
static struct symt* codeview_get_type(unsigned int typeno, BOOL quiet)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
struct symt* symt = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Convert Codeview type numbers into something we can grok internally.
|
2004-11-21 16:51:47 +01:00
|
|
|
* Numbers < FIRST_DEFINABLE_TYPE are all fixed builtin types.
|
|
|
|
* Numbers from FIRST_DEFINABLE_TYPE and up are all user defined (structs, etc).
|
2004-04-06 00:21:27 +02:00
|
|
|
*/
|
2004-11-21 16:51:47 +01:00
|
|
|
if (typeno < FIRST_DEFINABLE_TYPE)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
if (typeno < MAX_BUILTIN_TYPES)
|
|
|
|
symt = cv_basic_types[typeno];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
unsigned mod_index = typeno >> 24;
|
|
|
|
unsigned mod_typeno = typeno & 0x00FFFFFF;
|
|
|
|
struct cv_defined_module* mod;
|
|
|
|
|
|
|
|
mod = (mod_index == 0) ? cv_current_module : &cv_zmodules[mod_index];
|
|
|
|
|
|
|
|
if (mod_index >= CV_MAX_MODULES || !mod->allowed)
|
|
|
|
FIXME("Module of index %d isn't loaded yet (%x)\n", mod_index, typeno);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (mod_typeno - FIRST_DEFINABLE_TYPE < mod->num_defined_types)
|
|
|
|
symt = mod->defined_types[mod_typeno - FIRST_DEFINABLE_TYPE];
|
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2006-03-18 13:32:56 +01:00
|
|
|
if (!quiet && !symt && typeno) FIXME("Returning NULL symt for type-id %x\n", typeno);
|
2004-04-06 00:21:27 +02:00
|
|
|
return symt;
|
|
|
|
}
|
|
|
|
|
2006-03-18 13:32:50 +01:00
|
|
|
struct codeview_type_parse
|
|
|
|
{
|
|
|
|
struct module* module;
|
|
|
|
const BYTE* table;
|
|
|
|
const DWORD* offset;
|
|
|
|
DWORD num;
|
|
|
|
};
|
|
|
|
|
2007-04-18 23:24:27 +02:00
|
|
|
static inline const void* codeview_jump_to_type(const struct codeview_type_parse* ctp, DWORD idx)
|
2006-03-18 13:32:50 +01:00
|
|
|
{
|
|
|
|
if (idx < FIRST_DEFINABLE_TYPE) return NULL;
|
|
|
|
idx -= FIRST_DEFINABLE_TYPE;
|
|
|
|
return (idx >= ctp->num) ? NULL : (ctp->table + ctp->offset[idx]);
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
static int codeview_add_type(unsigned int typeno, struct symt* dt)
|
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
if (typeno < FIRST_DEFINABLE_TYPE)
|
|
|
|
FIXME("What the heck\n");
|
|
|
|
if (!cv_current_module)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Adding %x to non allowed module\n", typeno);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if ((typeno >> 24) != 0)
|
|
|
|
FIXME("No module index while inserting type-id assumption is wrong %x\n",
|
|
|
|
typeno);
|
2009-07-10 14:46:55 +02:00
|
|
|
if (typeno - FIRST_DEFINABLE_TYPE >= cv_current_module->num_defined_types)
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
|
|
|
if (cv_current_module->defined_types)
|
2009-07-10 14:46:55 +02:00
|
|
|
{
|
|
|
|
cv_current_module->num_defined_types = max( cv_current_module->num_defined_types * 2,
|
|
|
|
typeno - FIRST_DEFINABLE_TYPE + 1 );
|
2007-06-27 00:13:42 +02:00
|
|
|
cv_current_module->defined_types = HeapReAlloc(GetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY, cv_current_module->defined_types,
|
2004-11-21 16:51:47 +01:00
|
|
|
cv_current_module->num_defined_types * sizeof(struct symt*));
|
2009-07-10 14:46:55 +02:00
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
else
|
2009-07-10 14:46:55 +02:00
|
|
|
{
|
|
|
|
cv_current_module->num_defined_types = max( 256, typeno - FIRST_DEFINABLE_TYPE + 1 );
|
2007-06-27 00:13:42 +02:00
|
|
|
cv_current_module->defined_types = HeapAlloc(GetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
cv_current_module->num_defined_types * sizeof(struct symt*));
|
2009-07-10 14:46:55 +02:00
|
|
|
}
|
2004-11-21 16:51:47 +01:00
|
|
|
if (cv_current_module->defined_types == NULL) return FALSE;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2006-03-18 13:33:11 +01:00
|
|
|
if (cv_current_module->defined_types[typeno - FIRST_DEFINABLE_TYPE])
|
|
|
|
{
|
|
|
|
if (cv_current_module->defined_types[typeno - FIRST_DEFINABLE_TYPE] != dt)
|
2007-12-07 21:01:34 +01:00
|
|
|
FIXME("Overwriting at %x\n", typeno);
|
2006-03-18 13:33:11 +01:00
|
|
|
}
|
2004-11-21 16:51:47 +01:00
|
|
|
cv_current_module->defined_types[typeno - FIRST_DEFINABLE_TYPE] = dt;
|
2004-04-06 00:21:27 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void codeview_clear_type_table(void)
|
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
int i;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
for (i = 0; i < CV_MAX_MODULES; i++)
|
|
|
|
{
|
2006-06-12 00:11:36 +02:00
|
|
|
if (cv_zmodules[i].allowed)
|
2004-11-21 16:51:47 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, cv_zmodules[i].defined_types);
|
|
|
|
cv_zmodules[i].allowed = FALSE;
|
|
|
|
cv_zmodules[i].defined_types = NULL;
|
|
|
|
cv_zmodules[i].num_defined_types = 0;
|
|
|
|
}
|
|
|
|
cv_current_module = NULL;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2006-03-18 13:33:11 +01:00
|
|
|
static struct symt* codeview_parse_one_type(struct codeview_type_parse* ctp,
|
|
|
|
unsigned curr_type,
|
|
|
|
const union codeview_type* type, BOOL details);
|
|
|
|
|
|
|
|
static void* codeview_cast_symt(struct symt* symt, enum SymTagEnum tag)
|
|
|
|
{
|
|
|
|
if (symt->tag != tag)
|
|
|
|
{
|
|
|
|
FIXME("Bad tag. Expected %d, but got %d\n", tag, symt->tag);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return symt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct symt* codeview_fetch_type(struct codeview_type_parse* ctp,
|
2008-02-06 21:55:10 +01:00
|
|
|
unsigned typeno, BOOL details)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2006-03-18 13:33:11 +01:00
|
|
|
struct symt* symt;
|
|
|
|
const union codeview_type* p;
|
|
|
|
|
|
|
|
if (!typeno) return NULL;
|
|
|
|
if ((symt = codeview_get_type(typeno, TRUE))) return symt;
|
|
|
|
|
|
|
|
/* forward declaration */
|
|
|
|
if (!(p = codeview_jump_to_type(ctp, typeno)))
|
|
|
|
{
|
|
|
|
FIXME("Cannot locate type %x\n", typeno);
|
|
|
|
return NULL;
|
|
|
|
}
|
2008-02-06 21:55:10 +01:00
|
|
|
symt = codeview_parse_one_type(ctp, typeno, p, details);
|
2006-03-18 13:33:11 +01:00
|
|
|
if (!symt) FIXME("Couldn't load forward type %x\n", typeno);
|
|
|
|
return symt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct symt* codeview_add_type_pointer(struct codeview_type_parse* ctp,
|
|
|
|
struct symt* existing,
|
|
|
|
unsigned int pointee_type)
|
|
|
|
{
|
|
|
|
struct symt* pointee;
|
|
|
|
|
|
|
|
if (existing)
|
|
|
|
{
|
|
|
|
existing = codeview_cast_symt(existing, SymTagPointerType);
|
|
|
|
return existing;
|
|
|
|
}
|
2008-02-06 21:55:10 +01:00
|
|
|
pointee = codeview_fetch_type(ctp, pointee_type, FALSE);
|
2021-11-08 14:57:59 +01:00
|
|
|
return &symt_new_pointer(ctp->module, pointee, ctp->module->cpu->word_size)->symt;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2006-03-18 13:33:11 +01:00
|
|
|
static struct symt* codeview_add_type_array(struct codeview_type_parse* ctp,
|
2006-03-18 13:33:06 +01:00
|
|
|
const char* name,
|
|
|
|
unsigned int elemtype,
|
|
|
|
unsigned int indextype,
|
|
|
|
unsigned int arr_len)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2008-02-06 21:55:10 +01:00
|
|
|
struct symt* elem = codeview_fetch_type(ctp, elemtype, FALSE);
|
|
|
|
struct symt* index = codeview_fetch_type(ctp, indextype, FALSE);
|
2021-08-31 14:13:26 +02:00
|
|
|
DWORD64 elem_size;
|
|
|
|
DWORD count = 0;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2021-08-31 14:13:26 +02:00
|
|
|
if (symt_get_info(ctp->module, elem, TI_GET_LENGTH, &elem_size) && elem_size)
|
|
|
|
{
|
|
|
|
if (arr_len % (DWORD)elem_size)
|
2022-02-09 09:26:26 +01:00
|
|
|
FIXME("array size should be a multiple of element size %u %lu\n", arr_len, (DWORD)elem_size);
|
2021-08-31 14:13:26 +02:00
|
|
|
count = arr_len / (unsigned)elem_size;
|
|
|
|
}
|
|
|
|
return &symt_new_array(ctp->module, 0, count, elem, index)->symt;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2013-11-12 01:16:36 +01:00
|
|
|
static BOOL codeview_add_type_enum_field_list(struct module* module,
|
|
|
|
struct symt_enum* symt,
|
|
|
|
const union codeview_reftype* ref_type)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2006-03-18 13:32:50 +01:00
|
|
|
const unsigned char* ptr = ref_type->fieldlist.list;
|
|
|
|
const unsigned char* last = (const BYTE*)ref_type + ref_type->generic.len + 2;
|
|
|
|
const union codeview_fieldtype* type;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-03-18 13:32:50 +01:00
|
|
|
while (ptr < last)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
if (*ptr >= 0xf0) /* LF_PAD... */
|
|
|
|
{
|
|
|
|
ptr += *ptr & 0x0f;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-03-18 13:32:50 +01:00
|
|
|
type = (const union codeview_fieldtype*)ptr;
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
switch (type->generic.id)
|
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_ENUMERATE_V1:
|
|
|
|
{
|
|
|
|
int value, vlen = numeric_leaf(&value, &type->enumerate_v1.value);
|
|
|
|
const struct p_string* p_name = (const struct p_string*)((const unsigned char*)&type->enumerate_v1.value + vlen);
|
|
|
|
|
|
|
|
symt_add_enum_element(module, symt, terminate_string(p_name), value);
|
|
|
|
ptr += 2 + 2 + vlen + (1 + p_name->namelen);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case LF_ENUMERATE_V3:
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
int value, vlen = numeric_leaf(&value, &type->enumerate_v3.value);
|
|
|
|
const char* name = (const char*)&type->enumerate_v3.value + vlen;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
symt_add_enum_element(module, symt, name, value);
|
|
|
|
ptr += 2 + 2 + vlen + (1 + strlen(name));
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported type %04x in ENUM field list\n", type->generic.id);
|
2004-04-06 00:21:27 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2006-03-18 13:32:50 +01:00
|
|
|
return TRUE;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2006-03-18 13:32:56 +01:00
|
|
|
static void codeview_add_udt_element(struct codeview_type_parse* ctp,
|
|
|
|
struct symt_udt* symt, const char* name,
|
2006-03-18 13:33:11 +01:00
|
|
|
int value, unsigned type)
|
2006-03-18 13:32:56 +01:00
|
|
|
{
|
|
|
|
struct symt* subtype;
|
|
|
|
const union codeview_reftype*cv_type;
|
|
|
|
|
2006-03-18 13:33:11 +01:00
|
|
|
if ((cv_type = codeview_jump_to_type(ctp, type)))
|
2006-03-18 13:32:56 +01:00
|
|
|
{
|
|
|
|
switch (cv_type->generic.id)
|
|
|
|
{
|
|
|
|
case LF_BITFIELD_V1:
|
|
|
|
symt_add_udt_element(ctp->module, symt, name,
|
2008-02-06 21:55:10 +01:00
|
|
|
codeview_fetch_type(ctp, cv_type->bitfield_v1.type, FALSE),
|
2021-08-30 09:24:23 +02:00
|
|
|
value, cv_type->bitfield_v1.bitoff,
|
2006-03-18 13:32:56 +01:00
|
|
|
cv_type->bitfield_v1.nbits);
|
2006-03-18 13:33:11 +01:00
|
|
|
return;
|
2006-03-18 13:32:56 +01:00
|
|
|
case LF_BITFIELD_V2:
|
|
|
|
symt_add_udt_element(ctp->module, symt, name,
|
2008-02-06 21:55:10 +01:00
|
|
|
codeview_fetch_type(ctp, cv_type->bitfield_v2.type, FALSE),
|
2021-08-30 09:24:23 +02:00
|
|
|
value, cv_type->bitfield_v2.bitoff,
|
2006-03-18 13:32:56 +01:00
|
|
|
cv_type->bitfield_v2.nbits);
|
2006-03-18 13:33:11 +01:00
|
|
|
return;
|
2006-03-18 13:32:56 +01:00
|
|
|
}
|
|
|
|
}
|
2008-02-06 21:55:10 +01:00
|
|
|
subtype = codeview_fetch_type(ctp, type, FALSE);
|
2006-03-18 13:33:11 +01:00
|
|
|
|
|
|
|
if (subtype)
|
|
|
|
{
|
|
|
|
DWORD64 elem_size = 0;
|
2009-12-14 22:05:46 +01:00
|
|
|
symt_get_info(ctp->module, subtype, TI_GET_LENGTH, &elem_size);
|
2021-08-30 09:24:23 +02:00
|
|
|
symt_add_udt_element(ctp->module, symt, name, subtype, value, 0, 0);
|
2006-03-18 13:33:11 +01:00
|
|
|
}
|
2006-03-18 13:32:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static int codeview_add_type_struct_field_list(struct codeview_type_parse* ctp,
|
2006-03-18 13:32:50 +01:00
|
|
|
struct symt_udt* symt,
|
2006-03-18 13:33:11 +01:00
|
|
|
unsigned fieldlistno)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2006-03-18 13:33:11 +01:00
|
|
|
const unsigned char* ptr;
|
|
|
|
const unsigned char* last;
|
2005-03-29 13:30:57 +02:00
|
|
|
int value, leaf_len;
|
2004-11-21 16:51:47 +01:00
|
|
|
const struct p_string* p_name;
|
|
|
|
const char* c_name;
|
2006-03-18 13:33:11 +01:00
|
|
|
const union codeview_reftype*type_ref;
|
2006-03-18 13:32:50 +01:00
|
|
|
const union codeview_fieldtype* type;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-03-18 13:33:11 +01:00
|
|
|
if (!fieldlistno) return TRUE;
|
|
|
|
type_ref = codeview_jump_to_type(ctp, fieldlistno);
|
|
|
|
ptr = type_ref->fieldlist.list;
|
|
|
|
last = (const BYTE*)type_ref + type_ref->generic.len + 2;
|
|
|
|
|
2006-03-18 13:32:50 +01:00
|
|
|
while (ptr < last)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
if (*ptr >= 0xf0) /* LF_PAD... */
|
|
|
|
{
|
2006-03-18 13:32:50 +01:00
|
|
|
ptr += *ptr & 0x0f;
|
2004-04-06 00:21:27 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2006-03-18 13:32:50 +01:00
|
|
|
type = (const union codeview_fieldtype*)ptr;
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
switch (type->generic.id)
|
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_BCLASS_V1:
|
|
|
|
leaf_len = numeric_leaf(&value, &type->bclass_v1.offset);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
/* FIXME: ignored for now */
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 2 + leaf_len;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_BCLASS_V2:
|
|
|
|
leaf_len = numeric_leaf(&value, &type->bclass_v2.offset);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
/* FIXME: ignored for now */
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 4 + leaf_len;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_VBCLASS_V1:
|
|
|
|
case LF_IVBCLASS_V1:
|
|
|
|
{
|
2005-03-29 13:30:57 +02:00
|
|
|
const unsigned short int* p_vboff;
|
|
|
|
int vpoff, vplen;
|
2004-11-21 16:51:47 +01:00
|
|
|
leaf_len = numeric_leaf(&value, &type->vbclass_v1.vbpoff);
|
|
|
|
p_vboff = (const unsigned short int*)((const char*)&type->vbclass_v1.vbpoff + leaf_len);
|
|
|
|
vplen = numeric_leaf(&vpoff, p_vboff);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
/* FIXME: ignored for now */
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 2 + 2 + leaf_len + vplen;
|
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_VBCLASS_V2:
|
|
|
|
case LF_IVBCLASS_V2:
|
|
|
|
{
|
2005-03-29 13:30:57 +02:00
|
|
|
const unsigned short int* p_vboff;
|
|
|
|
int vpoff, vplen;
|
2004-11-21 16:51:47 +01:00
|
|
|
leaf_len = numeric_leaf(&value, &type->vbclass_v2.vbpoff);
|
|
|
|
p_vboff = (const unsigned short int*)((const char*)&type->vbclass_v2.vbpoff + leaf_len);
|
|
|
|
vplen = numeric_leaf(&vpoff, p_vboff);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
/* FIXME: ignored for now */
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 4 + 4 + leaf_len + vplen;
|
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_MEMBER_V1:
|
|
|
|
leaf_len = numeric_leaf(&value, &type->member_v1.offset);
|
|
|
|
p_name = (const struct p_string*)((const char*)&type->member_v1.offset + leaf_len);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-03-18 13:32:56 +01:00
|
|
|
codeview_add_udt_element(ctp, symt, terminate_string(p_name), value,
|
|
|
|
type->member_v1.type);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 2 + leaf_len + (1 + p_name->namelen);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_MEMBER_V2:
|
|
|
|
leaf_len = numeric_leaf(&value, &type->member_v2.offset);
|
|
|
|
p_name = (const struct p_string*)((const unsigned char*)&type->member_v2.offset + leaf_len);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-03-18 13:32:56 +01:00
|
|
|
codeview_add_udt_element(ctp, symt, terminate_string(p_name), value,
|
|
|
|
type->member_v2.type);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 4 + leaf_len + (1 + p_name->namelen);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_MEMBER_V3:
|
|
|
|
leaf_len = numeric_leaf(&value, &type->member_v3.offset);
|
|
|
|
c_name = (const char*)&type->member_v3.offset + leaf_len;
|
|
|
|
|
2006-03-18 13:33:20 +01:00
|
|
|
codeview_add_udt_element(ctp, symt, c_name, value, type->member_v3.type);
|
2004-11-21 16:51:47 +01:00
|
|
|
|
|
|
|
ptr += 2 + 2 + 4 + leaf_len + (strlen(c_name) + 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_STMEMBER_V1:
|
2004-04-06 00:21:27 +02:00
|
|
|
/* FIXME: ignored for now */
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 2 + (1 + type->stmember_v1.p_name.namelen);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_STMEMBER_V2:
|
2004-04-06 00:21:27 +02:00
|
|
|
/* FIXME: ignored for now */
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 4 + 2 + (1 + type->stmember_v2.p_name.namelen);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2008-02-06 21:55:28 +01:00
|
|
|
case LF_STMEMBER_V3:
|
|
|
|
/* FIXME: ignored for now */
|
|
|
|
ptr += 2 + 4 + 2 + (strlen(type->stmember_v3.name) + 1);
|
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_METHOD_V1:
|
2004-04-06 00:21:27 +02:00
|
|
|
/* FIXME: ignored for now */
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 2 + (1 + type->method_v1.p_name.namelen);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_METHOD_V2:
|
2004-04-06 00:21:27 +02:00
|
|
|
/* FIXME: ignored for now */
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 4 + (1 + type->method_v2.p_name.namelen);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2008-02-06 21:55:28 +01:00
|
|
|
case LF_METHOD_V3:
|
|
|
|
/* FIXME: ignored for now */
|
|
|
|
ptr += 2 + 2 + 4 + (strlen(type->method_v3.name) + 1);
|
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_NESTTYPE_V1:
|
2004-04-06 00:21:27 +02:00
|
|
|
/* FIXME: ignored for now */
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + (1 + type->nesttype_v1.p_name.namelen);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_NESTTYPE_V2:
|
2004-04-06 00:21:27 +02:00
|
|
|
/* FIXME: ignored for now */
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 4 + (1 + type->nesttype_v2.p_name.namelen);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2008-02-06 21:55:28 +01:00
|
|
|
case LF_NESTTYPE_V3:
|
|
|
|
/* FIXME: ignored for now */
|
|
|
|
ptr += 2 + 2 + 4 + (strlen(type->nesttype_v3.name) + 1);
|
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_VFUNCTAB_V1:
|
2004-04-06 00:21:27 +02:00
|
|
|
/* FIXME: ignored for now */
|
|
|
|
ptr += 2 + 2;
|
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_VFUNCTAB_V2:
|
2004-04-06 00:21:27 +02:00
|
|
|
/* FIXME: ignored for now */
|
|
|
|
ptr += 2 + 2 + 4;
|
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_ONEMETHOD_V1:
|
2004-04-06 00:21:27 +02:00
|
|
|
/* FIXME: ignored for now */
|
2004-11-21 16:51:47 +01:00
|
|
|
switch ((type->onemethod_v1.attribute >> 2) & 7)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
case 4: case 6: /* (pure) introducing virtual method */
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 2 + 4 + (1 + type->onemethod_virt_v1.p_name.namelen);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 2 + (1 + type->onemethod_v1.p_name.namelen);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
case LF_ONEMETHOD_V2:
|
2004-04-06 00:21:27 +02:00
|
|
|
/* FIXME: ignored for now */
|
2004-11-21 16:51:47 +01:00
|
|
|
switch ((type->onemethod_v2.attribute >> 2) & 7)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
case 4: case 6: /* (pure) introducing virtual method */
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 4 + 4 + (1 + type->onemethod_virt_v2.p_name.namelen);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2004-11-21 16:51:47 +01:00
|
|
|
ptr += 2 + 2 + 4 + (1 + type->onemethod_v2.p_name.namelen);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
2008-02-06 21:55:28 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_ONEMETHOD_V3:
|
|
|
|
/* FIXME: ignored for now */
|
|
|
|
switch ((type->onemethod_v3.attribute >> 2) & 7)
|
|
|
|
{
|
|
|
|
case 4: case 6: /* (pure) introducing virtual method */
|
|
|
|
ptr += 2 + 2 + 4 + 4 + (strlen(type->onemethod_virt_v3.name) + 1);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ptr += 2 + 2 + 4 + (strlen(type->onemethod_v3.name) + 1);
|
|
|
|
break;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-06-23 15:18:35 +02:00
|
|
|
case LF_INDEX_V1:
|
|
|
|
if (!codeview_add_type_struct_field_list(ctp, symt, type->index_v1.ref))
|
|
|
|
return FALSE;
|
|
|
|
ptr += 2 + 2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_INDEX_V2:
|
|
|
|
if (!codeview_add_type_struct_field_list(ctp, symt, type->index_v2.ref))
|
|
|
|
return FALSE;
|
|
|
|
ptr += 2 + 2 + 4;
|
|
|
|
break;
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
default:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported type %04x in STRUCT field list\n", type->generic.id);
|
2004-04-06 00:21:27 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-18 13:32:50 +01:00
|
|
|
return TRUE;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2006-03-18 13:33:11 +01:00
|
|
|
static struct symt* codeview_add_type_enum(struct codeview_type_parse* ctp,
|
|
|
|
struct symt* existing,
|
2006-03-18 13:33:06 +01:00
|
|
|
const char* name,
|
2008-02-06 21:55:59 +01:00
|
|
|
unsigned fieldlistno,
|
|
|
|
unsigned basetype)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2006-03-18 13:33:11 +01:00
|
|
|
struct symt_enum* symt;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-03-18 13:33:11 +01:00
|
|
|
if (existing)
|
|
|
|
{
|
|
|
|
if (!(symt = codeview_cast_symt(existing, SymTagEnum))) return NULL;
|
|
|
|
/* should also check that all fields are the same */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-02-06 21:55:59 +01:00
|
|
|
symt = symt_new_enum(ctp->module, name,
|
|
|
|
codeview_fetch_type(ctp, basetype, FALSE));
|
2006-03-18 13:33:11 +01:00
|
|
|
if (fieldlistno)
|
|
|
|
{
|
|
|
|
const union codeview_reftype* fieldlist;
|
|
|
|
fieldlist = codeview_jump_to_type(ctp, fieldlistno);
|
|
|
|
codeview_add_type_enum_field_list(ctp->module, symt, fieldlist);
|
|
|
|
}
|
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
return &symt->symt;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2006-03-18 13:33:06 +01:00
|
|
|
static struct symt* codeview_add_type_struct(struct codeview_type_parse* ctp,
|
2006-03-18 13:33:11 +01:00
|
|
|
struct symt* existing,
|
2008-11-10 11:14:45 +01:00
|
|
|
const char* name, int structlen,
|
|
|
|
enum UdtKind kind, unsigned property)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2006-03-18 13:33:11 +01:00
|
|
|
struct symt_udt* symt;
|
|
|
|
|
2008-11-10 11:14:45 +01:00
|
|
|
/* if we don't have an existing type, try to find one with same name
|
|
|
|
* FIXME: what to do when several types in different CUs have same name ?
|
|
|
|
*/
|
|
|
|
if (!existing)
|
|
|
|
{
|
|
|
|
void* ptr;
|
|
|
|
struct symt_ht* type;
|
|
|
|
struct hash_table_iter hti;
|
|
|
|
|
|
|
|
hash_table_iter_init(&ctp->module->ht_types, &hti, name);
|
|
|
|
while ((ptr = hash_table_iter_up(&hti)))
|
|
|
|
{
|
2016-03-08 11:44:26 +01:00
|
|
|
type = CONTAINING_RECORD(ptr, struct symt_ht, hash_elt);
|
2008-11-10 11:14:45 +01:00
|
|
|
|
|
|
|
if (type->symt.tag == SymTagUDT &&
|
|
|
|
type->hash_elt.name && !strcmp(type->hash_elt.name, name))
|
|
|
|
{
|
|
|
|
existing = &type->symt;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-03-18 13:33:11 +01:00
|
|
|
if (existing)
|
|
|
|
{
|
|
|
|
if (!(symt = codeview_cast_symt(existing, SymTagUDT))) return NULL;
|
|
|
|
/* should also check that all fields are the same */
|
2008-11-10 11:14:45 +01:00
|
|
|
if (!(property & 0x80)) /* 0x80 = forward declaration */
|
|
|
|
{
|
|
|
|
if (!symt->size) /* likely prior forward declaration, set UDT size */
|
|
|
|
symt_set_udt_size(ctp->module, symt, structlen);
|
|
|
|
else /* different UDT with same name, create a new type */
|
|
|
|
existing = NULL;
|
|
|
|
}
|
2006-03-18 13:33:11 +01:00
|
|
|
}
|
2008-11-10 11:14:45 +01:00
|
|
|
if (!existing) symt = symt_new_udt(ctp->module, name, structlen, kind);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-03-18 13:33:06 +01:00
|
|
|
return &symt->symt;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2006-03-18 13:33:11 +01:00
|
|
|
static struct symt* codeview_new_func_signature(struct codeview_type_parse* ctp,
|
|
|
|
struct symt* existing,
|
2006-03-18 13:33:06 +01:00
|
|
|
enum CV_call_e call_conv)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2006-03-18 13:33:00 +01:00
|
|
|
struct symt_function_signature* sym;
|
|
|
|
|
2006-03-18 13:33:11 +01:00
|
|
|
if (existing)
|
|
|
|
{
|
|
|
|
sym = codeview_cast_symt(existing, SymTagFunctionType);
|
|
|
|
if (!sym) return NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-03-04 17:04:07 +01:00
|
|
|
sym = symt_new_function_signature(ctp->module, NULL, call_conv);
|
2006-03-18 13:33:11 +01:00
|
|
|
}
|
2007-03-04 17:04:07 +01:00
|
|
|
return &sym->symt;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void codeview_add_func_signature_args(struct codeview_type_parse* ctp,
|
|
|
|
struct symt_function_signature* sym,
|
|
|
|
unsigned ret_type,
|
|
|
|
unsigned args_list)
|
|
|
|
{
|
|
|
|
const union codeview_reftype* reftype;
|
|
|
|
|
2008-02-06 21:55:10 +01:00
|
|
|
sym->rettype = codeview_fetch_type(ctp, ret_type, FALSE);
|
2006-03-18 13:33:11 +01:00
|
|
|
if (args_list && (reftype = codeview_jump_to_type(ctp, args_list)))
|
2006-03-18 13:33:00 +01:00
|
|
|
{
|
2008-09-24 21:50:05 +02:00
|
|
|
unsigned int i;
|
2006-03-18 13:33:00 +01:00
|
|
|
switch (reftype->generic.id)
|
|
|
|
{
|
|
|
|
case LF_ARGLIST_V1:
|
|
|
|
for (i = 0; i < reftype->arglist_v1.num; i++)
|
|
|
|
symt_add_function_signature_parameter(ctp->module, sym,
|
2008-02-06 21:55:10 +01:00
|
|
|
codeview_fetch_type(ctp, reftype->arglist_v1.args[i], FALSE));
|
2006-03-18 13:33:00 +01:00
|
|
|
break;
|
|
|
|
case LF_ARGLIST_V2:
|
|
|
|
for (i = 0; i < reftype->arglist_v2.num; i++)
|
|
|
|
symt_add_function_signature_parameter(ctp->module, sym,
|
2008-02-06 21:55:10 +01:00
|
|
|
codeview_fetch_type(ctp, reftype->arglist_v2.args[i], FALSE));
|
2006-03-18 13:33:00 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("Unexpected leaf %x for signature's pmt\n", reftype->generic.id);
|
|
|
|
}
|
|
|
|
}
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
|
|
|
|
2006-03-18 13:33:06 +01:00
|
|
|
static struct symt* codeview_parse_one_type(struct codeview_type_parse* ctp,
|
|
|
|
unsigned curr_type,
|
2006-03-18 13:33:11 +01:00
|
|
|
const union codeview_type* type, BOOL details)
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
2006-03-18 13:33:11 +01:00
|
|
|
struct symt* symt;
|
2004-11-21 16:51:47 +01:00
|
|
|
int value, leaf_len;
|
|
|
|
const struct p_string* p_name;
|
|
|
|
const char* c_name;
|
2006-03-18 13:33:11 +01:00
|
|
|
struct symt* existing;
|
|
|
|
|
|
|
|
existing = codeview_get_type(curr_type, TRUE);
|
2006-03-18 13:33:06 +01:00
|
|
|
|
|
|
|
switch (type->generic.id)
|
|
|
|
{
|
|
|
|
case LF_MODIFIER_V1:
|
2008-02-06 21:55:10 +01:00
|
|
|
/* FIXME: we don't handle modifiers,
|
|
|
|
* but read previous type on the curr_type
|
2006-03-18 13:33:06 +01:00
|
|
|
*/
|
|
|
|
WARN("Modifier on %x: %s%s%s%s\n",
|
|
|
|
type->modifier_v1.type,
|
|
|
|
type->modifier_v1.attribute & 0x01 ? "const " : "",
|
|
|
|
type->modifier_v1.attribute & 0x02 ? "volatile " : "",
|
|
|
|
type->modifier_v1.attribute & 0x04 ? "unaligned " : "",
|
|
|
|
type->modifier_v1.attribute & ~0x07 ? "unknown " : "");
|
2008-02-06 21:55:10 +01:00
|
|
|
symt = codeview_fetch_type(ctp, type->modifier_v1.type, details);
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
case LF_MODIFIER_V2:
|
|
|
|
/* FIXME: we don't handle modifiers, but readd previous type on the curr_type */
|
|
|
|
WARN("Modifier on %x: %s%s%s%s\n",
|
|
|
|
type->modifier_v2.type,
|
|
|
|
type->modifier_v2.attribute & 0x01 ? "const " : "",
|
|
|
|
type->modifier_v2.attribute & 0x02 ? "volatile " : "",
|
|
|
|
type->modifier_v2.attribute & 0x04 ? "unaligned " : "",
|
|
|
|
type->modifier_v2.attribute & ~0x07 ? "unknown " : "");
|
2008-02-06 21:55:10 +01:00
|
|
|
symt = codeview_fetch_type(ctp, type->modifier_v2.type, details);
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_POINTER_V1:
|
2006-03-18 13:33:11 +01:00
|
|
|
symt = codeview_add_type_pointer(ctp, existing, type->pointer_v1.datatype);
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
case LF_POINTER_V2:
|
2006-03-18 13:33:11 +01:00
|
|
|
symt = codeview_add_type_pointer(ctp, existing, type->pointer_v2.datatype);
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_ARRAY_V1:
|
2006-03-18 13:33:11 +01:00
|
|
|
if (existing) symt = codeview_cast_symt(existing, SymTagArrayType);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
leaf_len = numeric_leaf(&value, &type->array_v1.arrlen);
|
|
|
|
p_name = (const struct p_string*)((const unsigned char*)&type->array_v1.arrlen + leaf_len);
|
|
|
|
symt = codeview_add_type_array(ctp, terminate_string(p_name),
|
|
|
|
type->array_v1.elemtype,
|
|
|
|
type->array_v1.idxtype, value);
|
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
case LF_ARRAY_V2:
|
2006-03-18 13:33:11 +01:00
|
|
|
if (existing) symt = codeview_cast_symt(existing, SymTagArrayType);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
leaf_len = numeric_leaf(&value, &type->array_v2.arrlen);
|
|
|
|
p_name = (const struct p_string*)((const unsigned char*)&type->array_v2.arrlen + leaf_len);
|
2006-03-18 13:33:06 +01:00
|
|
|
|
2006-03-18 13:33:11 +01:00
|
|
|
symt = codeview_add_type_array(ctp, terminate_string(p_name),
|
|
|
|
type->array_v2.elemtype,
|
|
|
|
type->array_v2.idxtype, value);
|
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
case LF_ARRAY_V3:
|
2006-03-18 13:33:11 +01:00
|
|
|
if (existing) symt = codeview_cast_symt(existing, SymTagArrayType);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
leaf_len = numeric_leaf(&value, &type->array_v3.arrlen);
|
|
|
|
c_name = (const char*)&type->array_v3.arrlen + leaf_len;
|
2006-03-18 13:33:06 +01:00
|
|
|
|
2006-03-18 13:33:11 +01:00
|
|
|
symt = codeview_add_type_array(ctp, c_name,
|
|
|
|
type->array_v3.elemtype,
|
|
|
|
type->array_v3.idxtype, value);
|
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_STRUCTURE_V1:
|
|
|
|
case LF_CLASS_V1:
|
|
|
|
leaf_len = numeric_leaf(&value, &type->struct_v1.structlen);
|
|
|
|
p_name = (const struct p_string*)((const unsigned char*)&type->struct_v1.structlen + leaf_len);
|
2006-03-18 13:33:11 +01:00
|
|
|
symt = codeview_add_type_struct(ctp, existing, terminate_string(p_name), value,
|
2008-11-10 11:14:45 +01:00
|
|
|
type->generic.id == LF_CLASS_V1 ? UdtClass : UdtStruct,
|
|
|
|
type->struct_v1.property);
|
2006-03-18 13:33:11 +01:00
|
|
|
if (details)
|
|
|
|
{
|
|
|
|
codeview_add_type(curr_type, symt);
|
2011-05-01 09:46:29 +02:00
|
|
|
if (!(type->struct_v1.property & 0x80)) /* 0x80 = forward declaration */
|
|
|
|
codeview_add_type_struct_field_list(ctp, (struct symt_udt*)symt,
|
|
|
|
type->struct_v1.fieldlist);
|
2006-03-18 13:33:11 +01:00
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_STRUCTURE_V2:
|
|
|
|
case LF_CLASS_V2:
|
|
|
|
leaf_len = numeric_leaf(&value, &type->struct_v2.structlen);
|
|
|
|
p_name = (const struct p_string*)((const unsigned char*)&type->struct_v2.structlen + leaf_len);
|
2006-03-18 13:33:11 +01:00
|
|
|
symt = codeview_add_type_struct(ctp, existing, terminate_string(p_name), value,
|
2008-11-10 11:14:45 +01:00
|
|
|
type->generic.id == LF_CLASS_V2 ? UdtClass : UdtStruct,
|
|
|
|
type->struct_v2.property);
|
2006-03-18 13:33:11 +01:00
|
|
|
if (details)
|
|
|
|
{
|
|
|
|
codeview_add_type(curr_type, symt);
|
2011-05-01 09:46:29 +02:00
|
|
|
if (!(type->struct_v2.property & 0x80)) /* 0x80 = forward declaration */
|
|
|
|
codeview_add_type_struct_field_list(ctp, (struct symt_udt*)symt,
|
|
|
|
type->struct_v2.fieldlist);
|
2006-03-18 13:33:11 +01:00
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_STRUCTURE_V3:
|
|
|
|
case LF_CLASS_V3:
|
|
|
|
leaf_len = numeric_leaf(&value, &type->struct_v3.structlen);
|
|
|
|
c_name = (const char*)&type->struct_v3.structlen + leaf_len;
|
2006-03-18 13:33:11 +01:00
|
|
|
symt = codeview_add_type_struct(ctp, existing, c_name, value,
|
2008-11-10 11:14:45 +01:00
|
|
|
type->generic.id == LF_CLASS_V3 ? UdtClass : UdtStruct,
|
|
|
|
type->struct_v3.property);
|
2006-03-18 13:33:11 +01:00
|
|
|
if (details)
|
|
|
|
{
|
|
|
|
codeview_add_type(curr_type, symt);
|
2011-05-01 09:46:29 +02:00
|
|
|
if (!(type->struct_v3.property & 0x80)) /* 0x80 = forward declaration */
|
|
|
|
codeview_add_type_struct_field_list(ctp, (struct symt_udt*)symt,
|
|
|
|
type->struct_v3.fieldlist);
|
2006-03-18 13:33:11 +01:00
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_UNION_V1:
|
|
|
|
leaf_len = numeric_leaf(&value, &type->union_v1.un_len);
|
|
|
|
p_name = (const struct p_string*)((const unsigned char*)&type->union_v1.un_len + leaf_len);
|
2006-03-18 13:33:11 +01:00
|
|
|
symt = codeview_add_type_struct(ctp, existing, terminate_string(p_name),
|
2008-11-10 11:14:45 +01:00
|
|
|
value, UdtUnion, type->union_v1.property);
|
2006-03-18 13:33:11 +01:00
|
|
|
if (details)
|
|
|
|
{
|
|
|
|
codeview_add_type(curr_type, symt);
|
|
|
|
codeview_add_type_struct_field_list(ctp, (struct symt_udt*)symt,
|
|
|
|
type->union_v1.fieldlist);
|
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_UNION_V2:
|
|
|
|
leaf_len = numeric_leaf(&value, &type->union_v2.un_len);
|
|
|
|
p_name = (const struct p_string*)((const unsigned char*)&type->union_v2.un_len + leaf_len);
|
2006-03-18 13:33:11 +01:00
|
|
|
symt = codeview_add_type_struct(ctp, existing, terminate_string(p_name),
|
2008-11-10 11:14:45 +01:00
|
|
|
value, UdtUnion, type->union_v2.property);
|
2006-03-18 13:33:11 +01:00
|
|
|
if (details)
|
|
|
|
{
|
|
|
|
codeview_add_type(curr_type, symt);
|
|
|
|
codeview_add_type_struct_field_list(ctp, (struct symt_udt*)symt,
|
|
|
|
type->union_v2.fieldlist);
|
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
2006-03-18 13:33:11 +01:00
|
|
|
|
2006-03-18 13:33:06 +01:00
|
|
|
case LF_UNION_V3:
|
|
|
|
leaf_len = numeric_leaf(&value, &type->union_v3.un_len);
|
|
|
|
c_name = (const char*)&type->union_v3.un_len + leaf_len;
|
2006-03-18 13:33:11 +01:00
|
|
|
symt = codeview_add_type_struct(ctp, existing, c_name,
|
2008-11-10 11:14:45 +01:00
|
|
|
value, UdtUnion, type->union_v3.property);
|
2006-03-18 13:33:11 +01:00
|
|
|
if (details)
|
|
|
|
{
|
|
|
|
codeview_add_type(curr_type, symt);
|
|
|
|
codeview_add_type_struct_field_list(ctp, (struct symt_udt*)symt,
|
|
|
|
type->union_v3.fieldlist);
|
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_ENUM_V1:
|
2006-03-18 13:33:11 +01:00
|
|
|
symt = codeview_add_type_enum(ctp, existing,
|
2006-03-18 13:33:06 +01:00
|
|
|
terminate_string(&type->enumeration_v1.p_name),
|
2008-02-06 21:55:59 +01:00
|
|
|
type->enumeration_v1.fieldlist,
|
|
|
|
type->enumeration_v1.type);
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_ENUM_V2:
|
2006-03-18 13:33:11 +01:00
|
|
|
symt = codeview_add_type_enum(ctp, existing,
|
2006-03-18 13:33:06 +01:00
|
|
|
terminate_string(&type->enumeration_v2.p_name),
|
2008-02-06 21:55:59 +01:00
|
|
|
type->enumeration_v2.fieldlist,
|
|
|
|
type->enumeration_v2.type);
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_ENUM_V3:
|
2006-03-18 13:33:11 +01:00
|
|
|
symt = codeview_add_type_enum(ctp, existing, type->enumeration_v3.name,
|
2008-02-06 21:55:59 +01:00
|
|
|
type->enumeration_v3.fieldlist,
|
|
|
|
type->enumeration_v3.type);
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LF_PROCEDURE_V1:
|
2021-08-21 10:22:48 +02:00
|
|
|
symt = codeview_new_func_signature(ctp, existing, type->procedure_v1.callconv);
|
2007-03-04 17:04:07 +01:00
|
|
|
if (details)
|
|
|
|
{
|
|
|
|
codeview_add_type(curr_type, symt);
|
|
|
|
codeview_add_func_signature_args(ctp,
|
|
|
|
(struct symt_function_signature*)symt,
|
|
|
|
type->procedure_v1.rvtype,
|
|
|
|
type->procedure_v1.arglist);
|
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
case LF_PROCEDURE_V2:
|
2021-08-21 10:22:48 +02:00
|
|
|
symt = codeview_new_func_signature(ctp, existing,type->procedure_v2.callconv);
|
2007-03-04 17:04:07 +01:00
|
|
|
if (details)
|
|
|
|
{
|
|
|
|
codeview_add_type(curr_type, symt);
|
|
|
|
codeview_add_func_signature_args(ctp,
|
|
|
|
(struct symt_function_signature*)symt,
|
|
|
|
type->procedure_v2.rvtype,
|
|
|
|
type->procedure_v2.arglist);
|
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
2007-03-04 17:04:07 +01:00
|
|
|
|
2006-03-18 13:33:06 +01:00
|
|
|
case LF_MFUNCTION_V1:
|
|
|
|
/* FIXME: for C++, this is plain wrong, but as we don't use arg types
|
|
|
|
* nor class information, this would just do for now
|
|
|
|
*/
|
2021-08-21 10:22:48 +02:00
|
|
|
symt = codeview_new_func_signature(ctp, existing, type->mfunction_v1.callconv);
|
2007-03-04 17:04:07 +01:00
|
|
|
if (details)
|
|
|
|
{
|
|
|
|
codeview_add_type(curr_type, symt);
|
|
|
|
codeview_add_func_signature_args(ctp,
|
|
|
|
(struct symt_function_signature*)symt,
|
|
|
|
type->mfunction_v1.rvtype,
|
|
|
|
type->mfunction_v1.arglist);
|
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
case LF_MFUNCTION_V2:
|
|
|
|
/* FIXME: for C++, this is plain wrong, but as we don't use arg types
|
|
|
|
* nor class information, this would just do for now
|
|
|
|
*/
|
2021-08-21 10:22:48 +02:00
|
|
|
symt = codeview_new_func_signature(ctp, existing, type->mfunction_v2.callconv);
|
2007-03-04 17:04:07 +01:00
|
|
|
if (details)
|
|
|
|
{
|
|
|
|
codeview_add_type(curr_type, symt);
|
|
|
|
codeview_add_func_signature_args(ctp,
|
|
|
|
(struct symt_function_signature*)symt,
|
|
|
|
type->mfunction_v2.rvtype,
|
|
|
|
type->mfunction_v2.arglist);
|
|
|
|
}
|
2006-03-18 13:33:06 +01:00
|
|
|
break;
|
|
|
|
|
2006-03-18 13:33:16 +01:00
|
|
|
case LF_VTSHAPE_V1:
|
|
|
|
/* this is an ugly hack... FIXME when we have C++ support */
|
|
|
|
if (!(symt = existing))
|
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
snprintf(buf, sizeof(buf), "__internal_vt_shape_%x\n", curr_type);
|
|
|
|
symt = &symt_new_udt(ctp->module, buf, 0, UdtStruct)->symt;
|
|
|
|
}
|
|
|
|
break;
|
2006-03-18 13:33:06 +01:00
|
|
|
default:
|
|
|
|
FIXME("Unsupported type-id leaf %x\n", type->generic.id);
|
|
|
|
dump(type, 2 + type->generic.len);
|
2013-11-12 01:16:36 +01:00
|
|
|
return NULL;
|
2006-03-18 13:33:06 +01:00
|
|
|
}
|
2006-03-18 13:33:11 +01:00
|
|
|
return codeview_add_type(curr_type, symt) ? symt : NULL;
|
2006-03-18 13:33:06 +01:00
|
|
|
}
|
|
|
|
|
2013-11-12 01:16:36 +01:00
|
|
|
static BOOL codeview_parse_type_table(struct codeview_type_parse* ctp)
|
2006-03-18 13:33:06 +01:00
|
|
|
{
|
|
|
|
unsigned int curr_type = FIRST_DEFINABLE_TYPE;
|
|
|
|
const union codeview_type* type;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-03-18 13:33:06 +01:00
|
|
|
for (curr_type = FIRST_DEFINABLE_TYPE; curr_type < FIRST_DEFINABLE_TYPE + ctp->num; curr_type++)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2006-03-18 13:32:50 +01:00
|
|
|
type = codeview_jump_to_type(ctp, curr_type);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-03-18 13:32:44 +01:00
|
|
|
/* type records we're interested in are the ones referenced by symbols
|
|
|
|
* The known ranges are (X mark the ones we want):
|
|
|
|
* X 0000-0016 for V1 types
|
|
|
|
* 0200-020c for V1 types referenced by other types
|
|
|
|
* 0400-040f for V1 types (complex lists & sets)
|
|
|
|
* X 1000-100f for V2 types
|
|
|
|
* 1200-120c for V2 types referenced by other types
|
|
|
|
* 1400-140f for V1 types (complex lists & sets)
|
|
|
|
* X 1500-150d for V3 types
|
|
|
|
* 8000-8010 for numeric leafes
|
|
|
|
*/
|
2008-01-27 19:04:26 +01:00
|
|
|
if (!(type->generic.id & 0x8600) || (type->generic.id & 0x0100))
|
|
|
|
codeview_parse_one_type(ctp, curr_type, type, TRUE);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2006-03-18 13:33:06 +01:00
|
|
|
return TRUE;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*========================================================================
|
|
|
|
* Process CodeView line number information.
|
|
|
|
*/
|
2020-03-26 16:51:49 +01:00
|
|
|
static ULONG_PTR codeview_get_address(const struct msc_debug_info* msc_dbg,
|
2010-10-09 08:51:09 +02:00
|
|
|
unsigned seg, unsigned offset);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2008-09-29 21:32:29 +02:00
|
|
|
static void codeview_snarf_linetab(const struct msc_debug_info* msc_dbg, const BYTE* linetab,
|
|
|
|
int size, BOOL pascal_str)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2008-09-29 21:32:29 +02:00
|
|
|
const BYTE* ptr = linetab;
|
|
|
|
int nfile, nseg;
|
2013-01-14 22:44:19 +01:00
|
|
|
int i, j;
|
|
|
|
unsigned int k;
|
2004-04-06 00:21:27 +02:00
|
|
|
const unsigned int* filetab;
|
2004-05-18 23:29:09 +02:00
|
|
|
const unsigned int* lt_ptr;
|
2008-09-29 21:32:29 +02:00
|
|
|
const unsigned short* linenos;
|
2004-05-18 23:29:09 +02:00
|
|
|
const struct startend* start;
|
2006-03-18 13:32:31 +01:00
|
|
|
unsigned source;
|
2020-03-26 16:51:49 +01:00
|
|
|
ULONG_PTR addr, func_addr0;
|
2008-09-29 21:32:29 +02:00
|
|
|
struct symt_function* func;
|
|
|
|
const struct codeview_linetab_block* ltb;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2008-09-29 21:32:29 +02:00
|
|
|
nfile = *(const short*)linetab;
|
|
|
|
filetab = (const unsigned int*)(linetab + 2 * sizeof(short));
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
for (i = 0; i < nfile; i++)
|
|
|
|
{
|
2008-09-29 21:32:29 +02:00
|
|
|
ptr = linetab + filetab[i];
|
|
|
|
nseg = *(const short*)ptr;
|
|
|
|
lt_ptr = (const unsigned int*)(ptr + 2 * sizeof(short));
|
|
|
|
start = (const struct startend*)(lt_ptr + nseg);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now snarf the filename for all of the segments for this file.
|
|
|
|
*/
|
2004-11-21 16:51:47 +01:00
|
|
|
if (pascal_str)
|
2008-09-29 21:32:29 +02:00
|
|
|
source = source_new(msc_dbg->module, NULL, terminate_string((const struct p_string*)(start + nseg)));
|
2004-11-21 16:51:47 +01:00
|
|
|
else
|
2008-09-29 21:32:29 +02:00
|
|
|
source = source_new(msc_dbg->module, NULL, (const char*)(start + nseg));
|
|
|
|
|
|
|
|
for (j = 0; j < nseg; j++)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2008-09-29 21:32:29 +02:00
|
|
|
ltb = (const struct codeview_linetab_block*)(linetab + *lt_ptr++);
|
|
|
|
linenos = (const unsigned short*)<b->offsets[ltb->num_lines];
|
|
|
|
func_addr0 = codeview_get_address(msc_dbg, ltb->seg, start[j].start);
|
|
|
|
if (!func_addr0) continue;
|
|
|
|
for (func = NULL, k = 0; k < ltb->num_lines; k++)
|
|
|
|
{
|
|
|
|
/* now locate function (if any) */
|
|
|
|
addr = func_addr0 + ltb->offsets[k] - start[j].start;
|
2011-07-30 12:03:08 +02:00
|
|
|
/* unfortunately, we can have several functions in the same block, if there's no
|
2008-09-29 21:32:29 +02:00
|
|
|
* gap between them... find the new function if needed
|
|
|
|
*/
|
|
|
|
if (!func || addr >= func->address + func->size)
|
|
|
|
{
|
|
|
|
func = (struct symt_function*)symt_find_nearest(msc_dbg->module, addr);
|
|
|
|
/* FIXME: at least labels support line numbers */
|
2021-10-28 08:57:24 +02:00
|
|
|
if (!symt_check_tag(&func->symt, SymTagFunction) && !symt_check_tag(&func->symt, SymTagInlineSite))
|
2008-09-29 21:32:29 +02:00
|
|
|
{
|
2022-02-09 09:26:26 +01:00
|
|
|
WARN("--not a func at %04x:%08x %Ix tag=%d\n",
|
2008-09-29 21:32:29 +02:00
|
|
|
ltb->seg, ltb->offsets[k], addr, func ? func->symt.tag : -1);
|
|
|
|
func = NULL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-10-29 15:37:04 +02:00
|
|
|
symt_add_func_line(msc_dbg->module, func, source, linenos[k], addr);
|
2008-09-29 21:32:29 +02:00
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-08 14:59:20 +01:00
|
|
|
static void codeview_snarf_linetab2(const struct msc_debug_info* msc_dbg, const struct cv_module_snarf* cvmod)
|
2008-09-29 21:32:38 +02:00
|
|
|
{
|
|
|
|
unsigned i;
|
2021-11-08 14:59:20 +01:00
|
|
|
const void* hdr_last = (const char*)cvmod->dbgsubsect + cvmod->dbgsubsect_size;
|
2021-11-02 15:32:37 +01:00
|
|
|
const struct CV_DebugSSubsectionHeader_t* hdr;
|
|
|
|
const struct CV_DebugSSubsectionHeader_t* hdr_next;
|
|
|
|
const struct CV_DebugSSubsectionHeader_t* hdr_files = NULL;
|
|
|
|
const struct CV_DebugSLinesHeader_t* lines_hdr;
|
|
|
|
const struct CV_DebugSLinesFileBlockHeader_t* files_hdr;
|
|
|
|
const struct CV_Line_t* lines;
|
|
|
|
const struct CV_Checksum_t* chksms;
|
2008-09-29 21:32:38 +02:00
|
|
|
unsigned source;
|
|
|
|
struct symt_function* func;
|
|
|
|
|
2021-11-02 15:32:37 +01:00
|
|
|
/* locate DEBUG_S_FILECHKSMS (if any) */
|
2021-11-08 14:59:20 +01:00
|
|
|
for (hdr = cvmod->dbgsubsect; CV_IS_INSIDE(hdr, hdr_last); hdr = CV_RECORD_GAP(hdr, hdr->cbLen))
|
2008-09-29 21:32:38 +02:00
|
|
|
{
|
2021-11-02 15:32:37 +01:00
|
|
|
if (hdr->type == DEBUG_S_FILECHKSMS)
|
2008-09-29 21:32:38 +02:00
|
|
|
{
|
2021-11-02 15:32:37 +01:00
|
|
|
hdr_files = hdr;
|
2008-09-29 21:32:38 +02:00
|
|
|
break;
|
|
|
|
}
|
2009-10-31 14:57:40 +01:00
|
|
|
}
|
2021-11-02 15:32:37 +01:00
|
|
|
if (!hdr_files)
|
2009-10-31 14:57:40 +01:00
|
|
|
{
|
2021-11-02 15:32:37 +01:00
|
|
|
TRACE("No DEBUG_S_FILECHKSMS found\n");
|
2009-10-31 14:57:40 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-11-08 14:59:20 +01:00
|
|
|
for (hdr = cvmod->dbgsubsect; CV_IS_INSIDE(hdr, hdr_last); hdr = hdr_next)
|
2009-10-31 14:57:40 +01:00
|
|
|
{
|
2021-11-02 15:32:37 +01:00
|
|
|
hdr_next = CV_RECORD_GAP(hdr, hdr->cbLen);
|
|
|
|
if (!(hdr->type & DEBUG_S_IGNORE))
|
2008-09-29 21:32:38 +02:00
|
|
|
{
|
2021-11-08 14:59:47 +01:00
|
|
|
ULONG_PTR lineblk_base;
|
2021-11-02 15:32:37 +01:00
|
|
|
/* FIXME: should also check that whole lines_blk fits in linetab + size */
|
|
|
|
switch (hdr->type)
|
2009-10-31 14:57:40 +01:00
|
|
|
{
|
2021-11-02 15:32:37 +01:00
|
|
|
case DEBUG_S_LINES:
|
|
|
|
lines_hdr = CV_RECORD_AFTER(hdr);
|
|
|
|
files_hdr = CV_RECORD_AFTER(lines_hdr);
|
|
|
|
/* Skip blocks that are too small - Intel C Compiler generates these. */
|
|
|
|
if (!CV_IS_INSIDE(files_hdr, hdr_next)) break;
|
|
|
|
TRACE("block from %04x:%08x #%x\n",
|
|
|
|
lines_hdr->segCon, lines_hdr->offCon, lines_hdr->cbCon);
|
|
|
|
chksms = CV_RECORD_GAP(hdr_files, files_hdr->offFile);
|
|
|
|
if (!CV_IS_INSIDE(chksms, CV_RECORD_GAP(hdr_files, hdr_files->cbLen)))
|
|
|
|
{
|
|
|
|
WARN("Corrupt PDB file: offset in CHKSMS subsection is invalid\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
source = source_new(msc_dbg->module, NULL,
|
2021-11-08 14:59:20 +01:00
|
|
|
(chksms->strOffset < cvmod->strsize) ? cvmod->strimage + chksms->strOffset : "<<stroutofbounds>>");
|
2021-11-08 14:59:47 +01:00
|
|
|
lineblk_base = codeview_get_address(msc_dbg, lines_hdr->segCon, lines_hdr->offCon);
|
2021-11-02 15:32:37 +01:00
|
|
|
lines = CV_RECORD_AFTER(files_hdr);
|
|
|
|
for (i = 0; i < files_hdr->nLines; i++)
|
|
|
|
{
|
2021-11-08 14:59:47 +01:00
|
|
|
func = (struct symt_function*)symt_find_nearest(msc_dbg->module, lineblk_base + lines[i].offset);
|
|
|
|
/* FIXME: at least labels support line numbers */
|
|
|
|
if (!symt_check_tag(&func->symt, SymTagFunction) && !symt_check_tag(&func->symt, SymTagInlineSite))
|
|
|
|
{
|
|
|
|
WARN("--not a func at %04x:%08x %Ix tag=%d\n",
|
|
|
|
lines_hdr->segCon, lines_hdr->offCon + lines[i].offset, lineblk_base + lines[i].offset, func ? func->symt.tag : -1);
|
|
|
|
continue;
|
|
|
|
}
|
2021-11-02 15:32:37 +01:00
|
|
|
symt_add_func_line(msc_dbg->module, func, source,
|
2021-11-08 14:59:47 +01:00
|
|
|
lines[i].linenumStart, lineblk_base + lines[i].offset);
|
2021-11-02 15:32:37 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DEBUG_S_FILECHKSMS: /* skip */
|
|
|
|
break;
|
|
|
|
default:
|
2009-10-31 14:57:40 +01:00
|
|
|
break;
|
|
|
|
}
|
2008-09-29 21:32:38 +02:00
|
|
|
}
|
2021-11-02 15:32:37 +01:00
|
|
|
hdr = hdr_next;
|
2008-09-29 21:32:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/*========================================================================
|
|
|
|
* Process CodeView symbol information.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static unsigned int codeview_map_offset(const struct msc_debug_info* msc_dbg,
|
|
|
|
unsigned int offset)
|
|
|
|
{
|
|
|
|
int nomap = msc_dbg->nomap;
|
2021-11-02 15:33:04 +01:00
|
|
|
const OMAP* omapp = msc_dbg->omapp;
|
2004-04-06 00:21:27 +02:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!nomap || !omapp) return offset;
|
|
|
|
|
|
|
|
/* FIXME: use binary search */
|
|
|
|
for (i = 0; i < nomap - 1; i++)
|
2021-11-02 15:33:04 +01:00
|
|
|
if (omapp[i].rva <= offset && omapp[i+1].rva > offset)
|
|
|
|
return !omapp[i].rvaTo ? 0 : omapp[i].rvaTo + (offset - omapp[i].rva);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-03-26 16:51:49 +01:00
|
|
|
static ULONG_PTR codeview_get_address(const struct msc_debug_info* msc_dbg,
|
2010-10-09 08:51:09 +02:00
|
|
|
unsigned seg, unsigned offset)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
int nsect = msc_dbg->nsect;
|
|
|
|
const IMAGE_SECTION_HEADER* sectp = msc_dbg->sectp;
|
|
|
|
|
|
|
|
if (!seg || seg > nsect) return 0;
|
|
|
|
return msc_dbg->module->module.BaseOfImage +
|
|
|
|
codeview_map_offset(msc_dbg, sectp[seg-1].VirtualAddress + offset);
|
|
|
|
}
|
|
|
|
|
2021-11-08 14:58:39 +01:00
|
|
|
static BOOL func_has_local(struct symt_function* func, const char* name)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < func->vchildren.num_elts; ++i)
|
|
|
|
{
|
|
|
|
struct symt* p = *(struct symt**)vector_at(&func->vchildren, i);
|
|
|
|
if (symt_check_tag(p, SymTagData) && !strcmp(((struct symt_data*)p)->hash_elt.name, name))
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const union codeview_symbol* get_next_sym(const union codeview_symbol* sym)
|
|
|
|
{
|
|
|
|
return (const union codeview_symbol*)((const char*)sym + sym->generic.len + 2);
|
|
|
|
}
|
|
|
|
|
2008-09-06 22:20:19 +02:00
|
|
|
static inline void codeview_add_variable(const struct msc_debug_info* msc_dbg,
|
|
|
|
struct symt_compiland* compiland,
|
|
|
|
const char* name,
|
|
|
|
unsigned segment, unsigned offset,
|
2011-01-29 20:38:15 +01:00
|
|
|
unsigned symtype, BOOL is_local, BOOL in_tls, BOOL force)
|
2008-09-06 22:20:19 +02:00
|
|
|
{
|
|
|
|
if (name && *name)
|
|
|
|
{
|
2011-01-29 20:38:04 +01:00
|
|
|
struct location loc;
|
2008-09-06 22:20:19 +02:00
|
|
|
|
2011-01-29 20:38:15 +01:00
|
|
|
loc.kind = in_tls ? loc_tlsrel : loc_absolute;
|
2011-01-29 20:38:04 +01:00
|
|
|
loc.reg = 0;
|
2011-01-29 20:38:15 +01:00
|
|
|
loc.offset = in_tls ? offset : codeview_get_address(msc_dbg, segment, offset);
|
|
|
|
if (force || in_tls || !symt_find_nearest(msc_dbg->module, loc.offset))
|
2008-09-06 22:20:19 +02:00
|
|
|
{
|
|
|
|
symt_new_global_variable(msc_dbg->module, compiland,
|
2011-01-29 20:38:04 +01:00
|
|
|
name, is_local, loc, 0,
|
2008-09-06 22:20:19 +02:00
|
|
|
codeview_get_type(symtype, FALSE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-08 14:58:39 +01:00
|
|
|
struct cv_local_info
|
|
|
|
{
|
|
|
|
unsigned short kind; /* the S_DEFRANGE* */
|
|
|
|
unsigned short ngaps; /* number of gaps */
|
|
|
|
unsigned short reg;
|
|
|
|
unsigned short rangelen; /* after start */
|
|
|
|
short offset;
|
|
|
|
DWORD_PTR start;
|
|
|
|
struct cv_addr_gap gaps[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct cv_addr_gap* codeview_get_gaps(const union codeview_symbol* symrange)
|
|
|
|
{
|
|
|
|
const struct cv_addr_gap* gap;
|
|
|
|
switch (symrange->generic.id)
|
|
|
|
{
|
|
|
|
case S_DEFRANGE: gap = symrange->defrange_v3.gaps; break;
|
|
|
|
case S_DEFRANGE_SUBFIELD: gap = symrange->defrange_subfield_v3.gaps; break;
|
|
|
|
case S_DEFRANGE_REGISTER: gap = symrange->defrange_register_v3.gaps; break;
|
|
|
|
case S_DEFRANGE_FRAMEPOINTER_REL: gap = symrange->defrange_frameptrrel_v3.gaps; break;
|
|
|
|
case S_DEFRANGE_SUBFIELD_REGISTER: gap = symrange->defrange_subfield_register_v3.gaps; break;
|
|
|
|
case S_DEFRANGE_REGISTER_REL: gap = symrange->defrange_registerrel_v3.gaps; break;
|
|
|
|
/* no gaps for that one */
|
|
|
|
case S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE:
|
|
|
|
default: return NULL;
|
|
|
|
}
|
|
|
|
return gap != (const struct cv_addr_gap*)get_next_sym(symrange) ? gap : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void codeview_xform_range(const struct msc_debug_info* msc_dbg,
|
|
|
|
struct cv_local_info* locinfo,
|
|
|
|
const struct cv_addr_range* adrange)
|
|
|
|
{
|
|
|
|
locinfo->start = codeview_get_address(msc_dbg, adrange->isectStart, adrange->offStart);
|
|
|
|
locinfo->rangelen = adrange->cbRange;
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned codeview_transform_defrange(const struct msc_debug_info* msc_dbg,
|
|
|
|
struct symt_function* curr_func,
|
|
|
|
const union codeview_symbol* sym,
|
|
|
|
struct location* loc)
|
|
|
|
{
|
|
|
|
const union codeview_symbol* first_symrange = get_next_sym(sym);
|
|
|
|
const union codeview_symbol* symrange;
|
|
|
|
const struct cv_addr_gap* gap;
|
|
|
|
unsigned len, alloc = sizeof(DWORD); /* for terminating kind = 0 */
|
|
|
|
unsigned char* ptr;
|
|
|
|
|
|
|
|
/* we need to transform the cv_addr_range into cv_local_info */
|
|
|
|
for (symrange = first_symrange;
|
|
|
|
symrange->generic.id >= S_DEFRANGE && symrange->generic.id <= S_DEFRANGE_REGISTER_REL;
|
|
|
|
symrange = get_next_sym(symrange))
|
|
|
|
{
|
|
|
|
gap = codeview_get_gaps(symrange);
|
|
|
|
alloc += sizeof(struct cv_local_info) +
|
|
|
|
(gap ? (const char*)get_next_sym(symrange) - (const char*)gap : 0);
|
|
|
|
}
|
|
|
|
/* total length of all S_DEFRANGE* records (in bytes) following S_LOCAL */
|
|
|
|
len = (const char*)symrange - (const char*)first_symrange;
|
|
|
|
|
|
|
|
ptr = pool_alloc(&msc_dbg->module->pool, alloc);
|
|
|
|
if (ptr)
|
|
|
|
{
|
|
|
|
struct cv_local_info* locinfo = (struct cv_local_info*)ptr;
|
|
|
|
|
|
|
|
loc->kind = loc_cv_local_range;
|
|
|
|
loc->offset = (DWORD_PTR)ptr;
|
|
|
|
/* transform the cv_addr_range into cv_local_info */
|
|
|
|
for (symrange = first_symrange;
|
|
|
|
symrange->generic.id >= S_DEFRANGE && symrange->generic.id <= S_DEFRANGE_REGISTER_REL;
|
|
|
|
symrange = get_next_sym(symrange))
|
|
|
|
{
|
|
|
|
locinfo->kind = symrange->generic.id;
|
|
|
|
switch (symrange->generic.id)
|
|
|
|
{
|
|
|
|
case S_DEFRANGE:
|
2021-11-08 14:58:53 +01:00
|
|
|
codeview_xform_range(msc_dbg, locinfo, &symrange->defrange_v3.range);
|
|
|
|
/* FIXME: transformation unsupported; let loc_compute bark if actually needed */
|
|
|
|
break;
|
2021-11-08 14:58:39 +01:00
|
|
|
case S_DEFRANGE_SUBFIELD:
|
2021-11-08 14:58:53 +01:00
|
|
|
codeview_xform_range(msc_dbg, locinfo, &symrange->defrange_subfield_v3.range);
|
2021-11-08 14:58:39 +01:00
|
|
|
/* FIXME: transformation unsupported; let loc_compute bark if actually needed */
|
|
|
|
break;
|
|
|
|
case S_DEFRANGE_REGISTER:
|
|
|
|
locinfo->reg = symrange->defrange_register_v3.reg;
|
|
|
|
codeview_xform_range(msc_dbg, locinfo, &symrange->defrange_register_v3.range);
|
|
|
|
break;
|
|
|
|
case S_DEFRANGE_FRAMEPOINTER_REL:
|
|
|
|
locinfo->offset = symrange->defrange_frameptrrel_v3.offFramePointer;
|
|
|
|
codeview_xform_range(msc_dbg, locinfo, &symrange->defrange_frameptrrel_v3.range);
|
|
|
|
break;
|
|
|
|
case S_DEFRANGE_SUBFIELD_REGISTER:
|
|
|
|
locinfo->reg = symrange->defrange_subfield_register_v3.reg;
|
|
|
|
locinfo->offset = symrange->defrange_subfield_register_v3.offParent;
|
|
|
|
codeview_xform_range(msc_dbg, locinfo, &symrange->defrange_subfield_register_v3.range);
|
|
|
|
break;
|
|
|
|
case S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE:
|
|
|
|
locinfo->offset = symrange->defrange_frameptr_relfullscope_v3.offFramePointer;
|
|
|
|
locinfo->start = curr_func->address;
|
|
|
|
locinfo->rangelen = curr_func->size;
|
|
|
|
break;
|
|
|
|
case S_DEFRANGE_REGISTER_REL:
|
|
|
|
locinfo->reg = symrange->defrange_registerrel_v3.baseReg;
|
|
|
|
locinfo->offset = symrange->defrange_registerrel_v3.offBasePointer;
|
|
|
|
codeview_xform_range(msc_dbg, locinfo, &symrange->defrange_registerrel_v3.range);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
gap = codeview_get_gaps(symrange);
|
|
|
|
if (gap)
|
|
|
|
{
|
|
|
|
unsigned gaplen = (const char*)get_next_sym(symrange) - (const char*)gap;
|
|
|
|
locinfo->ngaps = gaplen / sizeof(*gap);
|
|
|
|
memcpy(locinfo->gaps, gap, gaplen);
|
2021-11-08 14:58:53 +01:00
|
|
|
locinfo = (struct cv_local_info*)((char*)(locinfo + 1) + gaplen);
|
2021-11-08 14:58:39 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
locinfo->ngaps = 0;
|
|
|
|
locinfo++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*(DWORD*)locinfo = 0; /* store terminating kind == 0 */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
loc->kind = loc_error;
|
|
|
|
loc->reg = loc_err_internal;
|
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
2021-11-08 14:59:34 +01:00
|
|
|
static unsigned codeview_binannot_uncompress(const unsigned char** pptr)
|
|
|
|
{
|
|
|
|
unsigned res = (unsigned)(-1);
|
|
|
|
const unsigned char* ptr = *pptr;
|
|
|
|
|
|
|
|
if ((*ptr & 0x80) == 0x00)
|
|
|
|
res = (unsigned)(*ptr++);
|
|
|
|
else if ((*ptr & 0xC0) == 0x80)
|
|
|
|
{
|
|
|
|
res = (unsigned)((*ptr++ & 0x3f) << 8);
|
|
|
|
res |= *ptr++;
|
|
|
|
}
|
|
|
|
else if ((*ptr & 0xE0) == 0xC0)
|
|
|
|
{
|
|
|
|
res = (*ptr++ & 0x1f) << 24;
|
|
|
|
res |= *ptr++ << 16;
|
|
|
|
res |= *ptr++ << 8;
|
|
|
|
res |= *ptr++;
|
|
|
|
}
|
|
|
|
else res = (unsigned)(-1);
|
|
|
|
*pptr = ptr;
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct cv_binannot
|
|
|
|
{
|
|
|
|
const unsigned char* annot; /* current pointer */
|
|
|
|
const unsigned char* last_annot; /* end of binary annotation stream (first byte after) */
|
|
|
|
unsigned opcode; /* last decoded opcode */
|
|
|
|
unsigned arg1, arg2;
|
|
|
|
};
|
|
|
|
|
|
|
|
static BOOL codeview_advance_binannot(struct cv_binannot* cvba)
|
|
|
|
{
|
|
|
|
if (cvba->annot >= cvba->last_annot) return FALSE;
|
|
|
|
cvba->opcode = codeview_binannot_uncompress(&cvba->annot);
|
|
|
|
if (cvba->opcode <= BA_OP_Invalid || cvba->opcode > BA_OP_ChangeColumnEnd) return FALSE;
|
|
|
|
if (cvba->annot >= cvba->last_annot) return FALSE;
|
|
|
|
cvba->arg1 = codeview_binannot_uncompress(&cvba->annot);
|
|
|
|
if (cvba->opcode == BA_OP_ChangeCodeOffsetAndLineOffset)
|
|
|
|
{
|
|
|
|
cvba->arg2 = cvba->arg1 >> 4;
|
|
|
|
cvba->arg1 &= 0x0F;
|
|
|
|
}
|
|
|
|
else if (cvba->opcode == BA_OP_ChangeCodeLengthAndCodeOffset)
|
|
|
|
{
|
|
|
|
if (cvba->annot >= cvba->last_annot) return FALSE;
|
|
|
|
cvba->arg2 = codeview_binannot_uncompress(&cvba->annot);
|
|
|
|
}
|
|
|
|
else cvba->arg2 = 0;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-11-08 15:00:01 +01:00
|
|
|
static inline int binannot_getsigned(unsigned i)
|
|
|
|
{
|
|
|
|
return (i & 1) ? -(int)(i >> 1) : (int)(i >> 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL cv_dbgsubsect_find_inlinee(const struct msc_debug_info* msc_dbg,
|
|
|
|
unsigned inlineeid,
|
|
|
|
const struct cv_module_snarf* cvmod,
|
|
|
|
const struct CV_DebugSSubsectionHeader_t* hdr_files,
|
|
|
|
unsigned* srcfile, unsigned* srcline)
|
|
|
|
{
|
|
|
|
const struct CV_DebugSSubsectionHeader_t* hdr;
|
|
|
|
const struct CV_DebugSSubsectionHeader_t* next_hdr;
|
|
|
|
const struct CV_InlineeSourceLine_t* inlsrc;
|
|
|
|
const struct CV_InlineeSourceLineEx_t* inlsrcex;
|
|
|
|
const struct CV_Checksum_t* chksms;
|
|
|
|
|
|
|
|
for (hdr = cvmod->dbgsubsect; CV_IS_INSIDE(hdr, cvmod->dbgsubsect + cvmod->dbgsubsect_size); hdr = next_hdr)
|
|
|
|
{
|
|
|
|
next_hdr = CV_RECORD_GAP(hdr, hdr->cbLen);
|
|
|
|
if (hdr->type != DEBUG_S_INLINEELINES) continue;
|
|
|
|
/* subsection starts with a DWORD signature */
|
|
|
|
switch (*(DWORD*)CV_RECORD_AFTER(hdr))
|
|
|
|
{
|
|
|
|
case CV_INLINEE_SOURCE_LINE_SIGNATURE:
|
|
|
|
inlsrc = CV_RECORD_GAP(hdr, sizeof(DWORD));
|
|
|
|
while (CV_IS_INSIDE(inlsrc, next_hdr))
|
|
|
|
{
|
|
|
|
if (inlsrc->inlinee == inlineeid)
|
|
|
|
{
|
|
|
|
chksms = CV_RECORD_GAP(hdr_files, inlsrc->fileId);
|
|
|
|
if (!CV_IS_INSIDE(chksms, CV_RECORD_GAP(hdr_files, hdr_files->cbLen))) return FALSE;
|
|
|
|
*srcfile = source_new(msc_dbg->module, NULL,
|
|
|
|
(chksms->strOffset < cvmod->strsize) ? cvmod->strimage + chksms->strOffset : "<<str-out-of-bounds>>");
|
|
|
|
*srcline = inlsrc->sourceLineNum;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
++inlsrc;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CV_INLINEE_SOURCE_LINE_SIGNATURE_EX:
|
|
|
|
inlsrcex = CV_RECORD_GAP(hdr, sizeof(DWORD));
|
|
|
|
while (CV_IS_INSIDE(inlsrcex, next_hdr))
|
|
|
|
{
|
|
|
|
if (inlsrcex->inlinee == inlineeid)
|
|
|
|
{
|
|
|
|
chksms = CV_RECORD_GAP(hdr_files, inlsrcex->fileId);
|
|
|
|
if (!CV_IS_INSIDE(chksms, CV_RECORD_GAP(hdr_files, hdr_files->cbLen))) return FALSE;
|
|
|
|
*srcfile = source_new(msc_dbg->module, NULL,
|
|
|
|
(chksms->strOffset < cvmod->strsize) ? cvmod->strimage + chksms->strOffset : "<<str-out-of-bounds>>");
|
|
|
|
*srcline = inlsrcex->sourceLineNum;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
inlsrcex = CV_RECORD_GAP(inlsrcex, inlsrcex->countOfExtraFiles * sizeof(inlsrcex->extraFileId[0]));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2022-02-09 09:26:26 +01:00
|
|
|
FIXME("Unknown signature %lx in INLINEELINES subsection\n", *(DWORD*)CV_RECORD_AFTER(hdr));
|
2021-11-08 15:00:01 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-11-08 14:59:34 +01:00
|
|
|
static struct symt_inlinesite* codeview_create_inline_site(const struct msc_debug_info* msc_dbg,
|
|
|
|
const struct cv_module_snarf* cvmod,
|
|
|
|
struct symt_function* top_func,
|
|
|
|
struct symt* container,
|
|
|
|
cv_itemid_t inlinee,
|
|
|
|
const unsigned char* annot,
|
|
|
|
const unsigned char* last_annot)
|
|
|
|
{
|
|
|
|
const struct CV_DebugSSubsectionHeader_t* hdr_files = NULL;
|
|
|
|
const union codeview_type* cvt;
|
|
|
|
DWORD64 addr;
|
|
|
|
struct symt_inlinesite* inlined;
|
|
|
|
struct cv_binannot cvba;
|
2021-11-08 15:00:01 +01:00
|
|
|
BOOL srcok, found = FALSE;
|
|
|
|
unsigned first, offset, length, line, srcfile;
|
|
|
|
const struct CV_Checksum_t* chksms;
|
2021-11-08 14:59:34 +01:00
|
|
|
|
|
|
|
if (!cvmod->ipi_ctp || !(cvt = codeview_jump_to_type(cvmod->ipi_ctp, inlinee)))
|
|
|
|
{
|
|
|
|
FIXME("Couldn't find type %x in IPI stream\n", inlinee);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
addr = top_func->address;
|
|
|
|
/* grasp first code offset in binary annotation to compute inline site start address */
|
|
|
|
cvba.annot = annot;
|
|
|
|
cvba.last_annot = last_annot;
|
|
|
|
while (codeview_advance_binannot(&cvba))
|
|
|
|
if (cvba.opcode == BA_OP_CodeOffset ||
|
|
|
|
cvba.opcode == BA_OP_ChangeCodeOffset ||
|
|
|
|
cvba.opcode == BA_OP_ChangeCodeOffsetAndLineOffset)
|
|
|
|
{
|
|
|
|
addr += first = cvba.arg1;
|
|
|
|
length = 0;
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (cvba.opcode == BA_OP_ChangeCodeLengthAndCodeOffset)
|
|
|
|
{
|
|
|
|
addr += first = cvba.arg2;
|
|
|
|
length = cvba.arg1;
|
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
offset = first;
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
{
|
2021-12-15 13:32:00 +01:00
|
|
|
WARN("Couldn't find start address of inlined\n");
|
2021-11-08 14:59:34 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (cvt->generic.id)
|
|
|
|
{
|
|
|
|
case LF_FUNC_ID:
|
|
|
|
inlined = symt_new_inlinesite(msc_dbg->module, top_func, container,
|
|
|
|
cvt->func_id_v3.name, addr,
|
|
|
|
codeview_get_type(cvt->func_id_v3.type, FALSE));
|
|
|
|
break;
|
|
|
|
case LF_MFUNC_ID:
|
|
|
|
/* FIXME we just declare a function, not a method */
|
|
|
|
inlined = symt_new_inlinesite(msc_dbg->module, top_func, container,
|
|
|
|
cvt->mfunc_id_v3.name, addr,
|
|
|
|
codeview_get_type(cvt->mfunc_id_v3.type, FALSE));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("unsupported inlinee kind %x\n", cvt->generic.id);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (hdr_files = cvmod->dbgsubsect;
|
|
|
|
CV_IS_INSIDE(hdr_files, cvmod->dbgsubsect + cvmod->dbgsubsect_size);
|
|
|
|
hdr_files = CV_RECORD_GAP(hdr_files, hdr_files->cbLen))
|
|
|
|
{
|
|
|
|
if (hdr_files->type == DEBUG_S_FILECHKSMS)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!hdr_files) return FALSE;
|
2021-11-08 15:00:01 +01:00
|
|
|
srcok = cv_dbgsubsect_find_inlinee(msc_dbg, inlinee, cvmod, hdr_files, &srcfile, &line);
|
2021-11-08 14:59:34 +01:00
|
|
|
|
2021-11-08 15:00:01 +01:00
|
|
|
if (srcok)
|
|
|
|
symt_add_func_line(msc_dbg->module, &inlined->func, srcfile, line, top_func->address + offset);
|
|
|
|
else
|
|
|
|
srcfile = line = 0;
|
2021-11-08 14:59:34 +01:00
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (!codeview_advance_binannot(&cvba)) break;
|
|
|
|
switch (cvba.opcode)
|
|
|
|
{
|
|
|
|
case BA_OP_CodeOffset:
|
|
|
|
first = offset = cvba.arg1;
|
|
|
|
length = 1;
|
|
|
|
break;
|
|
|
|
case BA_OP_ChangeCodeOffset:
|
|
|
|
offset += cvba.arg1;
|
|
|
|
length = 1;
|
2021-11-08 15:00:01 +01:00
|
|
|
if (srcok)
|
|
|
|
symt_add_func_line(msc_dbg->module, &inlined->func, srcfile, line, top_func->address + offset);
|
2021-11-08 14:59:34 +01:00
|
|
|
break;
|
|
|
|
case BA_OP_ChangeCodeLength:
|
|
|
|
length = cvba.arg1;
|
|
|
|
break;
|
|
|
|
case BA_OP_ChangeFile:
|
2021-11-08 15:00:01 +01:00
|
|
|
chksms = CV_RECORD_GAP(hdr_files, cvba.arg1);
|
|
|
|
if (CV_IS_INSIDE(chksms, CV_RECORD_GAP(hdr_files, hdr_files->cbLen)))
|
|
|
|
srcfile = source_new(msc_dbg->module, NULL,
|
|
|
|
(chksms->strOffset < cvmod->strsize) ? cvmod->strimage + chksms->strOffset : "<<str-out-of-bounds>>");
|
2021-11-08 14:59:34 +01:00
|
|
|
break;
|
|
|
|
case BA_OP_ChangeLineOffset:
|
2021-11-08 15:00:01 +01:00
|
|
|
line += binannot_getsigned(cvba.arg1);
|
2021-11-08 14:59:34 +01:00
|
|
|
break;
|
|
|
|
case BA_OP_ChangeCodeOffsetAndLineOffset:
|
2021-11-08 15:00:01 +01:00
|
|
|
if (srcok)
|
|
|
|
symt_add_func_line(msc_dbg->module, &inlined->func, srcfile, line, top_func->address + offset);
|
|
|
|
line += binannot_getsigned(cvba.arg2);
|
2021-11-08 14:59:34 +01:00
|
|
|
offset += cvba.arg1;
|
|
|
|
length = 1;
|
|
|
|
break;
|
|
|
|
case BA_OP_ChangeCodeLengthAndCodeOffset:
|
|
|
|
offset += cvba.arg2;
|
|
|
|
length = cvba.arg1;
|
2021-11-08 15:00:01 +01:00
|
|
|
if (srcok)
|
|
|
|
symt_add_func_line(msc_dbg->module, &inlined->func, srcfile, line, top_func->address + offset);
|
2021-11-08 14:59:34 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WARN("Unsupported op %d\n", cvba.opcode);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
symt_add_inlinesite_range(msc_dbg->module, inlined, top_func->address + first, top_func->address + offset + length);
|
|
|
|
return inlined;
|
|
|
|
}
|
|
|
|
|
2021-11-08 14:59:20 +01:00
|
|
|
static BOOL codeview_snarf(const struct msc_debug_info* msc_dbg,
|
|
|
|
const BYTE* root, unsigned offset, unsigned size,
|
|
|
|
const struct cv_module_snarf* cvmod,
|
|
|
|
BOOL do_globals)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2021-11-08 14:59:34 +01:00
|
|
|
struct symt_function* top_func = NULL;
|
2004-04-06 00:21:27 +02:00
|
|
|
struct symt_function* curr_func = NULL;
|
|
|
|
int i, length;
|
2004-04-19 04:58:27 +02:00
|
|
|
struct symt_block* block = NULL;
|
|
|
|
struct symt* symt;
|
2006-03-18 13:32:31 +01:00
|
|
|
struct symt_compiland* compiland = NULL;
|
2006-11-24 22:17:38 +01:00
|
|
|
struct location loc;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop over the different types of records and whenever we
|
|
|
|
* find something we are interested in, record it and move on.
|
|
|
|
*/
|
|
|
|
for (i = offset; i < size; i += length)
|
|
|
|
{
|
|
|
|
const union codeview_symbol* sym = (const union codeview_symbol*)(root + i);
|
|
|
|
length = sym->generic.len + 2;
|
2005-03-29 13:30:57 +02:00
|
|
|
if (i + length > size) break;
|
2008-04-05 09:34:07 +02:00
|
|
|
if (!sym->generic.id || length < 4) break;
|
2005-03-29 13:30:57 +02:00
|
|
|
if (length & 3) FIXME("unpadded len %u\n", length);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
switch (sym->generic.id)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Global and local data symbols. We don't associate these
|
|
|
|
* with any given source file.
|
|
|
|
*/
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GDATA32_16t:
|
|
|
|
case S_LDATA32_16t:
|
2008-09-06 22:20:19 +02:00
|
|
|
if (do_globals)
|
|
|
|
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->data_v1.p_name),
|
|
|
|
sym->data_v1.segment, sym->data_v1.offset, sym->data_v1.symtype,
|
2021-03-20 14:48:38 +01:00
|
|
|
sym->generic.id == S_LDATA32_16t, FALSE, TRUE);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GDATA32_ST:
|
|
|
|
case S_LDATA32_ST:
|
2008-09-06 22:20:19 +02:00
|
|
|
if (do_globals)
|
|
|
|
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->data_v2.p_name),
|
|
|
|
sym->data_v2.segment, sym->data_v2.offset, sym->data_v2.symtype,
|
2021-03-20 14:48:38 +01:00
|
|
|
sym->generic.id == S_LDATA32_ST, FALSE, TRUE);
|
2004-11-21 16:51:47 +01:00
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GDATA32:
|
|
|
|
case S_LDATA32:
|
2008-09-06 22:20:19 +02:00
|
|
|
if (do_globals)
|
|
|
|
codeview_add_variable(msc_dbg, compiland, sym->data_v3.name,
|
|
|
|
sym->data_v3.segment, sym->data_v3.offset, sym->data_v3.symtype,
|
2021-03-20 14:48:38 +01:00
|
|
|
sym->generic.id == S_LDATA32, FALSE, TRUE);
|
2011-01-29 20:38:15 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* variables with thread storage */
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GTHREAD32_16t:
|
|
|
|
case S_LTHREAD32_16t:
|
2011-01-29 20:38:15 +01:00
|
|
|
if (do_globals)
|
|
|
|
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->thread_v1.p_name),
|
|
|
|
sym->thread_v1.segment, sym->thread_v1.offset, sym->thread_v1.symtype,
|
2021-03-20 14:48:38 +01:00
|
|
|
sym->generic.id == S_LTHREAD32_16t, TRUE, TRUE);
|
2011-01-29 20:38:15 +01:00
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GTHREAD32_ST:
|
|
|
|
case S_LTHREAD32_ST:
|
2011-01-29 20:38:15 +01:00
|
|
|
if (do_globals)
|
|
|
|
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->thread_v2.p_name),
|
|
|
|
sym->thread_v2.segment, sym->thread_v2.offset, sym->thread_v2.symtype,
|
2021-03-20 14:48:38 +01:00
|
|
|
sym->generic.id == S_LTHREAD32_ST, TRUE, TRUE);
|
2011-01-29 20:38:15 +01:00
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GTHREAD32:
|
|
|
|
case S_LTHREAD32:
|
2011-01-29 20:38:15 +01:00
|
|
|
if (do_globals)
|
|
|
|
codeview_add_variable(msc_dbg, compiland, sym->thread_v3.name,
|
|
|
|
sym->thread_v3.segment, sym->thread_v3.offset, sym->thread_v3.symtype,
|
2021-03-20 14:48:38 +01:00
|
|
|
sym->generic.id == S_LTHREAD32, TRUE, TRUE);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
2008-09-06 22:20:19 +02:00
|
|
|
/* Public symbols */
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_PUB32_16t:
|
|
|
|
case S_PUB32_ST:
|
|
|
|
case S_PUB32:
|
|
|
|
case S_PROCREF:
|
|
|
|
case S_LPROCREF:
|
2008-09-06 22:20:19 +02:00
|
|
|
/* will be handled later on in codeview_snarf_public */
|
2004-11-21 16:51:47 +01:00
|
|
|
break;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Sort of like a global function, but it just points
|
|
|
|
* to a thunk, which is a stupid name for what amounts to
|
|
|
|
* a PLT slot in the normal jargon that everyone else uses.
|
|
|
|
*/
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_THUNK32_ST:
|
2006-03-18 13:32:31 +01:00
|
|
|
symt_new_thunk(msc_dbg->module, compiland,
|
2004-11-21 16:51:47 +01:00
|
|
|
terminate_string(&sym->thunk_v1.p_name), sym->thunk_v1.thtype,
|
|
|
|
codeview_get_address(msc_dbg, sym->thunk_v1.segment, sym->thunk_v1.offset),
|
|
|
|
sym->thunk_v1.thunk_len);
|
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_THUNK32:
|
2006-03-18 13:32:31 +01:00
|
|
|
symt_new_thunk(msc_dbg->module, compiland,
|
2004-11-21 16:51:47 +01:00
|
|
|
sym->thunk_v3.name, sym->thunk_v3.thtype,
|
|
|
|
codeview_get_address(msc_dbg, sym->thunk_v3.segment, sym->thunk_v3.offset),
|
|
|
|
sym->thunk_v3.thunk_len);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Global and static functions.
|
|
|
|
*/
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GPROC32_16t:
|
|
|
|
case S_LPROC32_16t:
|
2021-11-08 14:59:34 +01:00
|
|
|
if (top_func) FIXME("nested function\n");
|
|
|
|
top_func = symt_new_function(msc_dbg->module, compiland,
|
|
|
|
terminate_string(&sym->proc_v1.p_name),
|
|
|
|
codeview_get_address(msc_dbg, sym->proc_v1.segment, sym->proc_v1.offset),
|
|
|
|
sym->proc_v1.proc_len,
|
|
|
|
codeview_get_type(sym->proc_v1.proctype, FALSE));
|
|
|
|
curr_func = top_func;
|
2006-11-24 22:17:54 +01:00
|
|
|
loc.kind = loc_absolute;
|
|
|
|
loc.offset = sym->proc_v1.debug_start;
|
|
|
|
symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugStart, &loc, NULL);
|
|
|
|
loc.offset = sym->proc_v1.debug_end;
|
|
|
|
symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugEnd, &loc, NULL);
|
2004-11-21 16:51:47 +01:00
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GPROC32_ST:
|
|
|
|
case S_LPROC32_ST:
|
2021-11-08 14:59:34 +01:00
|
|
|
if (top_func) FIXME("nested function\n");
|
|
|
|
top_func = symt_new_function(msc_dbg->module, compiland,
|
|
|
|
terminate_string(&sym->proc_v2.p_name),
|
|
|
|
codeview_get_address(msc_dbg, sym->proc_v2.segment, sym->proc_v2.offset),
|
|
|
|
sym->proc_v2.proc_len,
|
|
|
|
codeview_get_type(sym->proc_v2.proctype, FALSE));
|
|
|
|
curr_func = top_func;
|
2006-11-24 22:17:54 +01:00
|
|
|
loc.kind = loc_absolute;
|
|
|
|
loc.offset = sym->proc_v2.debug_start;
|
|
|
|
symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugStart, &loc, NULL);
|
|
|
|
loc.offset = sym->proc_v2.debug_end;
|
|
|
|
symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugEnd, &loc, NULL);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GPROC32:
|
|
|
|
case S_LPROC32:
|
2021-11-08 14:59:34 +01:00
|
|
|
if (top_func) FIXME("nested function\n");
|
|
|
|
top_func = symt_new_function(msc_dbg->module, compiland,
|
|
|
|
sym->proc_v3.name,
|
|
|
|
codeview_get_address(msc_dbg, sym->proc_v3.segment, sym->proc_v3.offset),
|
|
|
|
sym->proc_v3.proc_len,
|
|
|
|
codeview_get_type(sym->proc_v3.proctype, FALSE));
|
|
|
|
curr_func = top_func;
|
2006-11-24 22:17:54 +01:00
|
|
|
loc.kind = loc_absolute;
|
|
|
|
loc.offset = sym->proc_v3.debug_start;
|
|
|
|
symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugStart, &loc, NULL);
|
|
|
|
loc.offset = sym->proc_v3.debug_end;
|
|
|
|
symt_add_function_point(msc_dbg->module, curr_func, SymTagFuncDebugEnd, &loc, NULL);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
/*
|
|
|
|
* Function parameters and stack variables.
|
|
|
|
*/
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_BPREL32_16t:
|
2006-11-24 22:17:38 +01:00
|
|
|
loc.kind = loc_regrel;
|
2011-04-11 20:47:13 +02:00
|
|
|
/* Yes, it's i386 dependent, but that's the symbol purpose. S_REGREL is used on other CPUs */
|
|
|
|
loc.reg = CV_REG_EBP;
|
2006-11-24 22:17:38 +01:00
|
|
|
loc.offset = sym->stack_v1.offset;
|
2021-03-20 14:48:38 +01:00
|
|
|
symt_add_func_local(msc_dbg->module, curr_func,
|
|
|
|
sym->stack_v1.offset > 0 ? DataIsParam : DataIsLocal,
|
2006-11-24 22:17:38 +01:00
|
|
|
&loc, block,
|
2006-09-25 22:40:41 +02:00
|
|
|
codeview_get_type(sym->stack_v1.symtype, FALSE),
|
|
|
|
terminate_string(&sym->stack_v1.p_name));
|
2004-11-21 16:51:47 +01:00
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_BPREL32_ST:
|
2006-11-24 22:17:38 +01:00
|
|
|
loc.kind = loc_regrel;
|
2011-04-11 20:47:13 +02:00
|
|
|
/* Yes, it's i386 dependent, but that's the symbol purpose. S_REGREL is used on other CPUs */
|
|
|
|
loc.reg = CV_REG_EBP;
|
2006-11-24 22:17:38 +01:00
|
|
|
loc.offset = sym->stack_v2.offset;
|
2021-03-20 14:48:38 +01:00
|
|
|
symt_add_func_local(msc_dbg->module, curr_func,
|
|
|
|
sym->stack_v2.offset > 0 ? DataIsParam : DataIsLocal,
|
2006-11-24 22:17:38 +01:00
|
|
|
&loc, block,
|
2006-06-18 21:31:55 +02:00
|
|
|
codeview_get_type(sym->stack_v2.symtype, FALSE),
|
2004-11-21 16:51:47 +01:00
|
|
|
terminate_string(&sym->stack_v2.p_name));
|
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_BPREL32:
|
2021-11-08 14:58:39 +01:00
|
|
|
/* S_BPREL32 can be present after S_LOCAL; prefer S_LOCAL when present */
|
|
|
|
if (func_has_local(curr_func, sym->stack_v3.name)) break;
|
2006-11-24 22:17:38 +01:00
|
|
|
loc.kind = loc_regrel;
|
2011-04-11 20:47:13 +02:00
|
|
|
/* Yes, it's i386 dependent, but that's the symbol purpose. S_REGREL is used on other CPUs */
|
|
|
|
loc.reg = CV_REG_EBP;
|
2006-11-24 22:17:38 +01:00
|
|
|
loc.offset = sym->stack_v3.offset;
|
2021-03-20 14:48:38 +01:00
|
|
|
symt_add_func_local(msc_dbg->module, curr_func,
|
|
|
|
sym->stack_v3.offset > 0 ? DataIsParam : DataIsLocal,
|
2006-11-24 22:17:38 +01:00
|
|
|
&loc, block,
|
2006-06-18 21:31:55 +02:00
|
|
|
codeview_get_type(sym->stack_v3.symtype, FALSE),
|
2004-11-21 16:51:47 +01:00
|
|
|
sym->stack_v3.name);
|
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_REGREL32:
|
2021-11-08 14:58:39 +01:00
|
|
|
/* S_REGREL32 can be present after S_LOCAL; prefer S_LOCAL when present */
|
|
|
|
if (func_has_local(curr_func, sym->regrel_v3.name)) break;
|
2008-02-06 21:55:40 +01:00
|
|
|
loc.kind = loc_regrel;
|
2010-10-09 08:51:47 +02:00
|
|
|
loc.reg = sym->regrel_v3.reg;
|
|
|
|
loc.offset = sym->regrel_v3.offset;
|
2008-02-06 21:55:40 +01:00
|
|
|
symt_add_func_local(msc_dbg->module, curr_func,
|
2010-10-09 08:51:47 +02:00
|
|
|
/* FIXME this is wrong !!! */
|
|
|
|
sym->regrel_v3.offset > 0 ? DataIsParam : DataIsLocal,
|
2008-02-06 21:55:40 +01:00
|
|
|
&loc, block,
|
2010-10-09 08:51:47 +02:00
|
|
|
codeview_get_type(sym->regrel_v3.symtype, FALSE),
|
|
|
|
sym->regrel_v3.name);
|
2008-02-06 21:55:40 +01:00
|
|
|
break;
|
2004-11-21 16:51:47 +01:00
|
|
|
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_REGISTER_16t:
|
2006-11-24 22:17:38 +01:00
|
|
|
loc.kind = loc_register;
|
|
|
|
loc.reg = sym->register_v1.reg;
|
|
|
|
loc.offset = 0;
|
2021-03-20 14:48:38 +01:00
|
|
|
symt_add_func_local(msc_dbg->module, curr_func,
|
2006-11-24 22:17:38 +01:00
|
|
|
DataIsLocal, &loc,
|
2004-11-21 16:51:47 +01:00
|
|
|
block, codeview_get_type(sym->register_v1.type, FALSE),
|
|
|
|
terminate_string(&sym->register_v1.p_name));
|
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_REGISTER_ST:
|
2006-11-24 22:17:38 +01:00
|
|
|
loc.kind = loc_register;
|
|
|
|
loc.reg = sym->register_v2.reg;
|
|
|
|
loc.offset = 0;
|
2021-03-20 14:48:38 +01:00
|
|
|
symt_add_func_local(msc_dbg->module, curr_func,
|
2006-11-24 22:17:38 +01:00
|
|
|
DataIsLocal, &loc,
|
2004-11-21 16:51:47 +01:00
|
|
|
block, codeview_get_type(sym->register_v2.type, FALSE),
|
|
|
|
terminate_string(&sym->register_v2.p_name));
|
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_REGISTER:
|
2021-11-08 14:58:39 +01:00
|
|
|
/* S_REGISTER can be present after S_LOCAL; prefer S_LOCAL when present */
|
|
|
|
if (func_has_local(curr_func, sym->register_v3.name)) break;
|
2008-02-06 21:55:34 +01:00
|
|
|
loc.kind = loc_register;
|
|
|
|
loc.reg = sym->register_v3.reg;
|
|
|
|
loc.offset = 0;
|
|
|
|
symt_add_func_local(msc_dbg->module, curr_func,
|
|
|
|
DataIsLocal, &loc,
|
|
|
|
block, codeview_get_type(sym->register_v3.type, FALSE),
|
|
|
|
sym->register_v3.name);
|
|
|
|
break;
|
2004-11-21 16:51:47 +01:00
|
|
|
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_BLOCK32_ST:
|
|
|
|
block = symt_open_func_block(msc_dbg->module, curr_func, block,
|
2021-11-10 16:42:03 +01:00
|
|
|
codeview_get_address(msc_dbg, sym->block_v1.segment, sym->block_v1.offset) - curr_func->address,
|
2004-11-21 16:51:47 +01:00
|
|
|
sym->block_v1.length);
|
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_BLOCK32:
|
|
|
|
block = symt_open_func_block(msc_dbg->module, curr_func, block,
|
2021-11-10 16:42:03 +01:00
|
|
|
codeview_get_address(msc_dbg, sym->block_v3.segment, sym->block_v3.offset) - curr_func->address,
|
2004-11-21 16:51:47 +01:00
|
|
|
sym->block_v3.length);
|
2004-04-19 04:58:27 +02:00
|
|
|
break;
|
|
|
|
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_END:
|
2004-04-19 04:58:27 +02:00
|
|
|
if (block)
|
|
|
|
{
|
|
|
|
block = symt_close_func_block(msc_dbg->module, curr_func, block, 0);
|
|
|
|
}
|
2021-11-08 14:59:34 +01:00
|
|
|
else if (top_func)
|
2004-04-19 04:58:27 +02:00
|
|
|
{
|
2021-11-08 14:59:34 +01:00
|
|
|
if (curr_func != top_func) FIXME("shouldn't close a top function with an opened inlined function\n");
|
|
|
|
top_func = curr_func = NULL;
|
2004-04-19 04:58:27 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_COMPILE:
|
2021-08-21 10:23:13 +02:00
|
|
|
TRACE("S-Compile-V1 machine:%x language:%x %s\n",
|
|
|
|
sym->compile_v1.machine, sym->compile_v1.flags.language, terminate_string(&sym->compile_v1.p_name));
|
2004-11-21 16:51:47 +01:00
|
|
|
break;
|
|
|
|
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_COMPILE2_ST:
|
2021-08-21 10:23:13 +02:00
|
|
|
TRACE("S-Compile-V2 machine:%x language:%x %s\n",
|
|
|
|
sym->compile2_v2.machine, sym->compile2_v2.flags.iLanguage, terminate_string(&sym->compile2_v2.p_name));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_COMPILE2:
|
|
|
|
TRACE("S-Compile-V3 machine:%x language:%x %s\n", sym->compile2_v3.machine, sym->compile2_v3.flags.iLanguage, sym->compile2_v3.name);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_COMPILE3:
|
|
|
|
TRACE("S-Compile3-V3 machine:%x language:%x %s\n", sym->compile3_v3.machine, sym->compile3_v3.flags.iLanguage, sym->compile3_v3.name);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_ENVBLOCK:
|
2004-11-21 16:51:47 +01:00
|
|
|
break;
|
2021-08-21 10:23:00 +02:00
|
|
|
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_OBJNAME:
|
2021-08-21 10:23:00 +02:00
|
|
|
TRACE("S-ObjName-V3 %s\n", sym->objname_v3.name);
|
|
|
|
compiland = symt_new_compiland(msc_dbg->module, 0 /* FIXME */,
|
|
|
|
source_new(msc_dbg->module, NULL,
|
|
|
|
sym->objname_v3.name));
|
2021-08-30 09:28:20 +02:00
|
|
|
break;
|
2004-04-19 04:58:27 +02:00
|
|
|
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_OBJNAME_ST:
|
2021-08-21 10:23:00 +02:00
|
|
|
TRACE("S-ObjName-V1 %s\n", terminate_string(&sym->objname_v1.p_name));
|
2006-11-24 22:17:21 +01:00
|
|
|
compiland = symt_new_compiland(msc_dbg->module, 0 /* FIXME */,
|
2006-06-18 21:32:20 +02:00
|
|
|
source_new(msc_dbg->module, NULL,
|
|
|
|
terminate_string(&sym->objname_v1.p_name)));
|
2004-04-19 04:58:27 +02:00
|
|
|
break;
|
|
|
|
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_LABEL32_ST:
|
2004-11-21 16:51:47 +01:00
|
|
|
if (curr_func)
|
|
|
|
{
|
2006-11-24 22:17:54 +01:00
|
|
|
loc.kind = loc_absolute;
|
|
|
|
loc.offset = codeview_get_address(msc_dbg, sym->label_v1.segment, sym->label_v1.offset) - curr_func->address;
|
|
|
|
symt_add_function_point(msc_dbg->module, curr_func, SymTagLabel, &loc,
|
2004-11-21 16:51:47 +01:00
|
|
|
terminate_string(&sym->label_v1.p_name));
|
|
|
|
}
|
2008-02-06 21:55:47 +01:00
|
|
|
else symt_new_label(msc_dbg->module, compiland,
|
|
|
|
terminate_string(&sym->label_v1.p_name),
|
|
|
|
codeview_get_address(msc_dbg, sym->label_v1.segment, sym->label_v1.offset));
|
2004-11-21 16:51:47 +01:00
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_LABEL32:
|
2004-04-19 04:58:27 +02:00
|
|
|
if (curr_func)
|
|
|
|
{
|
2006-11-24 22:17:54 +01:00
|
|
|
loc.kind = loc_absolute;
|
|
|
|
loc.offset = codeview_get_address(msc_dbg, sym->label_v3.segment, sym->label_v3.offset) - curr_func->address;
|
2021-03-20 14:48:38 +01:00
|
|
|
symt_add_function_point(msc_dbg->module, curr_func, SymTagLabel,
|
2006-11-24 22:17:54 +01:00
|
|
|
&loc, sym->label_v3.name);
|
2004-04-19 04:58:27 +02:00
|
|
|
}
|
2008-02-06 21:55:47 +01:00
|
|
|
else symt_new_label(msc_dbg->module, compiland, sym->label_v3.name,
|
|
|
|
codeview_get_address(msc_dbg, sym->label_v3.segment, sym->label_v3.offset));
|
2004-04-19 04:58:27 +02:00
|
|
|
break;
|
|
|
|
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_CONSTANT_16t:
|
2004-04-19 04:58:27 +02:00
|
|
|
{
|
2006-12-05 22:13:30 +01:00
|
|
|
int vlen;
|
2004-11-21 16:51:47 +01:00
|
|
|
const struct p_string* name;
|
|
|
|
struct symt* se;
|
2006-12-05 22:13:30 +01:00
|
|
|
VARIANT v;
|
2004-11-21 16:51:47 +01:00
|
|
|
|
2008-09-29 21:31:53 +02:00
|
|
|
vlen = leaf_as_variant(&v, &sym->constant_v1.cvalue);
|
2004-11-21 16:51:47 +01:00
|
|
|
name = (const struct p_string*)((const char*)&sym->constant_v1.cvalue + vlen);
|
|
|
|
se = codeview_get_type(sym->constant_v1.type, FALSE);
|
2006-12-05 22:13:30 +01:00
|
|
|
|
|
|
|
TRACE("S-Constant-V1 %u %s %x\n",
|
|
|
|
v.n1.n2.n3.intVal, terminate_string(name), sym->constant_v1.type);
|
|
|
|
symt_new_constant(msc_dbg->module, compiland, terminate_string(name),
|
|
|
|
se, &v);
|
2004-04-19 04:58:27 +02:00
|
|
|
}
|
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_CONSTANT_ST:
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
2006-12-05 22:13:30 +01:00
|
|
|
int vlen;
|
2004-11-21 16:51:47 +01:00
|
|
|
const struct p_string* name;
|
|
|
|
struct symt* se;
|
2006-12-05 22:13:30 +01:00
|
|
|
VARIANT v;
|
2004-11-21 16:51:47 +01:00
|
|
|
|
2008-09-29 21:31:53 +02:00
|
|
|
vlen = leaf_as_variant(&v, &sym->constant_v2.cvalue);
|
2004-11-21 16:51:47 +01:00
|
|
|
name = (const struct p_string*)((const char*)&sym->constant_v2.cvalue + vlen);
|
|
|
|
se = codeview_get_type(sym->constant_v2.type, FALSE);
|
2006-12-05 22:13:30 +01:00
|
|
|
|
|
|
|
TRACE("S-Constant-V2 %u %s %x\n",
|
|
|
|
v.n1.n2.n3.intVal, terminate_string(name), sym->constant_v2.type);
|
|
|
|
symt_new_constant(msc_dbg->module, compiland, terminate_string(name),
|
|
|
|
se, &v);
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_CONSTANT:
|
2004-04-19 04:58:27 +02:00
|
|
|
{
|
2006-12-05 22:13:30 +01:00
|
|
|
int vlen;
|
2004-11-21 16:51:47 +01:00
|
|
|
const char* name;
|
|
|
|
struct symt* se;
|
2006-12-05 22:13:30 +01:00
|
|
|
VARIANT v;
|
2004-11-21 16:51:47 +01:00
|
|
|
|
2008-09-29 21:31:53 +02:00
|
|
|
vlen = leaf_as_variant(&v, &sym->constant_v3.cvalue);
|
2004-11-21 16:51:47 +01:00
|
|
|
name = (const char*)&sym->constant_v3.cvalue + vlen;
|
|
|
|
se = codeview_get_type(sym->constant_v3.type, FALSE);
|
2006-12-05 22:13:30 +01:00
|
|
|
|
|
|
|
TRACE("S-Constant-V3 %u %s %x\n",
|
|
|
|
v.n1.n2.n3.intVal, name, sym->constant_v3.type);
|
2004-11-21 16:51:47 +01:00
|
|
|
/* FIXME: we should add this as a constant value */
|
2008-09-29 21:31:53 +02:00
|
|
|
symt_new_constant(msc_dbg->module, compiland, name, se, &v);
|
2004-04-19 04:58:27 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_UDT_16t:
|
2004-11-21 16:51:47 +01:00
|
|
|
if (sym->udt_v1.type)
|
|
|
|
{
|
|
|
|
if ((symt = codeview_get_type(sym->udt_v1.type, FALSE)))
|
2021-03-20 14:48:38 +01:00
|
|
|
symt_new_typedef(msc_dbg->module, symt,
|
2004-11-21 16:51:47 +01:00
|
|
|
terminate_string(&sym->udt_v1.p_name));
|
|
|
|
else
|
2021-03-20 14:48:38 +01:00
|
|
|
FIXME("S-Udt %s: couldn't find type 0x%x\n",
|
2004-11-21 16:51:47 +01:00
|
|
|
terminate_string(&sym->udt_v1.p_name), sym->udt_v1.type);
|
|
|
|
}
|
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_UDT_ST:
|
2004-11-21 16:51:47 +01:00
|
|
|
if (sym->udt_v2.type)
|
|
|
|
{
|
|
|
|
if ((symt = codeview_get_type(sym->udt_v2.type, FALSE)))
|
2021-03-20 14:48:38 +01:00
|
|
|
symt_new_typedef(msc_dbg->module, symt,
|
2004-11-21 16:51:47 +01:00
|
|
|
terminate_string(&sym->udt_v2.p_name));
|
|
|
|
else
|
2021-03-20 14:48:38 +01:00
|
|
|
FIXME("S-Udt %s: couldn't find type 0x%x\n",
|
2004-11-21 16:51:47 +01:00
|
|
|
terminate_string(&sym->udt_v2.p_name), sym->udt_v2.type);
|
|
|
|
}
|
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_UDT:
|
2004-11-21 16:51:47 +01:00
|
|
|
if (sym->udt_v3.type)
|
2004-04-19 04:58:27 +02:00
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
if ((symt = codeview_get_type(sym->udt_v3.type, FALSE)))
|
|
|
|
symt_new_typedef(msc_dbg->module, symt, sym->udt_v3.name);
|
|
|
|
else
|
2021-03-20 14:48:38 +01:00
|
|
|
FIXME("S-Udt %s: couldn't find type 0x%x\n",
|
2004-11-21 16:51:47 +01:00
|
|
|
sym->udt_v3.name, sym->udt_v3.type);
|
2004-04-19 04:58:27 +02:00
|
|
|
}
|
|
|
|
break;
|
2021-11-08 14:58:39 +01:00
|
|
|
case S_LOCAL:
|
|
|
|
length += codeview_transform_defrange(msc_dbg, curr_func, sym, &loc);
|
|
|
|
symt_add_func_local(msc_dbg->module, curr_func,
|
|
|
|
sym->local_v3.varflags & 0x0001 ? DataIsParam : DataIsLocal,
|
|
|
|
&loc, block,
|
|
|
|
codeview_get_type(sym->local_v3.symtype, FALSE),
|
|
|
|
sym->local_v3.name);
|
|
|
|
break;
|
2021-11-08 14:59:34 +01:00
|
|
|
case S_INLINESITE:
|
|
|
|
{
|
|
|
|
struct symt_inlinesite* inlined = codeview_create_inline_site(msc_dbg, cvmod, top_func,
|
|
|
|
block ? &block->symt : &curr_func->symt,
|
|
|
|
sym->inline_site_v3.inlinee,
|
|
|
|
sym->inline_site_v3.binaryAnnotations,
|
|
|
|
(const unsigned char*)sym + length);
|
|
|
|
if (inlined)
|
|
|
|
{
|
|
|
|
curr_func = (struct symt_function*)inlined;
|
|
|
|
block = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* skip all records until paired S_INLINESITE_END */
|
|
|
|
sym = (const union codeview_symbol*)(root + sym->inline_site_v3.pEnd);
|
|
|
|
if (sym->generic.id != S_INLINESITE_END) FIXME("complete wreckage\n");
|
|
|
|
length = sym->inline_site_v3.pEnd - i + sym->generic.len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case S_INLINESITE2:
|
|
|
|
{
|
|
|
|
struct symt_inlinesite* inlined = codeview_create_inline_site(msc_dbg, cvmod, top_func,
|
|
|
|
block ? &block->symt : &curr_func->symt,
|
|
|
|
sym->inline_site2_v3.inlinee,
|
|
|
|
sym->inline_site2_v3.binaryAnnotations,
|
|
|
|
(const unsigned char*)sym + length);
|
|
|
|
if (inlined)
|
|
|
|
{
|
|
|
|
curr_func = (struct symt_function*)inlined;
|
|
|
|
block = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* skip all records until paired S_INLINESITE_END */
|
|
|
|
sym = (const union codeview_symbol*)(root + sym->inline_site2_v3.pEnd);
|
|
|
|
if (sym->generic.id != S_INLINESITE_END) FIXME("complete wreckage\n");
|
|
|
|
length = sym->inline_site_v3.pEnd - i + sym->generic.len;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case S_INLINESITE_END:
|
|
|
|
block = symt_check_tag(curr_func->container, SymTagBlock) ?
|
|
|
|
(struct symt_block*)curr_func->container : NULL;
|
|
|
|
curr_func = (struct symt_function*)symt_get_upper_inlined((struct symt_inlinesite*)curr_func);
|
|
|
|
break;
|
2004-04-19 04:58:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
/*
|
2004-04-06 00:21:27 +02:00
|
|
|
* These are special, in that they are always followed by an
|
|
|
|
* additional length-prefixed string which is *not* included
|
|
|
|
* into the symbol length count. We need to skip it.
|
|
|
|
*/
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_PROCREF_ST:
|
|
|
|
case S_DATAREF_ST:
|
|
|
|
case S_LPROCREF_ST:
|
2012-04-19 23:22:33 +02:00
|
|
|
{
|
|
|
|
const char* name;
|
|
|
|
|
|
|
|
name = (const char*)sym + length;
|
|
|
|
length += (*name + 1 + 3) & ~3;
|
|
|
|
break;
|
|
|
|
}
|
2004-11-21 16:51:47 +01:00
|
|
|
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_SSEARCH:
|
2006-03-18 13:32:38 +01:00
|
|
|
TRACE("Start search: seg=0x%x at offset 0x%08x\n",
|
|
|
|
sym->ssearch_v1.segment, sym->ssearch_v1.offset);
|
|
|
|
break;
|
|
|
|
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_ALIGN:
|
2007-01-05 21:43:00 +01:00
|
|
|
TRACE("S-Align V1\n");
|
|
|
|
break;
|
2019-06-04 01:55:46 +02:00
|
|
|
case S_HEAPALLOCSITE:
|
2021-08-24 11:12:14 +02:00
|
|
|
TRACE("S-heap site V3: offset=0x%08x at sect_idx 0x%04x, inst_len 0x%08x, index 0x%08x\n",
|
|
|
|
sym->heap_alloc_site_v3.offset, sym->heap_alloc_site_v3.sect_idx,
|
|
|
|
sym->heap_alloc_site_v3.inst_len, sym->heap_alloc_site_v3.index);
|
2019-06-04 01:55:46 +02:00
|
|
|
break;
|
2007-01-05 21:43:00 +01:00
|
|
|
|
2021-11-15 18:26:48 +01:00
|
|
|
case S_SEPCODE:
|
|
|
|
if (!top_func)
|
|
|
|
{
|
|
|
|
ULONG_PTR parent_addr = codeview_get_address(msc_dbg, sym->sepcode_v3.sectParent, sym->sepcode_v3.offParent);
|
|
|
|
struct symt_ht* parent = symt_find_nearest(msc_dbg->module, parent_addr);
|
|
|
|
if (symt_check_tag(&parent->symt, SymTagFunction))
|
|
|
|
{
|
|
|
|
struct symt_function* pfunc = (struct symt_function*)parent;
|
|
|
|
top_func = symt_new_function(msc_dbg->module, compiland, pfunc->hash_elt.name,
|
|
|
|
codeview_get_address(msc_dbg, sym->sepcode_v3.sect, sym->sepcode_v3.off),
|
|
|
|
sym->sepcode_v3.length, pfunc->type);
|
|
|
|
curr_func = top_func;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
WARN("Couldn't find function referenced by S_SEPCODE at %04x:%08x\n",
|
|
|
|
sym->sepcode_v3.sectParent, sym->sepcode_v3.offParent);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
FIXME("S_SEPCODE inside top-level function %s\n", top_func->hash_elt.name);
|
|
|
|
break;
|
|
|
|
|
2008-09-29 21:30:48 +02:00
|
|
|
/* the symbols we can safely ignore for now */
|
2015-11-10 18:10:16 +01:00
|
|
|
case S_TRAMPOLINE:
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_FRAMEPROC:
|
|
|
|
case S_FRAMECOOKIE:
|
|
|
|
case S_SECTION:
|
|
|
|
case S_COFFGROUP:
|
|
|
|
case S_EXPORT:
|
2015-11-10 18:10:16 +01:00
|
|
|
case S_CALLSITEINFO:
|
2021-11-08 14:58:39 +01:00
|
|
|
/* even if S_LOCAL groks all the S_DEFRANGE* records following itself,
|
|
|
|
* those kinds of records can also be present after a S_FILESTATIC record
|
|
|
|
* so silence them until (at least) S_FILESTATIC is supported
|
|
|
|
*/
|
2015-11-10 18:10:16 +01:00
|
|
|
case S_DEFRANGE_REGISTER:
|
|
|
|
case S_DEFRANGE_FRAMEPOINTER_REL:
|
|
|
|
case S_DEFRANGE_SUBFIELD_REGISTER:
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE:
|
2015-11-10 18:10:16 +01:00
|
|
|
case S_DEFRANGE_REGISTER_REL:
|
|
|
|
case S_BUILDINFO:
|
|
|
|
case S_FILESTATIC:
|
|
|
|
case S_CALLEES:
|
2021-11-15 18:26:35 +01:00
|
|
|
case S_CALLERS:
|
2021-10-29 15:38:11 +02:00
|
|
|
case S_UNAMESPACE:
|
|
|
|
case S_INLINEES:
|
2021-11-15 18:26:35 +01:00
|
|
|
case S_POGODATA:
|
2008-09-06 22:20:13 +02:00
|
|
|
TRACE("Unsupported symbol id %x\n", sym->generic.id);
|
|
|
|
break;
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
default:
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("Unsupported symbol id %x\n", sym->generic.id);
|
|
|
|
dump(sym, 2 + sym->generic.len);
|
|
|
|
break;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
}
|
2021-11-08 14:59:20 +01:00
|
|
|
if (cvmod) codeview_snarf_linetab2(msc_dbg, cvmod);
|
2004-04-06 00:21:27 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-11-08 14:58:53 +01:00
|
|
|
static BOOL codeview_is_inside(const struct cv_local_info* locinfo, const struct symt_function* func, DWORD_PTR ip)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
/* ip must be in local_info range, but not in any of its gaps */
|
|
|
|
if (ip < locinfo->start || ip >= locinfo->start + locinfo->rangelen) return FALSE;
|
|
|
|
for (i = 0; i < locinfo->ngaps; ++i)
|
|
|
|
if (func->address + locinfo->gaps[i].gapStartOffset <= ip &&
|
|
|
|
ip < func->address + locinfo->gaps[i].gapStartOffset + locinfo->gaps[i].cbRange)
|
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-11-08 14:58:39 +01:00
|
|
|
static void pdb_location_compute(struct process* pcs,
|
|
|
|
const struct module_format* modfmt,
|
|
|
|
const struct symt_function* func,
|
|
|
|
struct location* loc)
|
|
|
|
{
|
2021-11-08 14:58:53 +01:00
|
|
|
const struct cv_local_info* locinfo;
|
|
|
|
|
|
|
|
switch (loc->kind)
|
|
|
|
{
|
|
|
|
case loc_cv_local_range:
|
|
|
|
for (locinfo = (const struct cv_local_info*)loc->offset;
|
|
|
|
locinfo->kind != 0;
|
|
|
|
locinfo = (const struct cv_local_info*)((const char*)(locinfo + 1) + locinfo->ngaps * sizeof(locinfo->gaps[0])))
|
|
|
|
{
|
|
|
|
if (!codeview_is_inside(locinfo, func, pcs->localscope_pc)) continue;
|
|
|
|
switch (locinfo->kind)
|
|
|
|
{
|
|
|
|
case S_DEFRANGE:
|
|
|
|
case S_DEFRANGE_SUBFIELD:
|
|
|
|
default:
|
|
|
|
FIXME("Unsupported defrange %d\n", locinfo->kind);
|
|
|
|
loc->kind = loc_error;
|
|
|
|
loc->reg = loc_err_internal;
|
|
|
|
return;
|
|
|
|
case S_DEFRANGE_SUBFIELD_REGISTER:
|
|
|
|
FIXME("sub-field part not handled\n");
|
|
|
|
/* fall through */
|
|
|
|
case S_DEFRANGE_REGISTER:
|
|
|
|
loc->kind = loc_register;
|
|
|
|
loc->reg = locinfo->reg;
|
|
|
|
return;
|
|
|
|
case S_DEFRANGE_REGISTER_REL:
|
|
|
|
loc->kind = loc_regrel;
|
|
|
|
loc->reg = locinfo->reg;
|
|
|
|
loc->offset = locinfo->offset;
|
|
|
|
return;
|
|
|
|
case S_DEFRANGE_FRAMEPOINTER_REL:
|
|
|
|
case S_DEFRANGE_FRAMEPOINTER_REL_FULL_SCOPE:
|
|
|
|
loc->kind = loc_regrel;
|
|
|
|
loc->reg = dbghelp_current_cpu->frame_regno;
|
|
|
|
loc->offset = locinfo->offset;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
loc->kind = loc_error;
|
2021-11-08 14:58:39 +01:00
|
|
|
loc->reg = loc_err_internal;
|
|
|
|
}
|
|
|
|
|
2013-11-12 01:16:36 +01:00
|
|
|
static BOOL codeview_snarf_public(const struct msc_debug_info* msc_dbg, const BYTE* root,
|
|
|
|
int offset, int size)
|
2008-09-06 22:20:19 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
int i, length;
|
|
|
|
struct symt_compiland* compiland = NULL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Loop over the different types of records and whenever we
|
|
|
|
* find something we are interested in, record it and move on.
|
|
|
|
*/
|
|
|
|
for (i = offset; i < size; i += length)
|
|
|
|
{
|
|
|
|
const union codeview_symbol* sym = (const union codeview_symbol*)(root + i);
|
|
|
|
length = sym->generic.len + 2;
|
|
|
|
if (i + length > size) break;
|
|
|
|
if (!sym->generic.id || length < 4) break;
|
|
|
|
if (length & 3) FIXME("unpadded len %u\n", length);
|
|
|
|
|
|
|
|
switch (sym->generic.id)
|
|
|
|
{
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_PUB32_16t:
|
2008-09-06 22:20:19 +02:00
|
|
|
if (!(dbghelp_options & SYMOPT_NO_PUBLICS))
|
|
|
|
{
|
|
|
|
symt_new_public(msc_dbg->module, compiland,
|
2018-11-25 10:15:46 +01:00
|
|
|
terminate_string(&sym->public_v1.p_name),
|
2021-08-24 11:11:24 +02:00
|
|
|
sym->public_v1.pubsymflags == SYMTYPE_FUNCTION,
|
2018-11-25 10:15:46 +01:00
|
|
|
codeview_get_address(msc_dbg, sym->public_v1.segment, sym->public_v1.offset), 1);
|
2008-09-06 22:20:19 +02:00
|
|
|
}
|
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_PUB32_ST:
|
2008-09-06 22:20:19 +02:00
|
|
|
if (!(dbghelp_options & SYMOPT_NO_PUBLICS))
|
|
|
|
{
|
|
|
|
symt_new_public(msc_dbg->module, compiland,
|
2018-11-25 10:15:46 +01:00
|
|
|
terminate_string(&sym->public_v2.p_name),
|
2021-08-24 11:11:24 +02:00
|
|
|
sym->public_v2.pubsymflags == SYMTYPE_FUNCTION,
|
2018-11-25 10:15:46 +01:00
|
|
|
codeview_get_address(msc_dbg, sym->public_v2.segment, sym->public_v2.offset), 1);
|
2008-09-06 22:20:19 +02:00
|
|
|
}
|
2018-11-25 10:15:46 +01:00
|
|
|
break;
|
2008-09-06 22:20:19 +02:00
|
|
|
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_PUB32:
|
2008-09-06 22:20:19 +02:00
|
|
|
if (!(dbghelp_options & SYMOPT_NO_PUBLICS))
|
|
|
|
{
|
|
|
|
symt_new_public(msc_dbg->module, compiland,
|
2018-11-25 10:15:46 +01:00
|
|
|
sym->public_v3.name,
|
2021-08-21 10:23:25 +02:00
|
|
|
sym->public_v3.pubsymflags == SYMTYPE_FUNCTION,
|
2018-11-25 10:15:46 +01:00
|
|
|
codeview_get_address(msc_dbg, sym->public_v3.segment, sym->public_v3.offset), 1);
|
2008-09-06 22:20:19 +02:00
|
|
|
}
|
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_PROCREF:
|
|
|
|
case S_LPROCREF: /* using a data_v3 isn't what we'd expect */
|
2008-09-06 22:20:19 +02:00
|
|
|
#if 0
|
|
|
|
/* FIXME: this is plain wrong (from a simple test) */
|
|
|
|
if (!(dbghelp_options & SYMOPT_NO_PUBLICS))
|
|
|
|
{
|
|
|
|
symt_new_public(msc_dbg->module, compiland,
|
|
|
|
sym->data_v3.name,
|
2010-01-23 22:13:18 +01:00
|
|
|
codeview_get_address(msc_dbg, sym->data_v3.segment, sym->data_v3.offset), 1);
|
2008-09-06 22:20:19 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
/*
|
|
|
|
* Global and local data symbols. We don't associate these
|
|
|
|
* with any given source file.
|
|
|
|
*/
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GDATA32_16t:
|
|
|
|
case S_LDATA32_16t:
|
2008-09-06 22:20:19 +02:00
|
|
|
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->data_v1.p_name),
|
|
|
|
sym->data_v1.segment, sym->data_v1.offset, sym->data_v1.symtype,
|
2021-03-20 14:48:38 +01:00
|
|
|
sym->generic.id == S_LDATA32_16t, FALSE, FALSE);
|
2008-09-06 22:20:19 +02:00
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GDATA32_ST:
|
|
|
|
case S_LDATA32_ST:
|
2008-09-06 22:20:19 +02:00
|
|
|
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->data_v2.p_name),
|
|
|
|
sym->data_v2.segment, sym->data_v2.offset, sym->data_v2.symtype,
|
2021-03-20 14:48:38 +01:00
|
|
|
sym->generic.id == S_LDATA32_ST, FALSE, FALSE);
|
2008-09-06 22:20:19 +02:00
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GDATA32:
|
|
|
|
case S_LDATA32:
|
2008-09-06 22:20:19 +02:00
|
|
|
codeview_add_variable(msc_dbg, compiland, sym->data_v3.name,
|
|
|
|
sym->data_v3.segment, sym->data_v3.offset, sym->data_v3.symtype,
|
2021-03-20 14:48:38 +01:00
|
|
|
sym->generic.id == S_LDATA32, FALSE, FALSE);
|
2011-01-29 20:38:15 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* variables with thread storage */
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GTHREAD32_16t:
|
|
|
|
case S_LTHREAD32_16t:
|
2011-01-29 20:38:15 +01:00
|
|
|
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->thread_v1.p_name),
|
|
|
|
sym->thread_v1.segment, sym->thread_v1.offset, sym->thread_v1.symtype,
|
2021-03-20 14:48:38 +01:00
|
|
|
sym->generic.id == S_LTHREAD32_16t, TRUE, FALSE);
|
2008-09-06 22:20:19 +02:00
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GTHREAD32_ST:
|
|
|
|
case S_LTHREAD32_ST:
|
2011-01-29 20:38:15 +01:00
|
|
|
codeview_add_variable(msc_dbg, compiland, terminate_string(&sym->thread_v2.p_name),
|
|
|
|
sym->thread_v2.segment, sym->thread_v2.offset, sym->thread_v2.symtype,
|
2021-03-20 14:48:38 +01:00
|
|
|
sym->generic.id == S_LTHREAD32_ST, TRUE, FALSE);
|
2011-01-29 20:38:15 +01:00
|
|
|
break;
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_GTHREAD32:
|
|
|
|
case S_LTHREAD32:
|
2011-01-29 20:38:15 +01:00
|
|
|
codeview_add_variable(msc_dbg, compiland, sym->thread_v3.name,
|
|
|
|
sym->thread_v3.segment, sym->thread_v3.offset, sym->thread_v3.symtype,
|
2021-03-20 14:48:38 +01:00
|
|
|
sym->generic.id == S_LTHREAD32, TRUE, FALSE);
|
2011-01-29 20:38:15 +01:00
|
|
|
break;
|
|
|
|
|
2008-09-06 22:20:19 +02:00
|
|
|
/*
|
|
|
|
* These are special, in that they are always followed by an
|
|
|
|
* additional length-prefixed string which is *not* included
|
|
|
|
* into the symbol length count. We need to skip it.
|
|
|
|
*/
|
2021-03-20 14:48:38 +01:00
|
|
|
case S_PROCREF_ST:
|
|
|
|
case S_DATAREF_ST:
|
|
|
|
case S_LPROCREF_ST:
|
2008-09-06 22:20:19 +02:00
|
|
|
length += (((const char*)sym)[length] + 1 + 3) & ~3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
msc_dbg->module->sortlist_valid = TRUE;
|
|
|
|
}
|
|
|
|
msc_dbg->module->sortlist_valid = FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/*========================================================================
|
|
|
|
* Process PDB file.
|
|
|
|
*/
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
static void* pdb_jg_read(const struct PDB_JG_HEADER* pdb, const WORD* block_list,
|
|
|
|
int size)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
int i, num_blocks;
|
|
|
|
BYTE* buffer;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
if (!size) return NULL;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
num_blocks = (size + pdb->block_size - 1) / pdb->block_size;
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, num_blocks * pdb->block_size);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
for (i = 0; i < num_blocks; i++)
|
|
|
|
memcpy(buffer + i * pdb->block_size,
|
|
|
|
(const char*)pdb + block_list[i] * pdb->block_size, pdb->block_size);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void* pdb_ds_read(const struct PDB_DS_HEADER* pdb, const DWORD* block_list,
|
|
|
|
int size)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
int i, num_blocks;
|
|
|
|
BYTE* buffer;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
if (!size) return NULL;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
num_blocks = (size + pdb->block_size - 1) / pdb->block_size;
|
|
|
|
buffer = HeapAlloc(GetProcessHeap(), 0, num_blocks * pdb->block_size);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
for (i = 0; i < num_blocks; i++)
|
|
|
|
memcpy(buffer + i * pdb->block_size,
|
|
|
|
(const char*)pdb + block_list[i] * pdb->block_size, pdb->block_size);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
static void* pdb_read_jg_file(const struct PDB_JG_HEADER* pdb,
|
|
|
|
const struct PDB_JG_TOC* toc, DWORD file_nr)
|
|
|
|
{
|
|
|
|
const WORD* block_list;
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
if (!toc || file_nr >= toc->num_files) return NULL;
|
|
|
|
|
|
|
|
block_list = (const WORD*) &toc->file[toc->num_files];
|
|
|
|
for (i = 0; i < file_nr; i++)
|
|
|
|
block_list += (toc->file[i].size + pdb->block_size - 1) / pdb->block_size;
|
|
|
|
|
|
|
|
return pdb_jg_read(pdb, block_list, toc->file[file_nr].size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void* pdb_read_ds_file(const struct PDB_DS_HEADER* pdb,
|
|
|
|
const struct PDB_DS_TOC* toc, DWORD file_nr)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
const DWORD* block_list;
|
|
|
|
DWORD i;
|
|
|
|
|
|
|
|
if (!toc || file_nr >= toc->num_files) return NULL;
|
2011-01-11 20:34:46 +01:00
|
|
|
if (toc->file_size[file_nr] == 0 || toc->file_size[file_nr] == 0xFFFFFFFF) return NULL;
|
2004-11-21 16:51:47 +01:00
|
|
|
|
|
|
|
block_list = &toc->file_size[toc->num_files];
|
|
|
|
for (i = 0; i < file_nr; i++)
|
|
|
|
block_list += (toc->file_size[i] + pdb->block_size - 1) / pdb->block_size;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
return pdb_ds_read(pdb, block_list, toc->file_size[file_nr]);
|
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2011-01-08 14:04:14 +01:00
|
|
|
static void* pdb_read_file(const struct pdb_file_info* pdb_file,
|
2004-11-21 16:51:47 +01:00
|
|
|
DWORD file_nr)
|
|
|
|
{
|
2011-01-08 14:04:01 +01:00
|
|
|
switch (pdb_file->kind)
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
|
|
|
case PDB_JG:
|
2011-01-08 14:04:14 +01:00
|
|
|
return pdb_read_jg_file((const struct PDB_JG_HEADER*)pdb_file->image,
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_file->u.jg.toc, file_nr);
|
2004-11-21 16:51:47 +01:00
|
|
|
case PDB_DS:
|
2011-01-08 14:04:14 +01:00
|
|
|
return pdb_read_ds_file((const struct PDB_DS_HEADER*)pdb_file->image,
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_file->u.ds.toc, file_nr);
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2011-01-08 14:04:01 +01:00
|
|
|
static unsigned pdb_get_file_size(const struct pdb_file_info* pdb_file, DWORD file_nr)
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
2011-01-08 14:04:01 +01:00
|
|
|
switch (pdb_file->kind)
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
2011-01-08 14:04:01 +01:00
|
|
|
case PDB_JG: return pdb_file->u.jg.toc->file[file_nr].size;
|
|
|
|
case PDB_DS: return pdb_file->u.ds.toc->file_size[file_nr];
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
|
|
|
return 0;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void pdb_free(void* buffer)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer);
|
|
|
|
}
|
|
|
|
|
2011-01-08 14:04:01 +01:00
|
|
|
static void pdb_free_file(struct pdb_file_info* pdb_file)
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
2011-01-08 14:04:01 +01:00
|
|
|
switch (pdb_file->kind)
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
|
|
|
case PDB_JG:
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_free(pdb_file->u.jg.toc);
|
|
|
|
pdb_file->u.jg.toc = NULL;
|
2004-11-21 16:51:47 +01:00
|
|
|
break;
|
|
|
|
case PDB_DS:
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_free(pdb_file->u.ds.toc);
|
|
|
|
pdb_file->u.ds.toc = NULL;
|
2004-11-21 16:51:47 +01:00
|
|
|
break;
|
|
|
|
}
|
2011-01-17 21:54:04 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, pdb_file->stream_dict);
|
|
|
|
}
|
|
|
|
|
2014-04-28 20:07:53 +02:00
|
|
|
static void pdb_load_stream_name_table(struct pdb_file_info* pdb_file, const char* str, unsigned cb)
|
2011-01-17 21:54:04 +01:00
|
|
|
{
|
|
|
|
DWORD* pdw;
|
|
|
|
DWORD* ok_bits;
|
|
|
|
DWORD count, numok;
|
|
|
|
unsigned i, j;
|
|
|
|
char* cpstr;
|
|
|
|
|
|
|
|
pdw = (DWORD*)(str + cb);
|
|
|
|
numok = *pdw++;
|
|
|
|
count = *pdw++;
|
|
|
|
|
|
|
|
pdb_file->stream_dict = HeapAlloc(GetProcessHeap(), 0, (numok + 1) * sizeof(struct pdb_stream_name) + cb);
|
2014-04-28 20:07:53 +02:00
|
|
|
if (!pdb_file->stream_dict) return;
|
2011-01-17 21:54:04 +01:00
|
|
|
cpstr = (char*)(pdb_file->stream_dict + numok + 1);
|
|
|
|
memcpy(cpstr, str, cb);
|
|
|
|
|
|
|
|
/* bitfield: first dword is len (in dword), then data */
|
|
|
|
ok_bits = pdw;
|
|
|
|
pdw += *ok_bits++ + 1;
|
|
|
|
if (*pdw++ != 0)
|
|
|
|
{
|
|
|
|
FIXME("unexpected value\n");
|
2014-04-28 20:07:53 +02:00
|
|
|
return;
|
2011-01-17 21:54:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = j = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
if (ok_bits[i / 32] & (1 << (i % 32)))
|
|
|
|
{
|
|
|
|
if (j >= numok) break;
|
|
|
|
pdb_file->stream_dict[j].name = &cpstr[*pdw++];
|
|
|
|
pdb_file->stream_dict[j].index = *pdw++;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* add sentinel */
|
|
|
|
pdb_file->stream_dict[numok].name = NULL;
|
2011-01-17 21:54:17 +01:00
|
|
|
pdb_file->fpoext_stream = -1;
|
2011-01-17 21:54:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned pdb_get_stream_by_name(const struct pdb_file_info* pdb_file, const char* name)
|
|
|
|
{
|
|
|
|
struct pdb_stream_name* psn;
|
|
|
|
|
|
|
|
for (psn = pdb_file->stream_dict; psn && psn->name; psn++)
|
|
|
|
{
|
|
|
|
if (!strcmp(psn->name, name)) return psn->index;
|
|
|
|
}
|
|
|
|
return -1;
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
2011-01-08 14:04:01 +01:00
|
|
|
|
2011-01-11 20:34:46 +01:00
|
|
|
static void* pdb_read_strings(const struct pdb_file_info* pdb_file)
|
|
|
|
{
|
2011-01-17 21:54:04 +01:00
|
|
|
unsigned idx;
|
2011-01-11 20:34:46 +01:00
|
|
|
void *ret;
|
|
|
|
|
2011-01-17 21:54:04 +01:00
|
|
|
idx = pdb_get_stream_by_name(pdb_file, "/names");
|
|
|
|
if (idx != -1)
|
|
|
|
{
|
|
|
|
ret = pdb_read_file( pdb_file, idx );
|
|
|
|
if (ret && *(const DWORD *)ret == 0xeffeeffe) return ret;
|
|
|
|
pdb_free( ret );
|
|
|
|
}
|
2011-01-11 20:34:46 +01:00
|
|
|
WARN("string table not found\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-01-08 14:04:08 +01:00
|
|
|
static void pdb_module_remove(struct process* pcsn, struct module_format* modfmt)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
|
|
|
|
for (i = 0; i < modfmt->u.pdb_info->used_subfiles; i++)
|
2011-01-08 14:04:14 +01:00
|
|
|
{
|
2011-01-08 14:04:08 +01:00
|
|
|
pdb_free_file(&modfmt->u.pdb_info->pdb_files[i]);
|
2011-01-08 14:04:14 +01:00
|
|
|
if (modfmt->u.pdb_info->pdb_files[i].image)
|
|
|
|
UnmapViewOfFile(modfmt->u.pdb_info->pdb_files[i].image);
|
|
|
|
if (modfmt->u.pdb_info->pdb_files[i].hMap)
|
|
|
|
CloseHandle(modfmt->u.pdb_info->pdb_files[i].hMap);
|
|
|
|
}
|
2011-01-08 14:04:08 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, modfmt);
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
static void pdb_convert_types_header(PDB_TYPES* types, const BYTE* image)
|
|
|
|
{
|
|
|
|
memset(types, 0, sizeof(PDB_TYPES));
|
|
|
|
if (!image) return;
|
|
|
|
|
2004-05-18 23:29:09 +02:00
|
|
|
if (*(const DWORD*)image < 19960000) /* FIXME: correct version? */
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
/* Old version of the types record header */
|
|
|
|
const PDB_TYPES_OLD* old = (const PDB_TYPES_OLD*)image;
|
|
|
|
types->version = old->version;
|
|
|
|
types->type_offset = sizeof(PDB_TYPES_OLD);
|
|
|
|
types->type_size = old->type_size;
|
|
|
|
types->first_index = old->first_index;
|
|
|
|
types->last_index = old->last_index;
|
|
|
|
types->file = old->file;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* New version of the types record header */
|
|
|
|
*types = *(const PDB_TYPES*)image;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pdb_convert_symbols_header(PDB_SYMBOLS* symbols,
|
|
|
|
int* header_size, const BYTE* image)
|
|
|
|
{
|
|
|
|
memset(symbols, 0, sizeof(PDB_SYMBOLS));
|
|
|
|
if (!image) return;
|
|
|
|
|
2004-05-18 23:29:09 +02:00
|
|
|
if (*(const DWORD*)image != 0xffffffff)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
/* Old version of the symbols record header */
|
|
|
|
const PDB_SYMBOLS_OLD* old = (const PDB_SYMBOLS_OLD*)image;
|
|
|
|
symbols->version = 0;
|
|
|
|
symbols->module_size = old->module_size;
|
|
|
|
symbols->offset_size = old->offset_size;
|
|
|
|
symbols->hash_size = old->hash_size;
|
|
|
|
symbols->srcmodule_size = old->srcmodule_size;
|
|
|
|
symbols->pdbimport_size = 0;
|
2021-08-24 11:12:45 +02:00
|
|
|
symbols->global_file = old->global_file;
|
|
|
|
symbols->public_file = old->public_file;
|
2004-04-06 00:21:27 +02:00
|
|
|
symbols->gsym_file = old->gsym_file;
|
|
|
|
|
|
|
|
*header_size = sizeof(PDB_SYMBOLS_OLD);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* New version of the symbols record header */
|
|
|
|
*symbols = *(const PDB_SYMBOLS*)image;
|
|
|
|
*header_size = sizeof(PDB_SYMBOLS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
static void pdb_convert_symbol_file(const PDB_SYMBOLS* symbols,
|
|
|
|
PDB_SYMBOL_FILE_EX* sfile,
|
|
|
|
unsigned* size, const void* image)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (symbols->version < 19970000)
|
|
|
|
{
|
2009-01-19 10:24:06 +01:00
|
|
|
const PDB_SYMBOL_FILE *sym_file = image;
|
2004-11-21 16:51:47 +01:00
|
|
|
memset(sfile, 0, sizeof(*sfile));
|
|
|
|
sfile->file = sym_file->file;
|
|
|
|
sfile->range.index = sym_file->range.index;
|
|
|
|
sfile->symbol_size = sym_file->symbol_size;
|
|
|
|
sfile->lineno_size = sym_file->lineno_size;
|
2021-11-02 15:31:16 +01:00
|
|
|
sfile->lineno2_size = sym_file->lineno2_size;
|
2004-11-21 16:51:47 +01:00
|
|
|
*size = sizeof(PDB_SYMBOL_FILE) - 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memcpy(sfile, image, sizeof(PDB_SYMBOL_FILE_EX));
|
|
|
|
*size = sizeof(PDB_SYMBOL_FILE_EX) - 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-08 14:04:14 +01:00
|
|
|
static HANDLE map_pdb_file(const struct process* pcs,
|
|
|
|
const struct pdb_lookup* lookup,
|
|
|
|
struct module* module)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2011-01-08 14:04:14 +01:00
|
|
|
HANDLE hFile, hMap = NULL;
|
2018-11-15 14:24:58 +01:00
|
|
|
WCHAR dbg_file_path[MAX_PATH];
|
2006-05-10 21:35:51 +02:00
|
|
|
BOOL ret = FALSE;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-05-10 21:35:51 +02:00
|
|
|
switch (lookup->kind)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2006-05-10 21:35:51 +02:00
|
|
|
case PDB_JG:
|
2020-03-25 17:41:26 +01:00
|
|
|
ret = path_find_symbol_file(pcs, module, lookup->filename, DMT_PDB, NULL, lookup->timestamp,
|
2008-10-18 09:15:03 +02:00
|
|
|
lookup->age, dbg_file_path, &module->module.PdbUnmatched);
|
2006-05-10 21:35:51 +02:00
|
|
|
break;
|
|
|
|
case PDB_DS:
|
2020-03-25 17:41:26 +01:00
|
|
|
ret = path_find_symbol_file(pcs, module, lookup->filename, DMT_PDB, &lookup->guid, 0,
|
2008-10-18 09:15:03 +02:00
|
|
|
lookup->age, dbg_file_path, &module->module.PdbUnmatched);
|
2006-05-10 21:35:51 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
WARN("\tCouldn't find %s\n", lookup->filename);
|
|
|
|
return NULL;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2018-11-15 14:24:58 +01:00
|
|
|
if ((hFile = CreateFileW(dbg_file_path, GENERIC_READ, FILE_SHARE_READ, NULL,
|
2011-01-08 14:04:14 +01:00
|
|
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL);
|
|
|
|
CloseHandle(hFile);
|
|
|
|
}
|
|
|
|
return hMap;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2021-11-08 14:59:07 +01:00
|
|
|
static BOOL pdb_init_type_parse(const struct msc_debug_info* msc_dbg,
|
|
|
|
struct codeview_type_parse* ctp,
|
|
|
|
BYTE* image)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2021-11-08 14:59:07 +01:00
|
|
|
PDB_TYPES types;
|
|
|
|
DWORD total;
|
|
|
|
const BYTE* ptr;
|
|
|
|
DWORD* offset;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2021-11-08 14:59:07 +01:00
|
|
|
pdb_convert_types_header(&types, image);
|
|
|
|
|
|
|
|
/* Check for unknown versions */
|
|
|
|
switch (types.version)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2021-11-08 14:59:07 +01:00
|
|
|
case 19950410: /* VC 4.0 */
|
|
|
|
case 19951122:
|
|
|
|
case 19961031: /* VC 5.0 / 6.0 */
|
|
|
|
case 19990903: /* VC 7.0 */
|
|
|
|
case 20040203: /* VC 8.0 */
|
|
|
|
break;
|
|
|
|
default:
|
2022-02-09 09:26:26 +01:00
|
|
|
ERR("-Unknown type info version %ld\n", types.version);
|
2021-11-10 16:42:14 +01:00
|
|
|
return FALSE;
|
2021-11-08 14:59:07 +01:00
|
|
|
}
|
2006-03-18 13:32:41 +01:00
|
|
|
|
2021-11-08 14:59:07 +01:00
|
|
|
ctp->module = msc_dbg->module;
|
|
|
|
/* reconstruct the types offset...
|
|
|
|
* FIXME: maybe it's present in the newest PDB_TYPES structures
|
|
|
|
*/
|
|
|
|
total = types.last_index - types.first_index + 1;
|
|
|
|
offset = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * total);
|
|
|
|
if (!offset) return FALSE;
|
|
|
|
ctp->table = ptr = image + types.type_offset;
|
|
|
|
ctp->num = 0;
|
|
|
|
while (ptr < ctp->table + types.type_size && ctp->num < total)
|
|
|
|
{
|
|
|
|
offset[ctp->num++] = ptr - ctp->table;
|
|
|
|
ptr += ((const union codeview_type*)ptr)->generic.len + 2;
|
|
|
|
}
|
|
|
|
ctp->offset = offset;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2021-11-08 14:59:07 +01:00
|
|
|
static void pdb_process_types(const struct msc_debug_info* msc_dbg,
|
|
|
|
const struct pdb_file_info* pdb_file)
|
|
|
|
{
|
|
|
|
struct codeview_type_parse ctp;
|
|
|
|
BYTE* types_image = pdb_read_file(pdb_file, 2);
|
2004-11-21 16:51:47 +01:00
|
|
|
|
2021-11-08 14:59:07 +01:00
|
|
|
if (types_image)
|
|
|
|
{
|
|
|
|
if (pdb_init_type_parse(msc_dbg, &ctp, types_image))
|
2006-03-18 13:32:41 +01:00
|
|
|
{
|
2021-11-08 14:59:07 +01:00
|
|
|
/* Read type table */
|
|
|
|
codeview_parse_type_table(&ctp);
|
|
|
|
HeapFree(GetProcessHeap(), 0, (DWORD*)ctp.offset);
|
2006-03-18 13:32:41 +01:00
|
|
|
}
|
2004-11-21 16:51:47 +01:00
|
|
|
pdb_free(types_image);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char PDB_JG_IDENT[] = "Microsoft C/C++ program database 2.00\r\n\032JG\0";
|
|
|
|
static const char PDB_DS_IDENT[] = "Microsoft C/C++ MSF 7.00\r\n\032DS\0";
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-05-10 21:35:51 +02:00
|
|
|
/******************************************************************
|
|
|
|
* pdb_init
|
|
|
|
*
|
|
|
|
* Tries to load a pdb file
|
2011-01-08 14:04:01 +01:00
|
|
|
* 'matched' is filled with the number of correct matches for this file:
|
|
|
|
* - age counts for one
|
|
|
|
* - timestamp or guid depending on kind counts for one
|
|
|
|
* a wrong kind of file returns FALSE (FIXME ?)
|
2006-05-10 21:35:51 +02:00
|
|
|
*/
|
2011-01-08 14:04:01 +01:00
|
|
|
static BOOL pdb_init(const struct pdb_lookup* pdb_lookup, struct pdb_file_info* pdb_file,
|
|
|
|
const char* image, unsigned* matched)
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
2006-05-10 21:35:51 +02:00
|
|
|
BOOL ret = TRUE;
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
/* check the file header, and if ok, load the TOC */
|
|
|
|
TRACE("PDB(%s): %.40s\n", pdb_lookup->filename, debugstr_an(image, 40));
|
2006-05-10 21:35:51 +02:00
|
|
|
|
2011-01-08 14:04:01 +01:00
|
|
|
*matched = 0;
|
2006-05-10 21:35:51 +02:00
|
|
|
if (!memcmp(image, PDB_JG_IDENT, sizeof(PDB_JG_IDENT)))
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2006-05-10 21:35:51 +02:00
|
|
|
const struct PDB_JG_HEADER* pdb = (const struct PDB_JG_HEADER*)image;
|
|
|
|
struct PDB_JG_ROOT* root;
|
|
|
|
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_file->u.jg.toc = pdb_jg_read(pdb, pdb->toc_block, pdb->toc.size);
|
|
|
|
root = pdb_read_jg_file(pdb, pdb_file->u.jg.toc, 1);
|
2006-05-10 21:35:51 +02:00
|
|
|
if (!root)
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
2006-05-10 21:35:51 +02:00
|
|
|
ERR("-Unable to get root from .PDB in %s\n", pdb_lookup->filename);
|
2004-11-21 16:51:47 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-05-10 21:35:51 +02:00
|
|
|
switch (root->Version)
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
2006-05-10 21:35:51 +02:00
|
|
|
case 19950623: /* VC 4.0 */
|
|
|
|
case 19950814:
|
|
|
|
case 19960307: /* VC 5.0 */
|
|
|
|
case 19970604: /* VC 6.0 */
|
|
|
|
break;
|
|
|
|
default:
|
2022-02-09 09:26:26 +01:00
|
|
|
ERR("-Unknown root block version %ld\n", root->Version);
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
2011-01-08 14:04:01 +01:00
|
|
|
if (pdb_lookup->kind != PDB_JG)
|
2006-05-10 21:35:51 +02:00
|
|
|
{
|
2011-01-08 14:04:01 +01:00
|
|
|
WARN("Found %s, but wrong PDB kind\n", pdb_lookup->filename);
|
2013-06-22 17:16:22 +02:00
|
|
|
pdb_free(root);
|
2011-01-08 14:04:01 +01:00
|
|
|
return FALSE;
|
2006-05-10 21:35:51 +02:00
|
|
|
}
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_file->kind = PDB_JG;
|
|
|
|
pdb_file->u.jg.timestamp = root->TimeDateStamp;
|
|
|
|
pdb_file->age = root->Age;
|
|
|
|
if (root->TimeDateStamp == pdb_lookup->timestamp) (*matched)++;
|
2022-02-09 09:26:26 +01:00
|
|
|
else WARN("Found %s, but wrong signature: %08lx %08lx\n",
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_lookup->filename, root->TimeDateStamp, pdb_lookup->timestamp);
|
|
|
|
if (root->Age == pdb_lookup->age) (*matched)++;
|
2022-02-09 09:26:26 +01:00
|
|
|
else WARN("Found %s, but wrong age: %08lx %08lx\n",
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_lookup->filename, root->Age, pdb_lookup->age);
|
2022-02-09 09:26:26 +01:00
|
|
|
TRACE("found JG for %s: age=%lx timestamp=%lx\n",
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_lookup->filename, root->Age, root->TimeDateStamp);
|
2011-01-17 21:54:04 +01:00
|
|
|
pdb_load_stream_name_table(pdb_file, &root->names[0], root->cbNames);
|
|
|
|
|
2006-05-10 21:35:51 +02:00
|
|
|
pdb_free(root);
|
|
|
|
}
|
|
|
|
else if (!memcmp(image, PDB_DS_IDENT, sizeof(PDB_DS_IDENT)))
|
|
|
|
{
|
|
|
|
const struct PDB_DS_HEADER* pdb = (const struct PDB_DS_HEADER*)image;
|
|
|
|
struct PDB_DS_ROOT* root;
|
|
|
|
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_file->u.ds.toc =
|
2006-05-10 21:35:51 +02:00
|
|
|
pdb_ds_read(pdb,
|
|
|
|
(const DWORD*)((const char*)pdb + pdb->toc_page * pdb->block_size),
|
|
|
|
pdb->toc_size);
|
2011-01-08 14:04:01 +01:00
|
|
|
root = pdb_read_ds_file(pdb, pdb_file->u.ds.toc, 1);
|
2006-05-10 21:35:51 +02:00
|
|
|
if (!root)
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
2006-05-10 21:35:51 +02:00
|
|
|
ERR("-Unable to get root from .PDB in %s\n", pdb_lookup->filename);
|
2004-11-21 16:51:47 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
2006-05-10 21:35:51 +02:00
|
|
|
switch (root->Version)
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
2006-05-10 21:35:51 +02:00
|
|
|
case 20000404:
|
|
|
|
break;
|
|
|
|
default:
|
2022-02-09 09:26:26 +01:00
|
|
|
ERR("-Unknown root block version %ld\n", root->Version);
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_file->kind = PDB_DS;
|
|
|
|
pdb_file->u.ds.guid = root->guid;
|
|
|
|
pdb_file->age = root->Age;
|
|
|
|
if (!memcmp(&root->guid, &pdb_lookup->guid, sizeof(GUID))) (*matched)++;
|
|
|
|
else WARN("Found %s, but wrong GUID: %s %s\n",
|
|
|
|
pdb_lookup->filename, debugstr_guid(&root->guid),
|
|
|
|
debugstr_guid(&pdb_lookup->guid));
|
|
|
|
if (root->Age == pdb_lookup->age) (*matched)++;
|
2022-02-09 09:26:26 +01:00
|
|
|
else WARN("Found %s, but wrong age: %08lx %08lx\n",
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_lookup->filename, root->Age, pdb_lookup->age);
|
2022-02-09 09:26:26 +01:00
|
|
|
TRACE("found DS for %s: age=%lx guid=%s\n",
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_lookup->filename, root->Age, debugstr_guid(&root->guid));
|
2011-01-17 21:54:04 +01:00
|
|
|
pdb_load_stream_name_table(pdb_file, &root->names[0], root->cbNames);
|
|
|
|
|
2006-05-10 21:35:51 +02:00
|
|
|
pdb_free(root);
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
if (0) /* some tool to dump the internal files from a PDB file */
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
int i, num_files;
|
|
|
|
|
2011-01-08 14:04:01 +01:00
|
|
|
switch (pdb_file->kind)
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
2011-01-08 14:04:01 +01:00
|
|
|
case PDB_JG: num_files = pdb_file->u.jg.toc->num_files; break;
|
|
|
|
case PDB_DS: num_files = pdb_file->u.ds.toc->num_files; break;
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < num_files; i++)
|
|
|
|
{
|
2011-01-08 14:04:14 +01:00
|
|
|
unsigned char* x = pdb_read_file(pdb_file, i);
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("********************** [%u]: size=%08x\n",
|
2011-01-08 14:04:01 +01:00
|
|
|
i, pdb_get_file_size(pdb_file, i));
|
|
|
|
dump(x, pdb_get_file_size(pdb_file, i));
|
2004-11-21 16:51:47 +01:00
|
|
|
pdb_free(x);
|
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2006-05-10 21:35:51 +02:00
|
|
|
return ret;
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
static BOOL pdb_process_internal(const struct process* pcs,
|
|
|
|
const struct msc_debug_info* msc_dbg,
|
2011-01-08 14:04:01 +01:00
|
|
|
const struct pdb_lookup* pdb_lookup,
|
2011-01-08 14:04:08 +01:00
|
|
|
struct pdb_module_info* pdb_module_info,
|
2004-11-21 16:51:47 +01:00
|
|
|
unsigned module_index);
|
|
|
|
|
|
|
|
static void pdb_process_symbol_imports(const struct process* pcs,
|
|
|
|
const struct msc_debug_info* msc_dbg,
|
2007-04-18 23:24:27 +02:00
|
|
|
const PDB_SYMBOLS* symbols,
|
2004-11-21 16:51:47 +01:00
|
|
|
const void* symbols_image,
|
2007-04-18 23:24:27 +02:00
|
|
|
const char* image,
|
|
|
|
const struct pdb_lookup* pdb_lookup,
|
2011-01-08 14:04:08 +01:00
|
|
|
struct pdb_module_info* pdb_module_info,
|
2004-11-21 16:51:47 +01:00
|
|
|
unsigned module_index)
|
|
|
|
{
|
|
|
|
if (module_index == -1 && symbols && symbols->pdbimport_size)
|
|
|
|
{
|
|
|
|
const PDB_SYMBOL_IMPORT*imp;
|
|
|
|
const void* first;
|
|
|
|
const void* last;
|
|
|
|
const char* ptr;
|
|
|
|
int i = 0;
|
2011-01-08 14:04:08 +01:00
|
|
|
struct pdb_file_info sf0 = pdb_module_info->pdb_files[0];
|
2004-11-21 16:51:47 +01:00
|
|
|
|
|
|
|
imp = (const PDB_SYMBOL_IMPORT*)((const char*)symbols_image + sizeof(PDB_SYMBOLS) +
|
|
|
|
symbols->module_size + symbols->offset_size +
|
|
|
|
symbols->hash_size + symbols->srcmodule_size);
|
2009-01-19 10:24:06 +01:00
|
|
|
first = imp;
|
2004-11-21 16:51:47 +01:00
|
|
|
last = (const char*)imp + symbols->pdbimport_size;
|
|
|
|
while (imp < (const PDB_SYMBOL_IMPORT*)last)
|
|
|
|
{
|
|
|
|
ptr = (const char*)imp + sizeof(*imp) + strlen(imp->filename);
|
2014-01-22 12:25:54 +01:00
|
|
|
if (i >= CV_MAX_MODULES) FIXME("Out of bounds!!!\n");
|
2020-04-07 14:25:07 +02:00
|
|
|
if (!stricmp(pdb_lookup->filename, imp->filename))
|
2004-11-21 16:51:47 +01:00
|
|
|
{
|
|
|
|
if (module_index != -1) FIXME("Twice the entry\n");
|
|
|
|
else module_index = i;
|
2011-01-08 14:04:08 +01:00
|
|
|
pdb_module_info->pdb_files[i] = sf0;
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
struct pdb_lookup imp_pdb_lookup;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-05-10 21:35:51 +02:00
|
|
|
/* FIXME: this is an import of a JG PDB file
|
|
|
|
* how's a DS PDB handled ?
|
|
|
|
*/
|
2004-11-21 16:51:47 +01:00
|
|
|
imp_pdb_lookup.filename = imp->filename;
|
|
|
|
imp_pdb_lookup.kind = PDB_JG;
|
2011-01-08 14:04:01 +01:00
|
|
|
imp_pdb_lookup.timestamp = imp->TimeDateStamp;
|
2006-05-10 21:35:51 +02:00
|
|
|
imp_pdb_lookup.age = imp->Age;
|
2022-02-09 09:26:26 +01:00
|
|
|
TRACE("got for %s: age=%lu ts=%lx\n",
|
2006-05-10 21:35:51 +02:00
|
|
|
imp->filename, imp->Age, imp->TimeDateStamp);
|
2011-01-08 14:04:08 +01:00
|
|
|
pdb_process_internal(pcs, msc_dbg, &imp_pdb_lookup, pdb_module_info, i);
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
imp = (const PDB_SYMBOL_IMPORT*)((const char*)first + ((ptr - (const char*)first + strlen(ptr) + 1 + 3) & ~3));
|
|
|
|
}
|
2011-01-08 14:04:08 +01:00
|
|
|
pdb_module_info->used_subfiles = i;
|
|
|
|
}
|
|
|
|
if (module_index == -1)
|
|
|
|
{
|
|
|
|
module_index = 0;
|
|
|
|
pdb_module_info->used_subfiles = 1;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2011-01-08 14:04:08 +01:00
|
|
|
cv_current_module = &cv_zmodules[module_index];
|
2014-01-22 12:25:54 +01:00
|
|
|
if (cv_current_module->allowed) FIXME("Already allowed??\n");
|
2004-11-21 16:51:47 +01:00
|
|
|
cv_current_module->allowed = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL pdb_process_internal(const struct process* pcs,
|
|
|
|
const struct msc_debug_info* msc_dbg,
|
2011-01-08 14:04:01 +01:00
|
|
|
const struct pdb_lookup* pdb_lookup,
|
2011-01-08 14:04:08 +01:00
|
|
|
struct pdb_module_info* pdb_module_info,
|
2004-11-21 16:51:47 +01:00
|
|
|
unsigned module_index)
|
|
|
|
{
|
2011-01-08 14:04:14 +01:00
|
|
|
HANDLE hMap = NULL;
|
2004-11-21 16:51:47 +01:00
|
|
|
char* image = NULL;
|
2005-09-02 16:47:36 +02:00
|
|
|
BYTE* symbols_image = NULL;
|
2008-09-29 21:32:38 +02:00
|
|
|
char* files_image = NULL;
|
|
|
|
DWORD files_size = 0;
|
2011-01-08 14:04:01 +01:00
|
|
|
unsigned matched;
|
2011-01-08 14:04:08 +01:00
|
|
|
struct pdb_file_info* pdb_file;
|
2004-11-21 16:51:47 +01:00
|
|
|
|
|
|
|
TRACE("Processing PDB file %s\n", pdb_lookup->filename);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2011-01-08 14:04:08 +01:00
|
|
|
pdb_file = &pdb_module_info->pdb_files[module_index == -1 ? 0 : module_index];
|
2004-11-21 16:51:47 +01:00
|
|
|
/* Open and map() .PDB file */
|
2011-01-08 14:04:14 +01:00
|
|
|
if ((hMap = map_pdb_file(pcs, pdb_lookup, msc_dbg->module)) == NULL ||
|
2004-11-21 16:51:47 +01:00
|
|
|
((image = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) == NULL))
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2005-02-09 23:21:58 +01:00
|
|
|
WARN("Unable to open .PDB file: %s\n", pdb_lookup->filename);
|
2011-01-08 14:04:14 +01:00
|
|
|
CloseHandle(hMap);
|
|
|
|
return FALSE;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2011-01-08 14:04:01 +01:00
|
|
|
if (!pdb_init(pdb_lookup, pdb_file, image, &matched) || matched != 2)
|
|
|
|
{
|
2011-01-08 14:04:14 +01:00
|
|
|
CloseHandle(hMap);
|
|
|
|
UnmapViewOfFile(image);
|
|
|
|
return FALSE;
|
2011-01-08 14:04:01 +01:00
|
|
|
}
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2011-01-08 14:04:14 +01:00
|
|
|
pdb_file->hMap = hMap;
|
|
|
|
pdb_file->image = image;
|
|
|
|
symbols_image = pdb_read_file(pdb_file, 3);
|
2004-11-21 16:51:47 +01:00
|
|
|
if (symbols_image)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
PDB_SYMBOLS symbols;
|
2008-09-06 22:20:19 +02:00
|
|
|
BYTE* globalimage;
|
2005-09-02 16:47:36 +02:00
|
|
|
BYTE* modimage;
|
2021-11-08 14:59:20 +01:00
|
|
|
BYTE* ipi_image;
|
|
|
|
struct codeview_type_parse ipi_ctp;
|
2005-09-02 16:47:36 +02:00
|
|
|
BYTE* file;
|
2004-11-21 16:51:47 +01:00
|
|
|
int header_size = 0;
|
2011-01-17 21:54:17 +01:00
|
|
|
PDB_STREAM_INDEXES* psi;
|
2021-11-10 16:42:14 +01:00
|
|
|
BOOL ipi_ok;
|
2011-01-17 21:54:17 +01:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
pdb_convert_symbols_header(&symbols, &header_size, symbols_image);
|
|
|
|
switch (symbols.version)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
case 0: /* VC 4.0 */
|
|
|
|
case 19960307: /* VC 5.0 */
|
|
|
|
case 19970606: /* VC 6.0 */
|
|
|
|
case 19990903:
|
|
|
|
break;
|
|
|
|
default:
|
2022-02-09 09:26:26 +01:00
|
|
|
ERR("-Unknown symbol info version %ld %08lx\n",
|
2004-11-21 16:51:47 +01:00
|
|
|
symbols.version, symbols.version);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2004-11-21 16:51:47 +01:00
|
|
|
|
2011-01-17 21:54:17 +01:00
|
|
|
switch (symbols.stream_index_size)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
case sizeof(PDB_STREAM_INDEXES_OLD):
|
|
|
|
/* no fpo ext stream in this case */
|
|
|
|
break;
|
|
|
|
case sizeof(PDB_STREAM_INDEXES):
|
|
|
|
psi = (PDB_STREAM_INDEXES*)((const char*)symbols_image + sizeof(PDB_SYMBOLS) +
|
|
|
|
symbols.module_size + symbols.offset_size +
|
|
|
|
symbols.hash_size + symbols.srcmodule_size +
|
|
|
|
symbols.pdbimport_size + symbols.unknown2_size);
|
|
|
|
pdb_file->fpoext_stream = psi->FPO_EXT;
|
|
|
|
break;
|
|
|
|
default:
|
2022-02-09 09:26:26 +01:00
|
|
|
FIXME("Unknown PDB_STREAM_INDEXES size (%ld)\n", symbols.stream_index_size);
|
2011-01-17 21:54:17 +01:00
|
|
|
break;
|
|
|
|
}
|
2011-01-11 20:34:46 +01:00
|
|
|
files_image = pdb_read_strings(pdb_file);
|
|
|
|
if (files_image) files_size = *(const DWORD*)(files_image + 8);
|
2008-09-29 21:32:38 +02:00
|
|
|
|
2011-01-08 14:04:08 +01:00
|
|
|
pdb_process_symbol_imports(pcs, msc_dbg, &symbols, symbols_image, image,
|
|
|
|
pdb_lookup, pdb_module_info, module_index);
|
2011-01-08 14:04:14 +01:00
|
|
|
pdb_process_types(msc_dbg, pdb_file);
|
2004-11-21 16:51:47 +01:00
|
|
|
|
2021-11-08 14:59:20 +01:00
|
|
|
ipi_image = pdb_read_file(pdb_file, 4);
|
2021-11-10 16:42:14 +01:00
|
|
|
ipi_ok = pdb_init_type_parse(msc_dbg, &ipi_ctp, ipi_image);
|
2021-11-08 14:59:20 +01:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
/* Read global symbol table */
|
2011-01-08 14:04:14 +01:00
|
|
|
globalimage = pdb_read_file(pdb_file, symbols.gsym_file);
|
2008-09-06 22:20:19 +02:00
|
|
|
if (globalimage)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2021-11-08 14:59:20 +01:00
|
|
|
codeview_snarf(msc_dbg, globalimage, 0, pdb_get_file_size(pdb_file, symbols.gsym_file),
|
|
|
|
NULL, FALSE);
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2008-09-29 21:32:29 +02:00
|
|
|
/* Read per-module symbols' tables */
|
2004-11-21 16:51:47 +01:00
|
|
|
file = symbols_image + header_size;
|
|
|
|
while (file - symbols_image < header_size + symbols.module_size)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-11-21 16:51:47 +01:00
|
|
|
PDB_SYMBOL_FILE_EX sfile;
|
|
|
|
const char* file_name;
|
|
|
|
unsigned size;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
HeapValidate(GetProcessHeap(), 0, NULL);
|
|
|
|
pdb_convert_symbol_file(&symbols, &sfile, &size, file);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2011-01-08 14:04:14 +01:00
|
|
|
modimage = pdb_read_file(pdb_file, sfile.file);
|
2004-11-21 16:51:47 +01:00
|
|
|
if (modimage)
|
|
|
|
{
|
2021-11-10 16:42:14 +01:00
|
|
|
struct cv_module_snarf cvmod = {ipi_ok ? &ipi_ctp : NULL, (const void*)(modimage + sfile.symbol_size), sfile.lineno2_size,
|
2021-11-08 14:59:20 +01:00
|
|
|
files_image + 12, files_size};
|
|
|
|
codeview_snarf(msc_dbg, modimage, sizeof(DWORD), sfile.symbol_size,
|
|
|
|
&cvmod, TRUE);
|
|
|
|
|
|
|
|
if (sfile.lineno_size && sfile.lineno2_size)
|
|
|
|
FIXME("Both line info present... only supporting second\n");
|
|
|
|
else if (sfile.lineno_size)
|
2008-09-29 21:32:29 +02:00
|
|
|
codeview_snarf_linetab(msc_dbg,
|
|
|
|
modimage + sfile.symbol_size,
|
|
|
|
sfile.lineno_size,
|
2011-01-08 14:04:08 +01:00
|
|
|
pdb_file->kind == PDB_JG);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
pdb_free(modimage);
|
|
|
|
}
|
|
|
|
file_name = (const char*)file + size;
|
|
|
|
file_name += strlen(file_name) + 1;
|
2009-02-22 22:28:19 +01:00
|
|
|
file = (BYTE*)((DWORD_PTR)(file_name + strlen(file_name) + 1 + 3) & ~3);
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
2008-09-06 22:20:19 +02:00
|
|
|
/* finish the remaining public and global information */
|
|
|
|
if (globalimage)
|
|
|
|
{
|
|
|
|
codeview_snarf_public(msc_dbg, globalimage, 0,
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_get_file_size(pdb_file, symbols.gsym_file));
|
2008-09-06 22:20:19 +02:00
|
|
|
pdb_free(globalimage);
|
|
|
|
}
|
2021-11-08 14:59:20 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, (DWORD*)ipi_ctp.offset);
|
|
|
|
pdb_free(ipi_image);
|
2004-11-21 16:51:47 +01:00
|
|
|
}
|
|
|
|
else
|
2011-01-08 14:04:08 +01:00
|
|
|
pdb_process_symbol_imports(pcs, msc_dbg, NULL, NULL, image,
|
|
|
|
pdb_lookup, pdb_module_info, module_index);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2006-10-06 04:38:54 +02:00
|
|
|
pdb_free(symbols_image);
|
2008-09-29 21:32:38 +02:00
|
|
|
pdb_free(files_image);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2011-01-08 14:04:14 +01:00
|
|
|
return TRUE;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
static BOOL pdb_process_file(const struct process* pcs,
|
|
|
|
const struct msc_debug_info* msc_dbg,
|
|
|
|
struct pdb_lookup* pdb_lookup)
|
|
|
|
{
|
2011-01-08 14:04:01 +01:00
|
|
|
BOOL ret;
|
2011-01-08 14:04:08 +01:00
|
|
|
struct module_format* modfmt;
|
|
|
|
struct pdb_module_info* pdb_module_info;
|
|
|
|
|
|
|
|
modfmt = HeapAlloc(GetProcessHeap(), 0,
|
|
|
|
sizeof(struct module_format) + sizeof(struct pdb_module_info));
|
|
|
|
if (!modfmt) return FALSE;
|
|
|
|
|
|
|
|
pdb_module_info = (void*)(modfmt + 1);
|
|
|
|
msc_dbg->module->format_info[DFI_PDB] = modfmt;
|
|
|
|
modfmt->module = msc_dbg->module;
|
|
|
|
modfmt->remove = pdb_module_remove;
|
2021-11-08 14:58:39 +01:00
|
|
|
modfmt->loc_compute = pdb_location_compute;
|
2011-01-08 14:04:08 +01:00
|
|
|
modfmt->u.pdb_info = pdb_module_info;
|
2004-11-21 16:51:47 +01:00
|
|
|
|
|
|
|
memset(cv_zmodules, 0, sizeof(cv_zmodules));
|
|
|
|
codeview_init_basic_types(msc_dbg->module);
|
2011-01-08 14:04:08 +01:00
|
|
|
ret = pdb_process_internal(pcs, msc_dbg, pdb_lookup,
|
|
|
|
msc_dbg->module->format_info[DFI_PDB]->u.pdb_info, -1);
|
2004-11-21 16:51:47 +01:00
|
|
|
codeview_clear_type_table();
|
2006-06-26 21:37:32 +02:00
|
|
|
if (ret)
|
|
|
|
{
|
2011-01-08 14:04:08 +01:00
|
|
|
struct pdb_module_info* pdb_info = msc_dbg->module->format_info[DFI_PDB]->u.pdb_info;
|
2018-11-25 10:15:48 +01:00
|
|
|
msc_dbg->module->module.SymType = SymPdb;
|
2011-01-08 14:04:08 +01:00
|
|
|
if (pdb_info->pdb_files[0].kind == PDB_JG)
|
|
|
|
msc_dbg->module->module.PdbSig = pdb_info->pdb_files[0].u.jg.timestamp;
|
2006-06-26 21:37:32 +02:00
|
|
|
else
|
2011-01-08 14:04:08 +01:00
|
|
|
msc_dbg->module->module.PdbSig70 = pdb_info->pdb_files[0].u.ds.guid;
|
|
|
|
msc_dbg->module->module.PdbAge = pdb_info->pdb_files[0].age;
|
2007-02-21 21:55:04 +01:00
|
|
|
MultiByteToWideChar(CP_ACP, 0, pdb_lookup->filename, -1,
|
|
|
|
msc_dbg->module->module.LoadedPdbName,
|
2018-07-12 23:49:34 +02:00
|
|
|
ARRAY_SIZE(msc_dbg->module->module.LoadedPdbName));
|
2006-06-26 21:37:32 +02:00
|
|
|
/* FIXME: we could have a finer grain here */
|
|
|
|
msc_dbg->module->module.LineNumbers = TRUE;
|
|
|
|
msc_dbg->module->module.GlobalSymbols = TRUE;
|
|
|
|
msc_dbg->module->module.TypeInfo = TRUE;
|
|
|
|
msc_dbg->module->module.SourceIndexed = TRUE;
|
|
|
|
msc_dbg->module->module.Publics = TRUE;
|
|
|
|
}
|
2011-01-17 21:57:46 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
msc_dbg->module->format_info[DFI_PDB] = NULL;
|
|
|
|
HeapFree(GetProcessHeap(), 0, modfmt);
|
|
|
|
}
|
2004-11-21 16:51:47 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-01-08 14:04:01 +01:00
|
|
|
BOOL pdb_fetch_file_info(const struct pdb_lookup* pdb_lookup, unsigned* matched)
|
2006-05-10 21:35:51 +02:00
|
|
|
{
|
|
|
|
HANDLE hFile, hMap = NULL;
|
|
|
|
char* image = NULL;
|
2011-01-08 14:04:14 +01:00
|
|
|
BOOL ret;
|
2011-01-08 14:04:01 +01:00
|
|
|
struct pdb_file_info pdb_file;
|
2006-05-10 21:35:51 +02:00
|
|
|
|
2007-02-21 21:55:15 +01:00
|
|
|
if ((hFile = CreateFileA(pdb_lookup->filename, GENERIC_READ, FILE_SHARE_READ, NULL,
|
2006-05-10 21:35:51 +02:00
|
|
|
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE ||
|
2007-02-21 21:55:15 +01:00
|
|
|
((hMap = CreateFileMappingW(hFile, NULL, PAGE_READONLY, 0, 0, NULL)) == NULL) ||
|
2006-05-10 21:35:51 +02:00
|
|
|
((image = MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0)) == NULL))
|
|
|
|
{
|
|
|
|
WARN("Unable to open .PDB file: %s\n", pdb_lookup->filename);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-01-08 14:04:01 +01:00
|
|
|
ret = pdb_init(pdb_lookup, &pdb_file, image, matched);
|
|
|
|
pdb_free_file(&pdb_file);
|
2006-05-10 21:35:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (image) UnmapViewOfFile(image);
|
|
|
|
if (hMap) CloseHandle(hMap);
|
2007-03-08 15:28:40 +01:00
|
|
|
if (hFile != INVALID_HANDLE_VALUE) CloseHandle(hFile);
|
2006-05-10 21:35:51 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-01-08 14:04:20 +01:00
|
|
|
/*========================================================================
|
|
|
|
* FPO unwinding code
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Stack unwinding is based on postfixed operations.
|
|
|
|
* Let's define our Postfix EValuator
|
|
|
|
*/
|
|
|
|
#define PEV_MAX_LEN 32
|
|
|
|
struct pevaluator
|
|
|
|
{
|
|
|
|
struct cpu_stack_walk* csw;
|
|
|
|
struct pool pool;
|
|
|
|
struct vector stack;
|
|
|
|
unsigned stk_index;
|
|
|
|
struct hash_table values;
|
|
|
|
char error[64];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct zvalue
|
|
|
|
{
|
|
|
|
DWORD_PTR value;
|
|
|
|
struct hash_table_elt elt;
|
|
|
|
};
|
|
|
|
|
2014-07-26 00:18:42 +02:00
|
|
|
#define PEV_ERROR(pev, msg) snprintf((pev)->error, sizeof((pev)->error), "%s", (msg))
|
|
|
|
#define PEV_ERROR1(pev, msg, pmt) snprintf((pev)->error, sizeof((pev)->error), (msg), (pmt))
|
2011-01-08 14:04:20 +01:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
static void pev_dump_stack(struct pevaluator* pev)
|
|
|
|
{
|
|
|
|
unsigned i;
|
|
|
|
FIXME("stack #%d\n", pev->stk_index);
|
|
|
|
for (i = 0; i < pev->stk_index; i++)
|
|
|
|
{
|
|
|
|
FIXME("\t%d) %s\n", i, *(char**)vector_at(&pev->stack, i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* get the value out of an operand (variable or literal) */
|
|
|
|
static BOOL pev_get_val(struct pevaluator* pev, const char* str, DWORD_PTR* val)
|
|
|
|
{
|
|
|
|
char* n;
|
|
|
|
struct hash_table_iter hti;
|
|
|
|
void* ptr;
|
|
|
|
|
|
|
|
switch (str[0])
|
|
|
|
{
|
|
|
|
case '$':
|
|
|
|
case '.':
|
|
|
|
hash_table_iter_init(&pev->values, &hti, str);
|
2011-03-13 21:30:53 +01:00
|
|
|
while ((ptr = hash_table_iter_up(&hti)))
|
|
|
|
{
|
2016-03-08 11:44:26 +01:00
|
|
|
if (!strcmp(CONTAINING_RECORD(ptr, struct zvalue, elt)->elt.name, str))
|
2011-03-13 21:30:53 +01:00
|
|
|
{
|
2016-03-08 11:44:26 +01:00
|
|
|
*val = CONTAINING_RECORD(ptr, struct zvalue, elt)->value;
|
2011-03-13 21:30:53 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return PEV_ERROR1(pev, "get_zvalue: no value found (%s)", str);
|
2011-01-08 14:04:20 +01:00
|
|
|
default:
|
|
|
|
*val = strtol(str, &n, 10);
|
|
|
|
if (n == str || *n != '\0')
|
|
|
|
return PEV_ERROR1(pev, "get_val: not a literal (%s)", str);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* push an operand onto the stack */
|
|
|
|
static BOOL pev_push(struct pevaluator* pev, const char* elt)
|
|
|
|
{
|
|
|
|
char** at;
|
|
|
|
if (pev->stk_index < vector_length(&pev->stack))
|
|
|
|
at = vector_at(&pev->stack, pev->stk_index);
|
|
|
|
else
|
|
|
|
at = vector_add(&pev->stack, &pev->pool);
|
|
|
|
if (!at) return PEV_ERROR(pev, "push: out of memory");
|
|
|
|
*at = pool_strdup(&pev->pool, elt);
|
|
|
|
pev->stk_index++;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* pop an operand from the stack */
|
|
|
|
static BOOL pev_pop(struct pevaluator* pev, char* elt)
|
|
|
|
{
|
|
|
|
char** at = vector_at(&pev->stack, --pev->stk_index);
|
|
|
|
if (!at) return PEV_ERROR(pev, "pop: stack empty");
|
|
|
|
strcpy(elt, *at);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* pop an operand from the stack, and gets its value */
|
|
|
|
static BOOL pev_pop_val(struct pevaluator* pev, DWORD_PTR* val)
|
|
|
|
{
|
|
|
|
char p[PEV_MAX_LEN];
|
|
|
|
|
|
|
|
return pev_pop(pev, p) && pev_get_val(pev, p, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* set var 'name' a new value (creates the var if it doesn't exist) */
|
|
|
|
static BOOL pev_set_value(struct pevaluator* pev, const char* name, DWORD_PTR val)
|
|
|
|
{
|
|
|
|
struct hash_table_iter hti;
|
|
|
|
void* ptr;
|
|
|
|
|
|
|
|
hash_table_iter_init(&pev->values, &hti, name);
|
2011-03-13 21:30:53 +01:00
|
|
|
while ((ptr = hash_table_iter_up(&hti)))
|
|
|
|
{
|
2016-03-08 11:44:26 +01:00
|
|
|
if (!strcmp(CONTAINING_RECORD(ptr, struct zvalue, elt)->elt.name, name))
|
2011-03-13 21:30:53 +01:00
|
|
|
{
|
2016-03-08 11:44:26 +01:00
|
|
|
CONTAINING_RECORD(ptr, struct zvalue, elt)->value = val;
|
2011-03-13 21:30:53 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!ptr)
|
2011-01-08 14:04:20 +01:00
|
|
|
{
|
|
|
|
struct zvalue* zv = pool_alloc(&pev->pool, sizeof(*zv));
|
|
|
|
if (!zv) return PEV_ERROR(pev, "set_value: out of memory");
|
|
|
|
zv->value = val;
|
|
|
|
|
|
|
|
zv->elt.name = pool_strdup(&pev->pool, name);
|
|
|
|
hash_table_add(&pev->values, &zv->elt);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* execute a binary operand from the two top most values on the stack.
|
|
|
|
* puts result on top of the stack */
|
|
|
|
static BOOL pev_binop(struct pevaluator* pev, char op)
|
|
|
|
{
|
|
|
|
char res[PEV_MAX_LEN];
|
|
|
|
DWORD_PTR v1, v2, c;
|
|
|
|
|
|
|
|
if (!pev_pop_val(pev, &v1) || !pev_pop_val(pev, &v2)) return FALSE;
|
|
|
|
switch (op)
|
|
|
|
{
|
|
|
|
case '+': c = v1 + v2; break;
|
|
|
|
case '-': c = v1 - v2; break;
|
|
|
|
case '*': c = v1 * v2; break;
|
|
|
|
case '/': c = v1 / v2; break;
|
|
|
|
case '%': c = v1 % v2; break;
|
|
|
|
default: return PEV_ERROR1(pev, "binop: unknown op (%c)", op);
|
|
|
|
}
|
2022-02-09 09:26:26 +01:00
|
|
|
snprintf(res, sizeof(res), "%Id", c);
|
2011-01-08 14:04:20 +01:00
|
|
|
pev_push(pev, res);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* pops top most operand, dereference it, on pushes the result on top of the stack */
|
|
|
|
static BOOL pev_deref(struct pevaluator* pev)
|
|
|
|
{
|
|
|
|
char res[PEV_MAX_LEN];
|
2018-07-31 18:17:39 +02:00
|
|
|
DWORD_PTR v1, v2 = 0;
|
2011-01-08 14:04:20 +01:00
|
|
|
|
|
|
|
if (!pev_pop_val(pev, &v1)) return FALSE;
|
2018-07-31 18:17:39 +02:00
|
|
|
if (!sw_read_mem(pev->csw, v1, &v2, pev->csw->cpu->word_size))
|
2022-02-09 09:26:26 +01:00
|
|
|
return PEV_ERROR1(pev, "deref: cannot read mem at %Ix\n", v1);
|
|
|
|
snprintf(res, sizeof(res), "%Id", v2);
|
2011-01-08 14:04:20 +01:00
|
|
|
pev_push(pev, res);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* assign value to variable (from two top most operands) */
|
|
|
|
static BOOL pev_assign(struct pevaluator* pev)
|
|
|
|
{
|
|
|
|
char p2[PEV_MAX_LEN];
|
|
|
|
DWORD_PTR v1;
|
|
|
|
|
|
|
|
if (!pev_pop_val(pev, &v1) || !pev_pop(pev, p2)) return FALSE;
|
|
|
|
if (p2[0] != '$') return PEV_ERROR1(pev, "assign: %s isn't a variable", p2);
|
|
|
|
pev_set_value(pev, p2, v1);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* initializes the postfix evaluator */
|
|
|
|
static void pev_init(struct pevaluator* pev, struct cpu_stack_walk* csw,
|
|
|
|
PDB_FPO_DATA* fpoext, struct pdb_cmd_pair* cpair)
|
|
|
|
{
|
|
|
|
pev->csw = csw;
|
|
|
|
pool_init(&pev->pool, 512);
|
|
|
|
vector_init(&pev->stack, sizeof(char*), 8);
|
|
|
|
pev->stk_index = 0;
|
|
|
|
hash_table_init(&pev->pool, &pev->values, 8);
|
|
|
|
pev->error[0] = '\0';
|
|
|
|
for (; cpair->name; cpair++)
|
|
|
|
pev_set_value(pev, cpair->name, *cpair->pvalue);
|
|
|
|
pev_set_value(pev, ".raSearchStart", fpoext->start);
|
|
|
|
pev_set_value(pev, ".cbLocals", fpoext->locals_size);
|
|
|
|
pev_set_value(pev, ".cbParams", fpoext->params_size);
|
|
|
|
pev_set_value(pev, ".cbSavedRegs", fpoext->savedregs_size);
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL pev_free(struct pevaluator* pev, struct pdb_cmd_pair* cpair)
|
|
|
|
{
|
|
|
|
DWORD_PTR val;
|
|
|
|
|
|
|
|
if (cpair) for (; cpair->name; cpair++)
|
|
|
|
{
|
|
|
|
if (pev_get_val(pev, cpair->name, &val))
|
|
|
|
*cpair->pvalue = val;
|
|
|
|
}
|
|
|
|
pool_destroy(&pev->pool);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL pdb_parse_cmd_string(struct cpu_stack_walk* csw, PDB_FPO_DATA* fpoext,
|
|
|
|
const char* cmd, struct pdb_cmd_pair* cpair)
|
|
|
|
{
|
|
|
|
char token[PEV_MAX_LEN];
|
|
|
|
char* ptok = token;
|
|
|
|
const char* ptr;
|
|
|
|
BOOL over = FALSE;
|
|
|
|
struct pevaluator pev;
|
|
|
|
|
|
|
|
pev_init(&pev, csw, fpoext, cpair);
|
|
|
|
for (ptr = cmd; !over; ptr++)
|
|
|
|
{
|
|
|
|
if (*ptr == ' ' || (over = *ptr == '\0'))
|
|
|
|
{
|
|
|
|
*ptok = '\0';
|
|
|
|
|
|
|
|
if (!strcmp(token, "+") || !strcmp(token, "-") || !strcmp(token, "*") ||
|
|
|
|
!strcmp(token, "/") || !strcmp(token, "%"))
|
|
|
|
{
|
|
|
|
if (!pev_binop(&pev, token[0])) goto done;
|
|
|
|
}
|
|
|
|
else if (!strcmp(token, "^"))
|
|
|
|
{
|
|
|
|
if (!pev_deref(&pev)) goto done;
|
|
|
|
}
|
|
|
|
else if (!strcmp(token, "="))
|
|
|
|
{
|
|
|
|
if (!pev_assign(&pev)) goto done;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!pev_push(&pev, token)) goto done;
|
|
|
|
}
|
|
|
|
ptok = token;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ptok - token >= PEV_MAX_LEN - 1)
|
|
|
|
{
|
|
|
|
PEV_ERROR1(&pev, "parse: token too long (%s)", ptr - (ptok - token));
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
*ptok++ = *ptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pev_free(&pev, cpair);
|
|
|
|
return TRUE;
|
|
|
|
done:
|
|
|
|
FIXME("Couldn't evaluate %s => %s\n", wine_dbgstr_a(cmd), pev.error);
|
|
|
|
pev_free(&pev, NULL);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2018-07-31 18:17:34 +02:00
|
|
|
BOOL pdb_virtual_unwind(struct cpu_stack_walk *csw, DWORD_PTR ip,
|
|
|
|
union ctx *context, struct pdb_cmd_pair *cpair)
|
2011-01-08 14:04:20 +01:00
|
|
|
{
|
|
|
|
struct module_pair pair;
|
|
|
|
struct pdb_module_info* pdb_info;
|
|
|
|
PDB_FPO_DATA* fpoext;
|
|
|
|
unsigned i, size, strsize;
|
|
|
|
char* strbase;
|
|
|
|
BOOL ret = TRUE;
|
|
|
|
|
2021-10-13 15:17:33 +02:00
|
|
|
if (!module_init_pair(&pair, csw->hProcess, ip)) return FALSE;
|
2011-01-08 14:04:20 +01:00
|
|
|
if (!pair.effective->format_info[DFI_PDB]) return FALSE;
|
|
|
|
pdb_info = pair.effective->format_info[DFI_PDB]->u.pdb_info;
|
2022-02-09 09:26:26 +01:00
|
|
|
TRACE("searching %Ix => %Ix\n", ip, ip - (DWORD_PTR)pair.effective->module.BaseOfImage);
|
2011-01-08 14:04:20 +01:00
|
|
|
ip -= (DWORD_PTR)pair.effective->module.BaseOfImage;
|
|
|
|
|
2011-01-11 20:34:46 +01:00
|
|
|
strbase = pdb_read_strings(&pdb_info->pdb_files[0]);
|
2011-01-08 14:04:20 +01:00
|
|
|
if (!strbase) return FALSE;
|
|
|
|
strsize = *(const DWORD*)(strbase + 8);
|
2011-01-17 21:54:17 +01:00
|
|
|
fpoext = pdb_read_file(&pdb_info->pdb_files[0], pdb_info->pdb_files[0].fpoext_stream);
|
|
|
|
size = pdb_get_file_size(&pdb_info->pdb_files[0], pdb_info->pdb_files[0].fpoext_stream);
|
2011-01-08 14:04:20 +01:00
|
|
|
if (fpoext && (size % sizeof(*fpoext)) == 0)
|
|
|
|
{
|
|
|
|
size /= sizeof(*fpoext);
|
|
|
|
for (i = 0; i < size; i++)
|
|
|
|
{
|
|
|
|
if (fpoext[i].start <= ip && ip < fpoext[i].start + fpoext[i].func_size)
|
|
|
|
{
|
2022-02-09 09:26:26 +01:00
|
|
|
TRACE("\t%08lx %08lx %8lx %8lx %4lx %4x %4x %08lx %s\n",
|
2011-01-08 14:04:20 +01:00
|
|
|
fpoext[i].start, fpoext[i].func_size, fpoext[i].locals_size,
|
|
|
|
fpoext[i].params_size, fpoext[i].maxstack_size, fpoext[i].prolog_size,
|
|
|
|
fpoext[i].savedregs_size, fpoext[i].flags,
|
|
|
|
fpoext[i].str_offset < strsize ?
|
|
|
|
wine_dbgstr_a(strbase + 12 + fpoext[i].str_offset) : "<out of bounds>");
|
|
|
|
if (fpoext[i].str_offset < strsize)
|
2011-03-13 21:30:53 +01:00
|
|
|
ret = pdb_parse_cmd_string(csw, &fpoext[i], strbase + 12 + fpoext[i].str_offset, cpair);
|
2011-01-08 14:04:20 +01:00
|
|
|
else
|
|
|
|
ret = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else ret = FALSE;
|
|
|
|
pdb_free(fpoext);
|
|
|
|
pdb_free(strbase);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/*========================================================================
|
|
|
|
* Process CodeView debug information.
|
|
|
|
*/
|
|
|
|
|
2004-11-21 16:51:47 +01:00
|
|
|
#define MAKESIG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((d) << 24))
|
|
|
|
#define CODEVIEW_NB09_SIG MAKESIG('N','B','0','9')
|
|
|
|
#define CODEVIEW_NB10_SIG MAKESIG('N','B','1','0')
|
|
|
|
#define CODEVIEW_NB11_SIG MAKESIG('N','B','1','1')
|
|
|
|
#define CODEVIEW_RSDS_SIG MAKESIG('R','S','D','S')
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2004-08-30 21:31:13 +02:00
|
|
|
static BOOL codeview_process_info(const struct process* pcs,
|
|
|
|
const struct msc_debug_info* msc_dbg)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2007-01-05 21:42:45 +01:00
|
|
|
const DWORD* signature = (const DWORD*)msc_dbg->root;
|
2004-08-30 21:31:13 +02:00
|
|
|
BOOL ret = FALSE;
|
2004-11-21 16:51:47 +01:00
|
|
|
struct pdb_lookup pdb_lookup;
|
2004-08-30 21:31:13 +02:00
|
|
|
|
2007-01-05 21:42:45 +01:00
|
|
|
TRACE("Processing signature %.4s\n", (const char*)signature);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2007-01-05 21:42:45 +01:00
|
|
|
switch (*signature)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
case CODEVIEW_NB09_SIG:
|
|
|
|
case CODEVIEW_NB11_SIG:
|
|
|
|
{
|
2007-01-05 21:42:45 +01:00
|
|
|
const OMFSignature* cv = (const OMFSignature*)msc_dbg->root;
|
|
|
|
const OMFDirHeader* hdr = (const OMFDirHeader*)(msc_dbg->root + cv->filepos);
|
|
|
|
const OMFDirEntry* ent;
|
|
|
|
const OMFDirEntry* prev;
|
|
|
|
const OMFDirEntry* next;
|
2004-04-06 00:21:27 +02:00
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
codeview_init_basic_types(msc_dbg->module);
|
2006-03-18 13:33:03 +01:00
|
|
|
|
|
|
|
for (i = 0; i < hdr->cDir; i++)
|
|
|
|
{
|
2007-01-05 21:42:45 +01:00
|
|
|
ent = (const OMFDirEntry*)((const BYTE*)hdr + hdr->cbDirHeader + i * hdr->cbDirEntry);
|
|
|
|
if (ent->SubSection == sstGlobalTypes)
|
2006-03-18 13:33:03 +01:00
|
|
|
{
|
2007-01-05 21:42:45 +01:00
|
|
|
const OMFGlobalTypes* types;
|
2006-03-18 13:33:03 +01:00
|
|
|
struct codeview_type_parse ctp;
|
|
|
|
|
2007-01-05 21:42:45 +01:00
|
|
|
types = (const OMFGlobalTypes*)(msc_dbg->root + ent->lfo);
|
2006-03-18 13:33:03 +01:00
|
|
|
ctp.module = msc_dbg->module;
|
|
|
|
ctp.offset = (const DWORD*)(types + 1);
|
|
|
|
ctp.num = types->cTypes;
|
|
|
|
ctp.table = (const BYTE*)(ctp.offset + types->cTypes);
|
|
|
|
|
|
|
|
cv_current_module = &cv_zmodules[0];
|
2014-01-22 12:25:54 +01:00
|
|
|
if (cv_current_module->allowed) FIXME("Already allowed??\n");
|
2006-03-18 13:33:03 +01:00
|
|
|
cv_current_module->allowed = TRUE;
|
|
|
|
|
|
|
|
codeview_parse_type_table(&ctp);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-05 21:42:45 +01:00
|
|
|
ent = (const OMFDirEntry*)((const BYTE*)hdr + hdr->cbDirHeader);
|
2004-04-06 00:21:27 +02:00
|
|
|
for (i = 0; i < hdr->cDir; i++, ent = next)
|
|
|
|
{
|
2006-03-18 13:33:03 +01:00
|
|
|
next = (i == hdr->cDir-1) ? NULL :
|
2007-01-05 21:42:45 +01:00
|
|
|
(const OMFDirEntry*)((const BYTE*)ent + hdr->cbDirEntry);
|
2006-03-18 13:33:03 +01:00
|
|
|
prev = (i == 0) ? NULL :
|
2007-01-05 21:42:45 +01:00
|
|
|
(const OMFDirEntry*)((const BYTE*)ent - hdr->cbDirEntry);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2007-01-05 21:42:45 +01:00
|
|
|
if (ent->SubSection == sstAlignSym)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2021-11-08 14:59:20 +01:00
|
|
|
codeview_snarf(msc_dbg, msc_dbg->root + ent->lfo, sizeof(DWORD), ent->cb,
|
|
|
|
NULL, TRUE);
|
2008-09-29 21:32:29 +02:00
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
/*
|
|
|
|
* Check the next and previous entry. If either is a
|
|
|
|
* sstSrcModule, it contains the line number info for
|
|
|
|
* this file.
|
|
|
|
*
|
|
|
|
* FIXME: This is not a general solution!
|
|
|
|
*/
|
2008-09-29 21:32:29 +02:00
|
|
|
if (next && next->iMod == ent->iMod && next->SubSection == sstSrcModule)
|
|
|
|
codeview_snarf_linetab(msc_dbg, msc_dbg->root + next->lfo,
|
|
|
|
next->cb, TRUE);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2008-09-29 21:32:29 +02:00
|
|
|
if (prev && prev->iMod == ent->iMod && prev->SubSection == sstSrcModule)
|
|
|
|
codeview_snarf_linetab(msc_dbg, msc_dbg->root + prev->lfo,
|
|
|
|
prev->cb, TRUE);
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-30 21:31:13 +02:00
|
|
|
msc_dbg->module->module.SymType = SymCv;
|
2006-06-26 21:37:32 +02:00
|
|
|
/* FIXME: we could have a finer grain here */
|
|
|
|
msc_dbg->module->module.LineNumbers = TRUE;
|
|
|
|
msc_dbg->module->module.GlobalSymbols = TRUE;
|
|
|
|
msc_dbg->module->module.TypeInfo = TRUE;
|
|
|
|
msc_dbg->module->module.SourceIndexed = TRUE;
|
|
|
|
msc_dbg->module->module.Publics = TRUE;
|
2006-03-18 13:33:03 +01:00
|
|
|
codeview_clear_type_table();
|
2004-08-30 21:31:13 +02:00
|
|
|
ret = TRUE;
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case CODEVIEW_NB10_SIG:
|
|
|
|
{
|
2007-01-05 21:42:45 +01:00
|
|
|
const CODEVIEW_PDB_DATA* pdb = (const CODEVIEW_PDB_DATA*)msc_dbg->root;
|
2004-11-21 16:51:47 +01:00
|
|
|
pdb_lookup.filename = pdb->name;
|
|
|
|
pdb_lookup.kind = PDB_JG;
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_lookup.timestamp = pdb->timestamp;
|
2008-08-29 21:50:33 +02:00
|
|
|
pdb_lookup.age = pdb->age;
|
2004-11-21 16:51:47 +01:00
|
|
|
ret = pdb_process_file(pcs, msc_dbg, &pdb_lookup);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case CODEVIEW_RSDS_SIG:
|
|
|
|
{
|
2007-01-05 21:42:45 +01:00
|
|
|
const OMFSignatureRSDS* rsds = (const OMFSignatureRSDS*)msc_dbg->root;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
2022-02-09 09:26:26 +01:00
|
|
|
TRACE("Got RSDS type of PDB file: guid=%s age=%08lx name=%s\n",
|
2008-08-29 21:50:33 +02:00
|
|
|
wine_dbgstr_guid(&rsds->guid), rsds->age, rsds->name);
|
2004-11-21 16:51:47 +01:00
|
|
|
pdb_lookup.filename = rsds->name;
|
|
|
|
pdb_lookup.kind = PDB_DS;
|
2011-01-08 14:04:01 +01:00
|
|
|
pdb_lookup.guid = rsds->guid;
|
2008-08-29 21:50:33 +02:00
|
|
|
pdb_lookup.age = rsds->age;
|
2004-11-21 16:51:47 +01:00
|
|
|
ret = pdb_process_file(pcs, msc_dbg, &pdb_lookup);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2022-02-09 09:26:26 +01:00
|
|
|
ERR("Unknown CODEVIEW signature %08lx in module %s\n",
|
2021-09-06 10:40:08 +02:00
|
|
|
*signature, debugstr_w(msc_dbg->module->modulename));
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
}
|
2006-06-26 21:37:32 +02:00
|
|
|
if (ret)
|
|
|
|
{
|
2007-01-05 21:42:45 +01:00
|
|
|
msc_dbg->module->module.CVSig = *signature;
|
|
|
|
memcpy(msc_dbg->module->module.CVData, msc_dbg->root,
|
2006-06-26 21:37:32 +02:00
|
|
|
sizeof(msc_dbg->module->module.CVData));
|
|
|
|
}
|
2004-08-30 21:31:13 +02:00
|
|
|
return ret;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*========================================================================
|
|
|
|
* Process debug directory.
|
|
|
|
*/
|
2004-08-30 21:31:13 +02:00
|
|
|
BOOL pe_load_debug_directory(const struct process* pcs, struct module* module,
|
2004-10-11 22:08:07 +02:00
|
|
|
const BYTE* mapping,
|
|
|
|
const IMAGE_SECTION_HEADER* sectp, DWORD nsect,
|
|
|
|
const IMAGE_DEBUG_DIRECTORY* dbg, int nDbg)
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
2004-08-30 21:31:13 +02:00
|
|
|
BOOL ret;
|
2004-04-06 00:21:27 +02:00
|
|
|
int i;
|
|
|
|
struct msc_debug_info msc_dbg;
|
|
|
|
|
|
|
|
msc_dbg.module = module;
|
2004-10-11 22:08:07 +02:00
|
|
|
msc_dbg.nsect = nsect;
|
|
|
|
msc_dbg.sectp = sectp;
|
2004-04-06 00:21:27 +02:00
|
|
|
msc_dbg.nomap = 0;
|
|
|
|
msc_dbg.omapp = NULL;
|
|
|
|
|
|
|
|
__TRY
|
|
|
|
{
|
2004-08-30 21:31:13 +02:00
|
|
|
ret = FALSE;
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
/* First, watch out for OMAP data */
|
|
|
|
for (i = 0; i < nDbg; i++)
|
|
|
|
{
|
|
|
|
if (dbg[i].Type == IMAGE_DEBUG_TYPE_OMAP_FROM_SRC)
|
|
|
|
{
|
2021-11-02 15:33:04 +01:00
|
|
|
msc_dbg.nomap = dbg[i].SizeOfData / sizeof(OMAP);
|
|
|
|
msc_dbg.omapp = (const OMAP*)(mapping + dbg[i].PointerToRawData);
|
2004-04-06 00:21:27 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now, try to parse CodeView debug info */
|
|
|
|
for (i = 0; i < nDbg; i++)
|
|
|
|
{
|
|
|
|
if (dbg[i].Type == IMAGE_DEBUG_TYPE_CODEVIEW)
|
|
|
|
{
|
|
|
|
msc_dbg.root = mapping + dbg[i].PointerToRawData;
|
2004-08-30 21:31:13 +02:00
|
|
|
if ((ret = codeview_process_info(pcs, &msc_dbg))) goto done;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If not found, try to parse COFF debug info */
|
|
|
|
for (i = 0; i < nDbg; i++)
|
|
|
|
{
|
|
|
|
if (dbg[i].Type == IMAGE_DEBUG_TYPE_COFF)
|
|
|
|
{
|
|
|
|
msc_dbg.root = mapping + dbg[i].PointerToRawData;
|
2004-08-30 21:31:13 +02:00
|
|
|
if ((ret = coff_process_info(&msc_dbg))) goto done;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
done:
|
|
|
|
/* FIXME: this should be supported... this is the debug information for
|
|
|
|
* functions compiled without a frame pointer (FPO = frame pointer omission)
|
|
|
|
* the associated data helps finding out the relevant information
|
|
|
|
*/
|
|
|
|
for (i = 0; i < nDbg; i++)
|
|
|
|
if (dbg[i].Type == IMAGE_DEBUG_TYPE_FPO)
|
2004-11-21 16:51:47 +01:00
|
|
|
FIXME("This guy has FPO information\n");
|
|
|
|
#if 0
|
2004-04-06 00:21:27 +02:00
|
|
|
|
|
|
|
#define FRAME_FPO 0
|
|
|
|
#define FRAME_TRAP 1
|
|
|
|
#define FRAME_TSS 2
|
|
|
|
|
|
|
|
typedef struct _FPO_DATA
|
|
|
|
{
|
|
|
|
DWORD ulOffStart; /* offset 1st byte of function code */
|
|
|
|
DWORD cbProcSize; /* # bytes in function */
|
|
|
|
DWORD cdwLocals; /* # bytes in locals/4 */
|
|
|
|
WORD cdwParams; /* # bytes in params/4 */
|
|
|
|
|
|
|
|
WORD cbProlog : 8; /* # bytes in prolog */
|
|
|
|
WORD cbRegs : 3; /* # regs saved */
|
|
|
|
WORD fHasSEH : 1; /* TRUE if SEH in func */
|
|
|
|
WORD fUseBP : 1; /* TRUE if EBP has been allocated */
|
|
|
|
WORD reserved : 1; /* reserved for future use */
|
|
|
|
WORD cbFrame : 2; /* frame type */
|
|
|
|
} FPO_DATA;
|
|
|
|
#endif
|
2004-11-21 16:51:47 +01:00
|
|
|
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
2005-12-16 17:17:57 +01:00
|
|
|
__EXCEPT_PAGE_FAULT
|
2004-04-06 00:21:27 +02:00
|
|
|
{
|
|
|
|
ERR("Got a page fault while loading symbols\n");
|
2004-08-30 21:31:13 +02:00
|
|
|
ret = FALSE;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|
|
|
|
__ENDTRY
|
2004-08-30 21:31:13 +02:00
|
|
|
return ret;
|
2004-04-06 00:21:27 +02:00
|
|
|
}
|