mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 00:45:24 +00:00
* Improve the way we create rossym debug info. The effort results in ~85% *smaller* build folder with ninja all with no code changes.
[DBGHELPHOST] * Introduce a self-contained, static library version of dbghelp, in order to leverage its PE DWARF support. Thanks to Jerome Gardou for his work on the compatibility layer, and to Thomas Faber for helping me with the review/improvements. * Unify the new host lib with the existing dll codebase using preprocessor conditions. This prevents code duplication. * Skip as much unneeded functionality as possible when compiling dbghelphost to keep it light and straight to the point. [RSYM] * Introduce the required functions that allow parsing DWARF (using dbghelphost) and using it (along with coff symbols) to create the rossym debug info. Brought to you by Awesome Arty with some bugfixes from Jerome Gardou. Many thanks to Thomas Faber for assisting me with the testing/bug hunting. [CMAKE/GCC] * Introduce a combination of dwarf and debug emission flags that ensure the smallest debug info size among all the possible options we have. * Introduce compressed debug sections that I already included the support for in RosBE 2.1. Thanks to the mingw-w64 folks (Kai Tietz) for the patch. * Don't compress debug sections of C++ modules for now due to a bug in the toolchain that leads to spamming the build at link time with a warning. * Don't run rsym on the RC shared libraries. Thanks to Thomas Faber for spotting this. [DBGHELP] * Update the ros diff to reflect the changes introduced by the dbghelphost unification. svn path=/trunk/; revision=59505
This commit is contained in:
parent
cc5e6fe6a6
commit
4f0694e3af
28 changed files with 3781 additions and 183 deletions
|
@ -65,6 +65,7 @@ if(NOT CMAKE_CROSSCOMPILING)
|
|||
|
||||
include_directories(include/host)
|
||||
|
||||
add_subdirectory(dll/win32/dbghelp)
|
||||
add_subdirectory(tools)
|
||||
add_subdirectory(lib)
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ add_compile_flags("-fdebug-prefix-map=\"${REACTOS_SOURCE_DIR_NATIVE}\"=ReactOS")
|
|||
if(SEPARATE_DBG)
|
||||
add_compile_flags("-gdwarf-2 -g2")
|
||||
else()
|
||||
add_compile_flags("-gstabs+")
|
||||
add_compile_flags("-gdwarf-2 -gstrict-dwarf -femit-struct-debug-detailed=none -feliminate-unused-debug-symbols")
|
||||
endif()
|
||||
|
||||
# For some reason, cmake sets -fPIC, and we don't want it
|
||||
|
@ -154,16 +154,15 @@ else()
|
|||
"<CMAKE_CXX_COMPILER> ${CMAKE_CXX_FLAGS} <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
|
||||
"${RSYM} <TARGET> <TARGET>")
|
||||
set(CMAKE_RC_CREATE_SHARED_LIBRARY
|
||||
"<CMAKE_C_COMPILER> ${CMAKE_C_FLAGS} <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>"
|
||||
"${RSYM} <TARGET> <TARGET>")
|
||||
"<CMAKE_C_COMPILER> ${CMAKE_C_FLAGS} <CMAKE_SHARED_LIBRARY_C_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-nostdlib -Wl,--enable-auto-image-base,--disable-auto-import,--disable-stdcall-fixup")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} -Wl,--disable-stdcall-fixup")
|
||||
|
||||
SET(CMAKE_C_COMPILE_OBJECT "${CCACHE} <CMAKE_C_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
|
||||
SET(CMAKE_C_COMPILE_OBJECT "${CCACHE} <CMAKE_C_COMPILER> <DEFINES> -Wa,--compress-debug-sections <FLAGS> -o <OBJECT> -c <SOURCE>")
|
||||
SET(CMAKE_CXX_COMPILE_OBJECT "${CCACHE} <CMAKE_CXX_COMPILER> <DEFINES> <FLAGS> -o <OBJECT> -c <SOURCE>")
|
||||
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -x assembler-with-cpp -o <OBJECT> -I${REACTOS_SOURCE_DIR}/include/asm -I${REACTOS_BINARY_DIR}/include/asm <FLAGS> <DEFINES> -D__ASM__ -c <SOURCE>")
|
||||
set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> -Wa,--compress-debug-sections -x assembler-with-cpp -o <OBJECT> -I${REACTOS_SOURCE_DIR}/include/asm -I${REACTOS_BINARY_DIR}/include/asm <FLAGS> <DEFINES> -D__ASM__ -c <SOURCE>")
|
||||
|
||||
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff <FLAGS> -DRC_INVOKED -D__WIN32__=1 -D__FLAT__=1 ${I18N_DEFS} <DEFINES> <SOURCE> <OBJECT>")
|
||||
set(CMAKE_DEPFILE_FLAGS_RC "--preprocessor \"${MINGW_TOOLCHAIN_PREFIX}gcc${MINGW_TOOLCHAIN_SUFFIX} -E -xc-header -MMD -MF <DEPFILE> -MT <OBJECT>\" ")
|
||||
|
|
|
@ -1,59 +1,90 @@
|
|||
|
||||
add_definitions(
|
||||
-D__WINESRC__
|
||||
-D_WINE
|
||||
-DHAVE_ALLOCA_H
|
||||
-D_IMAGEHLP_SOURCE_)
|
||||
if(NOT CMAKE_CROSSCOMPILING)
|
||||
add_definitions(-DDBGHELP_STATIC_LIB)
|
||||
|
||||
if(ARCH STREQUAL "i386")
|
||||
add_definitions(-D_X86_)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${REACTOS_SOURCE_DIR}/tools
|
||||
${REACTOS_SOURCE_DIR}/include/reactos/libs/zlib)
|
||||
|
||||
list(APPEND SOURCE
|
||||
compat.c
|
||||
dbghelp.c
|
||||
dwarf.c
|
||||
module.c
|
||||
pe_module.c
|
||||
source.c
|
||||
stabs.c
|
||||
storage.c
|
||||
symbol.c
|
||||
type.c)
|
||||
|
||||
if(ARCH STREQUAL "i386")
|
||||
list(APPEND SOURCE cpu_i386.c)
|
||||
endif()
|
||||
|
||||
add_library(dbghelphost ${SOURCE})
|
||||
else()
|
||||
add_definitions(
|
||||
-D__WINESRC__
|
||||
-D_WINE
|
||||
-DHAVE_ALLOCA_H
|
||||
-D_IMAGEHLP_SOURCE_)
|
||||
|
||||
if(ARCH STREQUAL "amd64")
|
||||
add_definitions(-DUNW_FLAG_NHANDLER=0 -DUNW_FLAG_EHANDLER=1 -DUNW_FLAG_UHANDLER=2 -DUNW_FLAG_CHAININFO=3)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${REACTOS_SOURCE_DIR}/include/reactos/wine
|
||||
${REACTOS_SOURCE_DIR}/include/reactos/libs/zlib)
|
||||
|
||||
spec2def(dbghelp.dll dbghelp.spec ADD_IMPORTLIB)
|
||||
|
||||
list(APPEND SOURCE
|
||||
coff.c
|
||||
cpu_arm.c
|
||||
cpu_arm64.c
|
||||
cpu_i386.c
|
||||
cpu_ppc.c
|
||||
cpu_x86_64.c
|
||||
crc32.c
|
||||
dbghelp.c
|
||||
dwarf.c
|
||||
elf_module.c
|
||||
image.c
|
||||
macho_module.c
|
||||
minidump.c
|
||||
module.c
|
||||
msc.c
|
||||
path.c
|
||||
pe_module.c
|
||||
rosstubs.c
|
||||
source.c
|
||||
stabs.c
|
||||
stack.c
|
||||
storage.c
|
||||
symbol.c
|
||||
type.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/dbghelp_stubs.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/dbghelp.def)
|
||||
|
||||
add_library(dbghelp SHARED ${SOURCE} version.rc)
|
||||
|
||||
if(NOT MSVC)
|
||||
# FIXME: http://www.cmake.org/Bug/view.php?id=12998
|
||||
#allow_warnings(dbghelp)
|
||||
set_source_files_properties(${SOURCE} PROPERTIES COMPILE_FLAGS "-Wno-error")
|
||||
endif()
|
||||
|
||||
set_module_type(dbghelp win32dll)
|
||||
target_link_libraries(dbghelp wine ${PSEH_LIB} oldnames zlib)
|
||||
add_delay_importlibs(dbghelp version)
|
||||
add_importlibs(dbghelp psapi msvcrt kernel32 ntdll)
|
||||
add_pch(dbghelp dbghelp_private.h)
|
||||
add_cd_file(TARGET dbghelp DESTINATION reactos/system32 FOR all)
|
||||
|
||||
if(ARCH STREQUAL "amd64")
|
||||
add_definitions(-DUNW_FLAG_NHANDLER=0 -DUNW_FLAG_EHANDLER=1 -DUNW_FLAG_UHANDLER=2 -DUNW_FLAG_CHAININFO=3)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${REACTOS_SOURCE_DIR}/include/reactos/wine
|
||||
${REACTOS_SOURCE_DIR}/include/reactos/libs/zlib)
|
||||
|
||||
spec2def(dbghelp.dll dbghelp.spec ADD_IMPORTLIB)
|
||||
|
||||
list(APPEND SOURCE
|
||||
coff.c
|
||||
cpu_arm.c
|
||||
cpu_arm64.c
|
||||
cpu_i386.c
|
||||
cpu_ppc.c
|
||||
cpu_x86_64.c
|
||||
crc32.c
|
||||
dbghelp.c
|
||||
dwarf.c
|
||||
elf_module.c
|
||||
image.c
|
||||
macho_module.c
|
||||
minidump.c
|
||||
module.c
|
||||
msc.c
|
||||
path.c
|
||||
pe_module.c
|
||||
rosstubs.c
|
||||
source.c
|
||||
stabs.c
|
||||
stack.c
|
||||
storage.c
|
||||
symbol.c
|
||||
type.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/dbghelp_stubs.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/dbghelp.def)
|
||||
|
||||
add_library(dbghelp SHARED ${SOURCE} version.rc)
|
||||
|
||||
if(NOT MSVC)
|
||||
# FIXME: http://www.cmake.org/Bug/view.php?id=12998
|
||||
#allow_warnings(dbghelp)
|
||||
set_source_files_properties(${SOURCE} PROPERTIES COMPILE_FLAGS "-Wno-error")
|
||||
endif()
|
||||
|
||||
set_module_type(dbghelp win32dll)
|
||||
target_link_libraries(dbghelp wine ${PSEH_LIB} oldnames zlib)
|
||||
add_delay_importlibs(dbghelp version)
|
||||
add_importlibs(dbghelp psapi msvcrt kernel32 ntdll)
|
||||
add_pch(dbghelp dbghelp_private.h)
|
||||
add_cd_file(TARGET dbghelp DESTINATION reactos/system32 FOR all)
|
||||
|
|
399
reactos/dll/win32/dbghelp/compat.c
Normal file
399
reactos/dll/win32/dbghelp/compat.c
Normal file
|
@ -0,0 +1,399 @@
|
|||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "dbghelp_private.h"
|
||||
|
||||
void* __HeapAlloc(int heap, int flags, size_t size)
|
||||
{
|
||||
void * ret = malloc(size);
|
||||
if(flags & HEAP_ZERO_MEMORY)
|
||||
memset(ret, 0, size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void* __HeapReAlloc(int heap, DWORD d2, void *slab, SIZE_T newsize)
|
||||
{
|
||||
return realloc(slab, newsize);
|
||||
}
|
||||
|
||||
WCHAR* lstrcpynW(WCHAR* lpString1, const WCHAR* lpString2, int iMaxLength)
|
||||
{
|
||||
LPWSTR d = lpString1;
|
||||
const WCHAR* s = lpString2;
|
||||
UINT count = iMaxLength;
|
||||
|
||||
while ((count > 1) && *s)
|
||||
{
|
||||
count--;
|
||||
*d++ = *s++;
|
||||
}
|
||||
|
||||
if (count)
|
||||
*d = 0;
|
||||
|
||||
return lpString1;
|
||||
}
|
||||
|
||||
PIMAGE_NT_HEADERS __RtlImageNtHeader(void *data)
|
||||
{
|
||||
PIMAGE_DOS_HEADER DosHeader = (PIMAGE_DOS_HEADER)data;
|
||||
PIMAGE_NT_HEADERS NtHeaders;
|
||||
PCHAR NtHeaderPtr;
|
||||
if (DosHeader->e_magic != IMAGE_DOS_SIGNATURE)
|
||||
return NULL;
|
||||
NtHeaderPtr = ((PCHAR)data) + DosHeader->e_lfanew;
|
||||
NtHeaders = (PIMAGE_NT_HEADERS)NtHeaderPtr;
|
||||
if (NtHeaders->Signature != IMAGE_NT_SIGNATURE)
|
||||
return NULL;
|
||||
return NtHeaders;
|
||||
}
|
||||
|
||||
PIMAGE_SECTION_HEADER
|
||||
__RtlImageRvaToSection(
|
||||
const IMAGE_NT_HEADERS* NtHeader,
|
||||
PVOID BaseAddress,
|
||||
ULONG Rva)
|
||||
{
|
||||
PIMAGE_SECTION_HEADER Section;
|
||||
ULONG Va;
|
||||
ULONG Count;
|
||||
|
||||
Count = SWAPW(NtHeader->FileHeader.NumberOfSections);
|
||||
Section = IMAGE_FIRST_SECTION(NtHeader);
|
||||
|
||||
while (Count--)
|
||||
{
|
||||
Va = SWAPD(Section->VirtualAddress);
|
||||
if ((Va <= Rva) &&
|
||||
(Rva < Va + SWAPD(Section->Misc.VirtualSize)))
|
||||
return Section;
|
||||
Section++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PVOID
|
||||
__RtlImageRvaToVa
|
||||
(const IMAGE_NT_HEADERS* NtHeader,
|
||||
PVOID BaseAddress,
|
||||
ULONG Rva,
|
||||
PIMAGE_SECTION_HEADER *SectionHeader)
|
||||
{
|
||||
PIMAGE_SECTION_HEADER Section = NULL;
|
||||
|
||||
if (SectionHeader)
|
||||
Section = *SectionHeader;
|
||||
|
||||
if ((Section == NULL) ||
|
||||
(Rva < SWAPD(Section->VirtualAddress)) ||
|
||||
(Rva >= SWAPD(Section->VirtualAddress) + SWAPD(Section->Misc.VirtualSize)))
|
||||
{
|
||||
Section = RtlImageRvaToSection (NtHeader, BaseAddress, Rva);
|
||||
if (Section == NULL)
|
||||
return NULL;
|
||||
|
||||
if (SectionHeader)
|
||||
*SectionHeader = Section;
|
||||
}
|
||||
|
||||
return (PVOID)((ULONG_PTR)BaseAddress +
|
||||
Rva +
|
||||
SWAPD(Section->PointerToRawData) -
|
||||
(ULONG_PTR)SWAPD(Section->VirtualAddress));
|
||||
}
|
||||
|
||||
PVOID
|
||||
__RtlImageDirectoryEntryToData(
|
||||
PVOID BaseAddress,
|
||||
BOOLEAN MappedAsImage,
|
||||
USHORT Directory,
|
||||
PULONG Size)
|
||||
{
|
||||
PIMAGE_NT_HEADERS NtHeader;
|
||||
ULONG Va;
|
||||
|
||||
/* Magic flag for non-mapped images. */
|
||||
if ((ULONG_PTR)BaseAddress & 1)
|
||||
{
|
||||
BaseAddress = (PVOID)((ULONG_PTR)BaseAddress & ~1);
|
||||
MappedAsImage = FALSE;
|
||||
}
|
||||
|
||||
NtHeader = RtlImageNtHeader(BaseAddress);
|
||||
if (NtHeader == NULL)
|
||||
return NULL;
|
||||
|
||||
if (Directory >= SWAPD(NtHeader->OptionalHeader.NumberOfRvaAndSizes))
|
||||
return NULL;
|
||||
|
||||
Va = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].VirtualAddress);
|
||||
if (Va == 0)
|
||||
return NULL;
|
||||
|
||||
*Size = SWAPD(NtHeader->OptionalHeader.DataDirectory[Directory].Size);
|
||||
|
||||
if (MappedAsImage || Va < SWAPD(NtHeader->OptionalHeader.SizeOfHeaders))
|
||||
return (PVOID)((ULONG_PTR)BaseAddress + Va);
|
||||
|
||||
/* image mapped as ordinary file, we must find raw pointer */
|
||||
return RtlImageRvaToVa(NtHeader, BaseAddress, Va, NULL);
|
||||
}
|
||||
|
||||
BOOL __GetFileSizeEx(HANDLE file, PLARGE_INTEGER fsize)
|
||||
{
|
||||
if (fseek((FILE*)file, 0, 2) == -1)
|
||||
return FALSE;
|
||||
fsize->QuadPart = ftell((FILE*)file);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL __CloseHandle(HANDLE handle)
|
||||
{
|
||||
fclose(handle);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
HANDLE __CreateFileW(
|
||||
LPCWSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile)
|
||||
{
|
||||
char buf[MAX_PATH];
|
||||
HANDLE res;
|
||||
|
||||
WideCharToMultiByte(CP_ACP, 0, lpFileName, -1, buf, MAX_PATH, NULL, NULL);
|
||||
res = CreateFileA(buf, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile);
|
||||
return res;
|
||||
}
|
||||
|
||||
void* __MapViewOfFile(HANDLE file,DWORD d1,DWORD d2,DWORD d3,SIZE_T s)
|
||||
{
|
||||
FILE *f = (FILE*)file;
|
||||
LARGE_INTEGER size;
|
||||
char *result;
|
||||
|
||||
if (file == INVALID_HANDLE_VALUE)
|
||||
return NULL;
|
||||
|
||||
if (!GetFileSizeEx(file, &size))
|
||||
return NULL;
|
||||
|
||||
if (fseek(f, 0, 0) == -1)
|
||||
return NULL;
|
||||
|
||||
result = malloc(size.LowPart);
|
||||
if (fread(result, 1, size.LowPart, f) != size.LowPart)
|
||||
{
|
||||
free(result);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
BOOL __UnmapViewOfFile(const void* data)
|
||||
{
|
||||
free((void *)data);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
LPSTR __lstrcpynA(LPSTR d,LPCSTR s,int c)
|
||||
{
|
||||
LPSTR r = d;
|
||||
while(*s && c)
|
||||
{
|
||||
*d++ = *s++;
|
||||
c--;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/* From Wine implementation over their unicode library */
|
||||
INT
|
||||
__WideCharToMultiByte(UINT page, DWORD flags, LPCWSTR src, INT srclen,
|
||||
LPSTR dst, INT dstlen, LPCSTR defchar, BOOL *used )
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!src || !srclen || (!dst && dstlen))
|
||||
{
|
||||
SetLastError( ERROR_INVALID_PARAMETER );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (srclen < 0) srclen = strlenW(src) + 1;
|
||||
|
||||
if(!dstlen)
|
||||
return srclen;
|
||||
|
||||
for(i=0; i<srclen && i<dstlen; i++)
|
||||
dst[i] = src[i] & 0xFF;
|
||||
|
||||
if (used) *used = FALSE;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
INT
|
||||
__MultiByteToWideChar(UINT page, DWORD flags, LPCSTR src, INT srclen,
|
||||
LPWSTR dst, INT dstlen )
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!src || !srclen || (!dst && dstlen))
|
||||
{
|
||||
SetLastError( ERROR_INVALID_PARAMETER );
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (srclen < 0) srclen = strlen(src) + 1;
|
||||
|
||||
if(!dstlen)
|
||||
return srclen;
|
||||
|
||||
for(i=0; i<srclen && i<dstlen; i++)
|
||||
dst[i] = src[i];
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/* In our case, the provided file path is the one we are looking for */
|
||||
HANDLE __FindExecutableImageExW(PCWSTR file, PCWSTR path, PWSTR out_buffer, PFIND_EXE_FILE_CALLBACKW x, PVOID y)
|
||||
{
|
||||
HANDLE ret = CreateFileW(file, 0, 0, NULL, 0, 0, NULL);
|
||||
if(ret)
|
||||
memcpy(out_buffer, file, (strlenW(file) + 1)*sizeof(WCHAR));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* printf with temp buffer allocation */
|
||||
const char *wine_dbg_sprintf( const char *format, ... )
|
||||
{
|
||||
static const int max_size = 200;
|
||||
static char buffer[256];
|
||||
char *ret;
|
||||
int len;
|
||||
va_list valist;
|
||||
|
||||
va_start(valist, format);
|
||||
ret = buffer;
|
||||
len = vsnprintf( ret, max_size, format, valist );
|
||||
if (len == -1 || len >= max_size) ret[max_size-1] = 0;
|
||||
va_end(valist);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* default implementation of wine_dbgstr_an */
|
||||
const char *wine_dbgstr_an( const char *str, int n )
|
||||
{
|
||||
static const char hex[16] = "0123456789abcdef";
|
||||
char *dst, *res;
|
||||
size_t size;
|
||||
char buffer[256];
|
||||
|
||||
if (!((ULONG_PTR)str >> 16))
|
||||
{
|
||||
if (!str) return "(null)";
|
||||
res = buffer;
|
||||
sprintf( res, "#%04x", LOWORD(str) );
|
||||
return res;
|
||||
}
|
||||
if (n == -1) n = strlen(str);
|
||||
if (n < 0) n = 0;
|
||||
size = 10 + min( 300, n * 4 );
|
||||
dst = res = buffer;
|
||||
*dst++ = '"';
|
||||
while (n-- > 0 && dst <= res + size - 9)
|
||||
{
|
||||
unsigned char c = *str++;
|
||||
switch (c)
|
||||
{
|
||||
case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
|
||||
case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
|
||||
case '\t': *dst++ = '\\'; *dst++ = 't'; break;
|
||||
case '"': *dst++ = '\\'; *dst++ = '"'; break;
|
||||
case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
|
||||
default:
|
||||
if (c >= ' ' && c <= 126)
|
||||
*dst++ = c;
|
||||
else
|
||||
{
|
||||
*dst++ = '\\';
|
||||
*dst++ = 'x';
|
||||
*dst++ = hex[(c >> 4) & 0x0f];
|
||||
*dst++ = hex[c & 0x0f];
|
||||
}
|
||||
}
|
||||
}
|
||||
*dst++ = '"';
|
||||
if (n > 0)
|
||||
{
|
||||
*dst++ = '.';
|
||||
*dst++ = '.';
|
||||
*dst++ = '.';
|
||||
}
|
||||
*dst++ = 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
/* default implementation of wine_dbgstr_wn */
|
||||
const char *wine_dbgstr_wn( const WCHAR *str, int n )
|
||||
{
|
||||
char *dst, *res;
|
||||
size_t size;
|
||||
static char buffer[256];
|
||||
|
||||
if (!((ULONG_PTR)str >> 16))
|
||||
{
|
||||
if (!str) return "(null)";
|
||||
res = buffer;
|
||||
sprintf( res, "#%04x", LOWORD(str) );
|
||||
return res;
|
||||
}
|
||||
if (n == -1)
|
||||
{
|
||||
const WCHAR *end = str;
|
||||
while (*end) end++;
|
||||
n = end - str;
|
||||
}
|
||||
if (n < 0) n = 0;
|
||||
size = 12 + min( 300, n * 5 );
|
||||
dst = res = buffer;
|
||||
*dst++ = 'L';
|
||||
*dst++ = '"';
|
||||
while (n-- > 0 && dst <= res + size - 10)
|
||||
{
|
||||
WCHAR c = *str++;
|
||||
switch (c)
|
||||
{
|
||||
case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
|
||||
case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
|
||||
case '\t': *dst++ = '\\'; *dst++ = 't'; break;
|
||||
case '"': *dst++ = '\\'; *dst++ = '"'; break;
|
||||
case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
|
||||
default:
|
||||
if (c >= ' ' && c <= 126)
|
||||
*dst++ = c;
|
||||
else
|
||||
{
|
||||
*dst++ = '\\';
|
||||
sprintf(dst,"%04x",c);
|
||||
dst+=4;
|
||||
}
|
||||
}
|
||||
}
|
||||
*dst++ = '"';
|
||||
if (n > 0)
|
||||
{
|
||||
*dst++ = '.';
|
||||
*dst++ = '.';
|
||||
*dst++ = '.';
|
||||
}
|
||||
*dst++ = 0;
|
||||
return res;
|
||||
}
|
2028
reactos/dll/win32/dbghelp/compat.h
Normal file
2028
reactos/dll/win32/dbghelp/compat.h
Normal file
File diff suppressed because it is too large
Load diff
|
@ -20,12 +20,17 @@
|
|||
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
#include "ntstatus.h"
|
||||
#define WIN32_NO_STATUS
|
||||
#endif
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
#include "wine/winbase16.h"
|
||||
#include "winternl.h"
|
||||
#include "wine/debug.h"
|
||||
#endif
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
|
||||
|
@ -34,7 +39,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
|||
|
||||
#define IS_VM86_MODE(ctx) (ctx->EFlags & V86_FLAG)
|
||||
|
||||
#ifdef __i386__
|
||||
|
||||
#if defined(__i386__) && !defined(DBGHELP_STATIC_LIB)
|
||||
static ADDRESS_MODE get_selector_type(HANDLE hThread, const CONTEXT* ctx, WORD sel)
|
||||
{
|
||||
LDT_ENTRY le;
|
||||
|
@ -73,6 +79,7 @@ static unsigned i386_build_addr(HANDLE hThread, const CONTEXT* ctx, ADDRESS64* a
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
static unsigned i386_get_addr(HANDLE hThread, const CONTEXT* ctx,
|
||||
enum cpu_addr ca, ADDRESS64* addr)
|
||||
{
|
||||
|
@ -86,8 +93,9 @@ static unsigned i386_get_addr(HANDLE hThread, const CONTEXT* ctx,
|
|||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
#endif /* DBGHELP_STATIC_LIB */
|
||||
|
||||
#ifdef __i386__
|
||||
#if defined(__i386__) && !defined(DBGHELP_STATIC_LIB)
|
||||
/* fetch_next_frame32()
|
||||
*
|
||||
* modify (at least) context.{eip, esp, ebp} using unwind information
|
||||
|
@ -110,7 +118,9 @@ static BOOL fetch_next_frame32(struct cpu_stack_walk* csw,
|
|||
cpair[2].name = "$eip"; cpair[2].pvalue = &context->Eip;
|
||||
cpair[3].name = NULL; cpair[3].pvalue = NULL;
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
if (!pdb_virtual_unwind(csw, curr_pc, context, cpair))
|
||||
#endif
|
||||
{
|
||||
/* do a simple unwind using ebp
|
||||
* we assume a "regular" prologue in the function has been used
|
||||
|
@ -148,6 +158,7 @@ enum st_mode {stm_start, stm_32bit, stm_16bit, stm_done};
|
|||
#define set_curr_mode(m) {frame->Reserved[__CurrentModeCount] &= ~0x0F; frame->Reserved[__CurrentModeCount] |= (m & 0x0F);}
|
||||
#define inc_curr_count() (frame->Reserved[__CurrentModeCount] += 0x10)
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
static BOOL i386_stack_walk(struct cpu_stack_walk* csw, LPSTACKFRAME64 frame, CONTEXT* context)
|
||||
{
|
||||
STACK32FRAME frame32;
|
||||
|
@ -513,6 +524,7 @@ done_err:
|
|||
set_curr_mode(stm_done);
|
||||
return FALSE;
|
||||
}
|
||||
#endif /* DBGHELP_STATIC_LIB */
|
||||
|
||||
static unsigned i386_map_dwarf_register(unsigned regno)
|
||||
{
|
||||
|
@ -662,6 +674,7 @@ static const char* i386_fetch_regname(unsigned regno)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
static BOOL i386_fetch_minidump_thread(struct dump_context* dc, unsigned index, unsigned flags, const CONTEXT* ctx)
|
||||
{
|
||||
if (ctx->ContextFlags && (flags & ThreadWriteInstructionWindow))
|
||||
|
@ -675,6 +688,7 @@ static BOOL i386_fetch_minidump_thread(struct dump_context* dc, unsigned index,
|
|||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
static BOOL i386_fetch_minidump_module(struct dump_context* dc, unsigned index, unsigned flags)
|
||||
{
|
||||
|
@ -688,12 +702,22 @@ DECLSPEC_HIDDEN struct cpu cpu_i386 = {
|
|||
IMAGE_FILE_MACHINE_I386,
|
||||
4,
|
||||
CV_REG_EBP,
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
i386_get_addr,
|
||||
i386_stack_walk,
|
||||
#else
|
||||
NULL,
|
||||
NULL,
|
||||
#endif
|
||||
NULL,
|
||||
i386_map_dwarf_register,
|
||||
i386_fetch_context_reg,
|
||||
i386_fetch_regname,
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
i386_fetch_minidump_thread,
|
||||
i386_fetch_minidump_module,
|
||||
#else
|
||||
NULL,
|
||||
NULL,
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -21,11 +21,14 @@
|
|||
#include "config.h"
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
#include "wdbgexts.h"
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
#include "winerror.h"
|
||||
#include "psapi.h"
|
||||
#include "wine/debug.h"
|
||||
#include "wdbgexts.h"
|
||||
#include "winnls.h"
|
||||
#endif
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
|
||||
|
@ -133,6 +136,7 @@ void* fetch_buffer(struct process* pcs, unsigned size)
|
|||
return pcs->buffer;
|
||||
}
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
const char* wine_dbgstr_addr(const ADDRESS64* addr)
|
||||
{
|
||||
if (!addr) return "(null)";
|
||||
|
@ -150,12 +154,18 @@ const char* wine_dbgstr_addr(const ADDRESS64* addr)
|
|||
return "unknown";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
extern struct cpu cpu_i386, cpu_x86_64, cpu_ppc, cpu_arm, cpu_arm64;
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
static struct cpu* dbghelp_cpus[] = {&cpu_i386, &cpu_x86_64, &cpu_ppc, &cpu_arm, &cpu_arm64, NULL};
|
||||
#else
|
||||
static struct cpu* dbghelp_cpus[] = {&cpu_i386, NULL};
|
||||
#endif
|
||||
|
||||
struct cpu* dbghelp_current_cpu =
|
||||
#if defined(__i386__)
|
||||
#if defined(__i386__) || defined(DBGHELP_STATIC_LIB)
|
||||
&cpu_i386
|
||||
#elif defined(__x86_64__)
|
||||
&cpu_x86_64
|
||||
|
@ -280,8 +290,10 @@ static BOOL check_live_target(struct process* pcs)
|
|||
{
|
||||
if (!GetProcessId(pcs->handle)) return FALSE;
|
||||
if (GetEnvironmentVariableA("DBGHELP_NOLIVE", NULL, 0)) return FALSE;
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
if (!elf_read_wine_loader_dbg_info(pcs))
|
||||
macho_read_wine_loader_dbg_info(pcs);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -370,7 +382,8 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeP
|
|||
pcs->dbg_hdr_addr = 0;
|
||||
pcs->next = process_first;
|
||||
process_first = pcs;
|
||||
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
if (check_live_target(pcs))
|
||||
{
|
||||
if (fInvadeProcess)
|
||||
|
@ -384,6 +397,7 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeP
|
|||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -26,18 +26,25 @@
|
|||
#define COM_NO_WINDOWS_H
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#include <winver.h>
|
||||
#include <dbghelp.h>
|
||||
#include <objbase.h>
|
||||
#include <cvconst.h>
|
||||
#include <wine/unicode.h>
|
||||
#else
|
||||
#include <string.h>
|
||||
#include "compat.h"
|
||||
#endif
|
||||
|
||||
//#include "oaidl.h"
|
||||
//#include "winnls.h"
|
||||
#include <wine/list.h>
|
||||
#include <wine/unicode.h>
|
||||
#include <wine/rbtree.h>
|
||||
|
||||
#include <cvconst.h>
|
||||
|
||||
/* #define USE_STATS */
|
||||
|
||||
|
@ -675,7 +682,9 @@ extern BOOL dwarf2_virtual_unwind(struct cpu_stack_walk* csw, DWORD_PTR
|
|||
CONTEXT* context, ULONG_PTR* cfa) DECLSPEC_HIDDEN;
|
||||
|
||||
/* stack.c */
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
extern BOOL sw_read_mem(struct cpu_stack_walk* csw, DWORD64 addr, void* ptr, DWORD sz) DECLSPEC_HIDDEN;
|
||||
#endif
|
||||
extern DWORD64 sw_xlat_addr(struct cpu_stack_walk* csw, ADDRESS64* addr) DECLSPEC_HIDDEN;
|
||||
extern void* sw_table_access(struct cpu_stack_walk* csw, DWORD64 addr) DECLSPEC_HIDDEN;
|
||||
extern DWORD64 sw_module_base(struct cpu_stack_walk* csw, DWORD64 addr) DECLSPEC_HIDDEN;
|
||||
|
|
|
@ -1,34 +1,123 @@
|
|||
Index: stabs.c
|
||||
===================================================================
|
||||
--- stabs.c (revision 35085)
|
||||
+++ stabs.c (working copy)
|
||||
@@ -64,6 +64,8 @@
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_stabs);
|
||||
|
||||
+#define strtoull _strtoui64
|
||||
diff -prudN e:\Wine\dlls\dbghelp/cpu_i386.c e:\reactos-dwarf\dll\win32\dbghelp/cpu_i386.c
|
||||
--- e:\Wine\dlls\dbghelp/cpu_i386.c 2012-12-09 09:57:02.223180200 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/cpu_i386.c 2013-07-14 16:01:45.804981700 +0100
|
||||
@@ -20,12 +20,17 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
#include "ntstatus.h"
|
||||
-#define WIN32_NO_STATUS
|
||||
+#endif
|
||||
+
|
||||
/* Masks for n_type field */
|
||||
#ifndef N_STAB
|
||||
#define N_STAB 0xe0
|
||||
Index: cpu_sparc.c
|
||||
===================================================================
|
||||
--- cpu_sparc.c (revision 35085)
|
||||
+++ cpu_sparc.c (working copy)
|
||||
@@ -29,6 +29,8 @@
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
+
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
#include "wine/winbase16.h"
|
||||
#include "winternl.h"
|
||||
#include "wine/debug.h"
|
||||
+#endif
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
|
||||
+#define IMAGE_FILE_MACHINE_SPARC 0x2000
|
||||
|
||||
@@ -34,7 +39,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
|
||||
#define IS_VM86_MODE(ctx) (ctx->EFlags & V86_FLAG)
|
||||
|
||||
-#ifdef __i386__
|
||||
+
|
||||
static unsigned sparc_get_addr(HANDLE hThread, const CONTEXT* ctx,
|
||||
enum cpu_addr ca, ADDRESS64* addr)
|
||||
+#if defined(__i386__) && !defined(DBGHELP_STATIC_LIB)
|
||||
static ADDRESS_MODE get_selector_type(HANDLE hThread, const CONTEXT* ctx, WORD sel)
|
||||
{
|
||||
Index: cpu_x86_64.c
|
||||
===================================================================
|
||||
--- cpu_x86_64.c (Revision 56237)
|
||||
+++ cpu_x86_64.c (Arbeitskopie)
|
||||
@@ -281,10 +281,10 @@
|
||||
LDT_ENTRY le;
|
||||
@@ -73,6 +79,7 @@ static unsigned i386_build_addr(HANDLE h
|
||||
}
|
||||
#endif
|
||||
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
static unsigned i386_get_addr(HANDLE hThread, const CONTEXT* ctx,
|
||||
enum cpu_addr ca, ADDRESS64* addr)
|
||||
{
|
||||
@@ -86,8 +93,9 @@ static unsigned i386_get_addr(HANDLE hTh
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
+#endif /* DBGHELP_STATIC_LIB */
|
||||
|
||||
-#ifdef __i386__
|
||||
+#if defined(__i386__) && !defined(DBGHELP_STATIC_LIB)
|
||||
/* fetch_next_frame32()
|
||||
*
|
||||
* modify (at least) context.{eip, esp, ebp} using unwind information
|
||||
@@ -110,7 +118,9 @@ static BOOL fetch_next_frame32(struct cp
|
||||
cpair[2].name = "$eip"; cpair[2].pvalue = &context->Eip;
|
||||
cpair[3].name = NULL; cpair[3].pvalue = NULL;
|
||||
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
if (!pdb_virtual_unwind(csw, curr_pc, context, cpair))
|
||||
+#endif
|
||||
{
|
||||
/* do a simple unwind using ebp
|
||||
* we assume a "regular" prologue in the function has been used
|
||||
@@ -148,6 +158,7 @@ enum st_mode {stm_start, stm_32bit, stm_
|
||||
#define set_curr_mode(m) {frame->Reserved[__CurrentModeCount] &= ~0x0F; frame->Reserved[__CurrentModeCount] |= (m & 0x0F);}
|
||||
#define inc_curr_count() (frame->Reserved[__CurrentModeCount] += 0x10)
|
||||
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
static BOOL i386_stack_walk(struct cpu_stack_walk* csw, LPSTACKFRAME64 frame, CONTEXT* context)
|
||||
{
|
||||
STACK32FRAME frame32;
|
||||
@@ -513,6 +524,7 @@ done_err:
|
||||
set_curr_mode(stm_done);
|
||||
return FALSE;
|
||||
}
|
||||
+#endif /* DBGHELP_STATIC_LIB */
|
||||
|
||||
static unsigned i386_map_dwarf_register(unsigned regno)
|
||||
{
|
||||
@@ -662,6 +674,7 @@ static const char* i386_fetch_regname(un
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
static BOOL i386_fetch_minidump_thread(struct dump_context* dc, unsigned index, unsigned flags, const CONTEXT* ctx)
|
||||
{
|
||||
if (ctx->ContextFlags && (flags & ThreadWriteInstructionWindow))
|
||||
@@ -675,6 +688,7 @@ static BOOL i386_fetch_minidump_thread(s
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
+#endif
|
||||
|
||||
static BOOL i386_fetch_minidump_module(struct dump_context* dc, unsigned index, unsigned flags)
|
||||
{
|
||||
@@ -688,12 +702,22 @@ DECLSPEC_HIDDEN struct cpu cpu_i386 = {
|
||||
IMAGE_FILE_MACHINE_I386,
|
||||
4,
|
||||
CV_REG_EBP,
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
i386_get_addr,
|
||||
i386_stack_walk,
|
||||
+#else
|
||||
+ NULL,
|
||||
+ NULL,
|
||||
+#endif
|
||||
NULL,
|
||||
i386_map_dwarf_register,
|
||||
i386_fetch_context_reg,
|
||||
i386_fetch_regname,
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
i386_fetch_minidump_thread,
|
||||
i386_fetch_minidump_module,
|
||||
+#else
|
||||
+ NULL,
|
||||
+ NULL,
|
||||
+#endif
|
||||
};
|
||||
diff -prudN e:\Wine\dlls\dbghelp/cpu_x86_64.c e:\reactos-dwarf\dll\win32\dbghelp/cpu_x86_64.c
|
||||
--- e:\Wine\dlls\dbghelp/cpu_x86_64.c 2012-04-02 20:39:57.749333300 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/cpu_x86_64.c 2013-07-14 16:01:02.487336800 +0100
|
||||
@@ -302,10 +302,10 @@ static BOOL is_inside_epilog(struct cpu_
|
||||
if ((op0 & 0xf8) == 0x48)
|
||||
{
|
||||
if (!sw_read_mem(csw, pc + 1, &op1, 1)) return FALSE;
|
||||
|
@ -40,3 +129,622 @@ Index: cpu_x86_64.c
|
|||
if (op0 == 0x48 && op2 == 0xc4)
|
||||
{
|
||||
pc += 7;
|
||||
@@ -313,7 +313,6 @@ static BOOL is_inside_epilog(struct cpu_
|
||||
}
|
||||
return FALSE;
|
||||
case 0x83: /* add $n,%rsp */
|
||||
- if (!sw_read_mem(csw, pc + 2, &op2, 1)) return FALSE;
|
||||
if (op0 == 0x48 && op2 == 0xc4)
|
||||
{
|
||||
pc += 4;
|
||||
@@ -321,7 +320,6 @@ static BOOL is_inside_epilog(struct cpu_
|
||||
}
|
||||
return FALSE;
|
||||
case 0x8d: /* lea n(reg),%rsp */
|
||||
- if (!sw_read_mem(csw, pc + 2, &op2, 1)) return FALSE;
|
||||
if (op0 & 0x06) return FALSE; /* rex.RX must be cleared */
|
||||
if (((op2 >> 3) & 7) != 4) return FALSE; /* dest reg mus be %rsp */
|
||||
if ((op2 & 7) == 4) return FALSE; /* no SIB byte allowed */
|
||||
diff -prudN e:\Wine\dlls\dbghelp/dbghelp.c e:\reactos-dwarf\dll\win32\dbghelp/dbghelp.c
|
||||
--- e:\Wine\dlls\dbghelp/dbghelp.c 2013-03-16 11:54:52.395468000 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/dbghelp.c 2013-07-17 21:37:35.292366600 +0100
|
||||
@@ -21,11 +21,14 @@
|
||||
#include "config.h"
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
+#include "wdbgexts.h"
|
||||
+
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
#include "winerror.h"
|
||||
#include "psapi.h"
|
||||
#include "wine/debug.h"
|
||||
-#include "wdbgexts.h"
|
||||
#include "winnls.h"
|
||||
+#endif
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
|
||||
@@ -133,6 +136,7 @@ void* fetch_buffer(struct process* pcs,
|
||||
return pcs->buffer;
|
||||
}
|
||||
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
const char* wine_dbgstr_addr(const ADDRESS64* addr)
|
||||
{
|
||||
if (!addr) return "(null)";
|
||||
@@ -150,12 +154,18 @@ const char* wine_dbgstr_addr(const ADDRE
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
+#endif
|
||||
|
||||
extern struct cpu cpu_i386, cpu_x86_64, cpu_ppc, cpu_arm, cpu_arm64;
|
||||
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
static struct cpu* dbghelp_cpus[] = {&cpu_i386, &cpu_x86_64, &cpu_ppc, &cpu_arm, &cpu_arm64, NULL};
|
||||
+#else
|
||||
+static struct cpu* dbghelp_cpus[] = {&cpu_i386, NULL};
|
||||
+#endif
|
||||
+
|
||||
struct cpu* dbghelp_current_cpu =
|
||||
-#if defined(__i386__)
|
||||
+#if defined(__i386__) || defined(DBGHELP_STATIC_LIB)
|
||||
&cpu_i386
|
||||
#elif defined(__x86_64__)
|
||||
&cpu_x86_64
|
||||
@@ -280,8 +290,10 @@ static BOOL check_live_target(struct pro
|
||||
{
|
||||
if (!GetProcessId(pcs->handle)) return FALSE;
|
||||
if (GetEnvironmentVariableA("DBGHELP_NOLIVE", NULL, 0)) return FALSE;
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
if (!elf_read_wine_loader_dbg_info(pcs))
|
||||
macho_read_wine_loader_dbg_info(pcs);
|
||||
+#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -370,7 +382,8 @@ BOOL WINAPI SymInitializeW(HANDLE hProce
|
||||
pcs->dbg_hdr_addr = 0;
|
||||
pcs->next = process_first;
|
||||
process_first = pcs;
|
||||
-
|
||||
+
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
if (check_live_target(pcs))
|
||||
{
|
||||
if (fInvadeProcess)
|
||||
@@ -384,6 +397,7 @@ BOOL WINAPI SymInitializeW(HANDLE hProce
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
+#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
diff -prudN e:\Wine\dlls\dbghelp/dbghelp_private.h e:\reactos-dwarf\dll\win32\dbghelp/dbghelp_private.h
|
||||
--- e:\Wine\dlls\dbghelp/dbghelp_private.h 2012-04-02 20:39:57.749333300 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/dbghelp_private.h 2013-07-14 16:01:46.453826200 +0100
|
||||
@@ -21,19 +21,30 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
+#define WIN32_NO_STATUS
|
||||
+#define _INC_WINDOWS
|
||||
+#define COM_NO_WINDOWS_H
|
||||
+
|
||||
#include <stdarg.h>
|
||||
-#include "windef.h"
|
||||
-#include "winbase.h"
|
||||
-#include "winver.h"
|
||||
-#include "dbghelp.h"
|
||||
-#include "objbase.h"
|
||||
-#include "oaidl.h"
|
||||
-#include "winnls.h"
|
||||
-#include "wine/list.h"
|
||||
-#include "wine/unicode.h"
|
||||
-#include "wine/rbtree.h"
|
||||
|
||||
-#include "cvconst.h"
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
+#include <windef.h>
|
||||
+#include <winbase.h>
|
||||
+#include <winver.h>
|
||||
+#include <dbghelp.h>
|
||||
+#include <objbase.h>
|
||||
+#include <cvconst.h>
|
||||
+#include <wine/unicode.h>
|
||||
+#else
|
||||
+#include <string.h>
|
||||
+#include "compat.h"
|
||||
+#endif
|
||||
+
|
||||
+//#include "oaidl.h"
|
||||
+//#include "winnls.h"
|
||||
+#include <wine/list.h>
|
||||
+#include <wine/rbtree.h>
|
||||
+
|
||||
|
||||
/* #define USE_STATS */
|
||||
|
||||
@@ -671,7 +682,9 @@ extern BOOL dwarf2_virtual_unwin
|
||||
CONTEXT* context, ULONG_PTR* cfa) DECLSPEC_HIDDEN;
|
||||
|
||||
/* stack.c */
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
extern BOOL sw_read_mem(struct cpu_stack_walk* csw, DWORD64 addr, void* ptr, DWORD sz) DECLSPEC_HIDDEN;
|
||||
+#endif
|
||||
extern DWORD64 sw_xlat_addr(struct cpu_stack_walk* csw, ADDRESS64* addr) DECLSPEC_HIDDEN;
|
||||
extern void* sw_table_access(struct cpu_stack_walk* csw, DWORD64 addr) DECLSPEC_HIDDEN;
|
||||
extern DWORD64 sw_module_base(struct cpu_stack_walk* csw, DWORD64 addr) DECLSPEC_HIDDEN;
|
||||
|
||||
diff -prudN e:\Wine\dlls\dbghelp/dwarf.c e:\reactos-dwarf\dll\win32\dbghelp/dwarf.c
|
||||
--- e:\Wine\dlls\dbghelp/dwarf.c 2013-03-02 14:17:59.439371000 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/dwarf.c 2013-07-14 16:01:46.490851000 +0100
|
||||
@@ -22,23 +22,23 @@
|
||||
|
||||
#define NONAMELESSUNION
|
||||
|
||||
-#include "config.h"
|
||||
+#include <config.h>
|
||||
|
||||
-#include <sys/types.h>
|
||||
-#include <fcntl.h>
|
||||
+//#include <sys/types.h>
|
||||
+//#include <fcntl.h>
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_MMAN_H
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
-#include <limits.h>
|
||||
-#include <stdlib.h>
|
||||
-#include <string.h>
|
||||
+//#include <limits.h>
|
||||
+//#include <stdlib.h>
|
||||
+//#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
-#include <stdio.h>
|
||||
+//#include <stdio.h>
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -46,18 +46,20 @@
|
||||
#include <zlib.h>
|
||||
#endif
|
||||
|
||||
-#include "windef.h"
|
||||
-#include "winternl.h"
|
||||
-#include "winbase.h"
|
||||
-#include "winuser.h"
|
||||
-#include "ole2.h"
|
||||
-#include "oleauto.h"
|
||||
+//#include "windef.h"
|
||||
+//#include "winbase.h"
|
||||
+//#include "winuser.h"
|
||||
+//#include "ole2.h"
|
||||
+//#include "oleauto.h"
|
||||
+
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
+#include <winternl.h>
|
||||
+#include <wine/debug.h>
|
||||
+#endif
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
#include "image_private.h"
|
||||
|
||||
-#include "wine/debug.h"
|
||||
-
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_dwarf);
|
||||
|
||||
/* FIXME:
|
||||
@@ -1888,8 +1890,10 @@ static struct symt* dwarf2_parse_subprog
|
||||
* (not the case for stabs), we just drop Wine's thunks here...
|
||||
* Actual thunks will be created in elf_module from the symbol table
|
||||
*/
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
if (elf_is_in_thunk_area(ctx->load_offset + low_pc, ctx->thunks) >= 0)
|
||||
return NULL;
|
||||
+#endif
|
||||
if (!(ret_type = dwarf2_lookup_type(ctx, di)))
|
||||
{
|
||||
ret_type = ctx->symt_cache[sc_void];
|
||||
diff -prudN e:\Wine\dlls\dbghelp/dwarf.h e:\reactos-dwarf\dll\win32\dbghelp/dwarf.h
|
||||
--- e:\Wine\dlls\dbghelp/dwarf.h 2011-09-16 23:22:36.194780200 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/dwarf.h 2013-07-14 16:01:46.862099400 +0100
|
||||
@@ -554,3 +554,15 @@ enum dwarf_call_frame_info
|
||||
#define DW_INL_inlined 0x01
|
||||
#define DW_INL_declared_not_inlined 0x02
|
||||
#define DW_INL_declared_inlined 0x03
|
||||
+
|
||||
+#ifdef DBGHELP_STATIC_LIB
|
||||
+/* from stack.c */
|
||||
+static BOOL sw_read_mem(struct cpu_stack_walk* csw, DWORD64 addr, void* ptr, DWORD sz)
|
||||
+{
|
||||
+ DWORD bytes_read = 0;
|
||||
+ if (csw->is32)
|
||||
+ return csw->u.s32.f_read_mem(csw->hProcess, addr, ptr, sz, &bytes_read);
|
||||
+ else
|
||||
+ return csw->u.s64.f_read_mem(csw->hProcess, addr, ptr, sz, &bytes_read);
|
||||
+}
|
||||
+#endif
|
||||
|
||||
diff -prudN e:\Wine\dlls\dbghelp/image_private.h e:\reactos-dwarf\dll\win32\dbghelp/image_private.h
|
||||
--- e:\Wine\dlls\dbghelp/image_private.h 2012-04-02 20:39:57.752333500 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/image_private.h 2013-07-14 16:01:46.946185400 +0100
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
#define IMAGE_NO_MAP ((void*)-1)
|
||||
|
||||
-#ifdef __ELF__
|
||||
+#if defined(__ELF__) && !defined(DBGHELP_STATIC_LIB)
|
||||
|
||||
#ifdef _WIN64
|
||||
#define Elf_Ehdr Elf64_Ehdr
|
||||
@@ -85,7 +85,7 @@ struct image_file_map
|
||||
const char* shstrtab;
|
||||
struct image_file_map* alternate; /* another ELF file (linked to this one) */
|
||||
char* target_copy;
|
||||
-#ifdef __ELF__
|
||||
+#if defined(__ELF__) && !defined(DBGHELP_STATIC_LIB)
|
||||
Elf_Ehdr elfhdr;
|
||||
struct
|
||||
{
|
||||
@@ -135,7 +135,9 @@ static inline BOOL image_find_section(st
|
||||
{
|
||||
switch (fmap->modtype)
|
||||
{
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_ELF: return elf_find_section(fmap, name, SHT_NULL, ism);
|
||||
+#endif
|
||||
case DMT_PE: return pe_find_section(fmap, name, ism);
|
||||
default: assert(0); return FALSE;
|
||||
}
|
||||
@@ -146,7 +148,9 @@ static inline const char* image_map_sect
|
||||
if (!ism->fmap) return NULL;
|
||||
switch (ism->fmap->modtype)
|
||||
{
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_ELF: return elf_map_section(ism);
|
||||
+#endif
|
||||
case DMT_PE: return pe_map_section(ism);
|
||||
default: assert(0); return NULL;
|
||||
}
|
||||
@@ -157,7 +161,9 @@ static inline void image_unmap_section(s
|
||||
if (!ism->fmap) return;
|
||||
switch (ism->fmap->modtype)
|
||||
{
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_ELF: elf_unmap_section(ism); break;
|
||||
+#endif
|
||||
case DMT_PE: pe_unmap_section(ism); break;
|
||||
default: assert(0); return;
|
||||
}
|
||||
@@ -168,7 +174,9 @@ static inline DWORD_PTR image_get_map_rv
|
||||
if (!ism->fmap) return 0;
|
||||
switch (ism->fmap->modtype)
|
||||
{
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_ELF: return elf_get_map_rva(ism);
|
||||
+#endif
|
||||
case DMT_PE: return pe_get_map_rva(ism);
|
||||
default: assert(0); return 0;
|
||||
}
|
||||
@@ -179,7 +187,9 @@ static inline unsigned image_get_map_siz
|
||||
if (!ism->fmap) return 0;
|
||||
switch (ism->fmap->modtype)
|
||||
{
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_ELF: return elf_get_map_size(ism);
|
||||
+#endif
|
||||
case DMT_PE: return pe_get_map_size(ism);
|
||||
default: assert(0); return 0;
|
||||
}
|
||||
|
||||
diff -prudN e:\Wine\dlls\dbghelp/module.c e:\reactos-dwarf\dll\win32\dbghelp/module.c
|
||||
--- e:\Wine\dlls\dbghelp/module.c 2012-09-09 19:47:53.367024200 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/module.c 2013-07-14 16:01:46.973202500 +0100
|
||||
@@ -19,16 +19,19 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
-#include "config.h"
|
||||
-#include <stdlib.h>
|
||||
-#include <stdio.h>
|
||||
-#include <string.h>
|
||||
+#include <config.h>
|
||||
+//#include <stdlib.h>
|
||||
+//#include <stdio.h>
|
||||
+//#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
-#include "psapi.h"
|
||||
-#include "winternl.h"
|
||||
-#include "wine/debug.h"
|
||||
+
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
+#include <psapi.h>
|
||||
+#include <wine/debug.h>
|
||||
+#endif
|
||||
+//#include "winternl.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
|
||||
@@ -346,9 +349,11 @@ BOOL module_get_debug(struct module_pair
|
||||
if (pair->effective->is_virtual) ret = FALSE;
|
||||
else switch (pair->effective->type)
|
||||
{
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_ELF:
|
||||
ret = elf_load_debug_info(pair->effective);
|
||||
break;
|
||||
+#endif
|
||||
case DMT_PE:
|
||||
idslW64.SizeOfStruct = sizeof(idslW64);
|
||||
idslW64.BaseOfImage = pair->effective->module.BaseOfImage;
|
||||
@@ -365,9 +370,11 @@ BOOL module_get_debug(struct module_pair
|
||||
ret ? CBA_DEFERRED_SYMBOL_LOAD_COMPLETE : CBA_DEFERRED_SYMBOL_LOAD_FAILURE,
|
||||
&idslW64);
|
||||
break;
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_MACHO:
|
||||
ret = macho_load_debug_info(pair->effective, NULL);
|
||||
break;
|
||||
+#endif
|
||||
default:
|
||||
ret = FALSE;
|
||||
break;
|
||||
@@ -506,11 +513,13 @@ enum module_type module_get_type_by_name
|
||||
/******************************************************************
|
||||
* refresh_module_list
|
||||
*/
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
static BOOL refresh_module_list(struct process* pcs)
|
||||
{
|
||||
/* force transparent ELF and Mach-O loading / unloading */
|
||||
return elf_synchronize_module_list(pcs) || macho_synchronize_module_list(pcs);
|
||||
}
|
||||
+#endif
|
||||
|
||||
/***********************************************************************
|
||||
* SymLoadModule (DBGHELP.@)
|
||||
@@ -594,7 +603,9 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE
|
||||
if (Flags & ~(SLMFLAG_VIRTUAL))
|
||||
FIXME("Unsupported Flags %08x for %s\n", Flags, debugstr_w(wImageName));
|
||||
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
refresh_module_list(pcs);
|
||||
+#endif
|
||||
|
||||
/* this is a Wine extension to the API just to redo the synchronisation */
|
||||
if (!wImageName && !hFile) return 0;
|
||||
@@ -618,6 +629,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE
|
||||
wImageName)
|
||||
{
|
||||
/* and finally an ELF or Mach-O module */
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
switch (module_get_type_by_name(wImageName))
|
||||
{
|
||||
case DMT_ELF:
|
||||
@@ -630,6 +642,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE
|
||||
/* Ignored */
|
||||
break;
|
||||
}
|
||||
+#endif
|
||||
}
|
||||
}
|
||||
if (!module)
|
||||
@@ -819,6 +832,7 @@ BOOL WINAPI SymEnumerateModulesW64(HAND
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
/******************************************************************
|
||||
* EnumerateLoadedModules64 (DBGHELP.@)
|
||||
*
|
||||
@@ -919,6 +933,7 @@ BOOL WINAPI EnumerateLoadedModulesW64(H
|
||||
|
||||
return sz != 0 && i == sz;
|
||||
}
|
||||
+#endif /* DBGHELP_STATIC_LIB */
|
||||
|
||||
/******************************************************************
|
||||
* SymGetModuleInfo (DBGHELP.@)
|
||||
@@ -1131,7 +1146,11 @@ BOOL WINAPI SymRefreshModuleList(HANDLE
|
||||
|
||||
if (!(pcs = process_find_by_handle(hProcess))) return FALSE;
|
||||
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
return refresh_module_list(pcs);
|
||||
+#else
|
||||
+ return TRUE;
|
||||
+#endif
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
||||
diff -prudN e:\Wine\dlls\dbghelp/pe_module.c e:\reactos-dwarf\dll\win32\dbghelp/pe_module.c
|
||||
--- e:\Wine\dlls\dbghelp/pe_module.c 2012-04-02 20:39:57.755333700 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/pe_module.c 2013-07-14 17:06:18.750513200 +0100
|
||||
@@ -31,8 +31,10 @@
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
#include "image_private.h"
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
#include "winternl.h"
|
||||
#include "wine/debug.h"
|
||||
+#endif
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
|
||||
@@ -526,6 +528,7 @@ static BOOL pe_load_dwarf(struct module*
|
||||
return ret;
|
||||
}
|
||||
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
/******************************************************************
|
||||
* pe_load_dbg_file
|
||||
*
|
||||
@@ -625,6 +628,7 @@ done:
|
||||
pe_unmap_full(fmap);
|
||||
return ret;
|
||||
}
|
||||
+#endif /* DBGHELP_STATIC_LIB */
|
||||
|
||||
/***********************************************************************
|
||||
* pe_load_export_debug_info
|
||||
@@ -721,7 +725,9 @@ BOOL pe_load_debug_info(const struct pro
|
||||
{
|
||||
ret = pe_load_stabs(pcs, module);
|
||||
ret = pe_load_dwarf(module) || ret;
|
||||
+ #ifndef DBGHELP_STATIC_LIB
|
||||
ret = pe_load_msc_debug_info(pcs, module) || ret;
|
||||
+ #endif
|
||||
ret = ret || pe_load_coff_symbol_table(module); /* FIXME */
|
||||
/* if we still have no debug info (we could only get SymExport at this
|
||||
* point), then do the SymExport except if we have an ELF container,
|
||||
|
||||
diff -prudN e:\Wine\dlls\dbghelp/source.c e:\reactos-dwarf\dll\win32\dbghelp/source.c
|
||||
--- e:\Wine\dlls\dbghelp/source.c 2011-09-16 23:22:36.198780400 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/source.c 2013-07-14 16:01:47.027608100 +0100
|
||||
@@ -18,14 +18,17 @@
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
-#include "config.h"
|
||||
-#include <stdlib.h>
|
||||
-#include <stdio.h>
|
||||
-#include <string.h>
|
||||
+#include <config.h>
|
||||
+//#include <stdlib.h>
|
||||
+//#include <stdio.h>
|
||||
+//#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
-#include "wine/debug.h"
|
||||
+
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
+#include <wine/debug.h>
|
||||
+#endif
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
|
||||
diff -prudN e:\Wine\dlls\dbghelp/stabs.c e:\reactos-dwarf\dll\win32\dbghelp/stabs.c
|
||||
--- e:\Wine\dlls\dbghelp/stabs.c 2012-08-13 02:55:03.317206300 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/stabs.c 2013-07-14 17:06:14.969603400 +0100
|
||||
@@ -29,41 +29,47 @@
|
||||
* available (hopefully) from http://sources.redhat.com/gdb/onlinedocs
|
||||
*/
|
||||
|
||||
-#include "config.h"
|
||||
-#include "wine/port.h"
|
||||
+#include <config.h>
|
||||
+//#include "wine/port.h"
|
||||
|
||||
-#include <sys/types.h>
|
||||
-#include <fcntl.h>
|
||||
+//#include <sys/types.h>
|
||||
+//#include <fcntl.h>
|
||||
#ifdef HAVE_SYS_STAT_H
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_MMAN_H
|
||||
#include <sys/mman.h>
|
||||
#endif
|
||||
-#include <limits.h>
|
||||
-#include <stdlib.h>
|
||||
-#include <string.h>
|
||||
+//#include <limits.h>
|
||||
+//#include <stdlib.h>
|
||||
+//#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
-#include <stdio.h>
|
||||
+//#include <stdio.h>
|
||||
#include <assert.h>
|
||||
-#include <stdarg.h>
|
||||
+//#include <stdarg.h>
|
||||
|
||||
#ifdef HAVE_MACH_O_NLIST_H
|
||||
# include <mach-o/nlist.h>
|
||||
#endif
|
||||
|
||||
-#include "windef.h"
|
||||
-#include "winbase.h"
|
||||
-#include "winnls.h"
|
||||
+//#include "windef.h"
|
||||
+//#include "winbase.h"
|
||||
+//#include "winnls.h"
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
|
||||
-#include "wine/debug.h"
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
+#include <wine/debug.h>
|
||||
+#endif
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_stabs);
|
||||
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
+#define strtoull _strtoui64
|
||||
+#endif
|
||||
+
|
||||
/* Masks for n_type field */
|
||||
#ifndef N_STAB
|
||||
#define N_STAB 0xe0
|
||||
|
||||
diff -prudN e:\Wine\dlls\dbghelp/storage.c e:\reactos-dwarf\dll\win32\dbghelp/storage.c
|
||||
--- e:\Wine\dlls\dbghelp/storage.c 2011-09-16 23:22:36.199780500 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/storage.c 2013-07-14 16:01:47.077595900 +0100
|
||||
@@ -23,7 +23,10 @@
|
||||
#include "config.h"
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
+
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
#include "wine/debug.h"
|
||||
+#endif
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
#ifdef USE_STATS
|
||||
|
||||
diff -prudN e:\Wine\dlls\dbghelp/symbol.c e:\reactos-dwarf\dll\win32\dbghelp/symbol.c
|
||||
--- e:\Wine\dlls\dbghelp/symbol.c 2012-04-02 20:39:57.756333700 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/symbol.c 2013-07-17 04:29:08.161225800 +0100
|
||||
@@ -31,9 +31,12 @@
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
|
||||
-#include "wine/debug.h"
|
||||
#include "dbghelp_private.h"
|
||||
+
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
+#include "wine/debug.h"
|
||||
#include "winnls.h"
|
||||
+#endif
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
WINE_DECLARE_DEBUG_CHANNEL(dbghelp_symt);
|
||||
diff -prudN e:\Wine\dlls\dbghelp/type.c e:\reactos-dwarf\dll\win32\dbghelp/type.c
|
||||
--- e:\Wine\dlls\dbghelp/type.c 2012-04-02 20:39:57.756333700 +0100
|
||||
+++ e:\reactos-dwarf\dll\win32\dbghelp/type.c 2013-07-14 16:01:47.136913600 +0100
|
||||
@@ -29,10 +29,13 @@
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
+#ifndef DBGHELP_STATIC_LIB
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winnls.h"
|
||||
#include "wine/debug.h"
|
||||
+#endif
|
||||
+
|
||||
#include "dbghelp_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
|
|
|
@ -47,17 +47,19 @@
|
|||
#endif
|
||||
|
||||
//#include "windef.h"
|
||||
#include <winternl.h>
|
||||
//#include "winbase.h"
|
||||
//#include "winuser.h"
|
||||
//#include "ole2.h"
|
||||
//#include "oleauto.h"
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
#include <winternl.h>
|
||||
#include <wine/debug.h>
|
||||
#endif
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
#include "image_private.h"
|
||||
|
||||
#include <wine/debug.h>
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_dwarf);
|
||||
|
||||
/* FIXME:
|
||||
|
@ -1888,8 +1890,10 @@ static struct symt* dwarf2_parse_subprogram(dwarf2_parse_context_t* ctx,
|
|||
* (not the case for stabs), we just drop Wine's thunks here...
|
||||
* Actual thunks will be created in elf_module from the symbol table
|
||||
*/
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
if (elf_is_in_thunk_area(ctx->load_offset + low_pc, ctx->thunks) >= 0)
|
||||
return NULL;
|
||||
#endif
|
||||
if (!(ret_type = dwarf2_lookup_type(ctx, di)))
|
||||
{
|
||||
ret_type = ctx->symt_cache[sc_void];
|
||||
|
|
|
@ -554,3 +554,15 @@ enum dwarf_call_frame_info
|
|||
#define DW_INL_inlined 0x01
|
||||
#define DW_INL_declared_not_inlined 0x02
|
||||
#define DW_INL_declared_inlined 0x03
|
||||
|
||||
#ifdef DBGHELP_STATIC_LIB
|
||||
/* from stack.c */
|
||||
static BOOL sw_read_mem(struct cpu_stack_walk* csw, DWORD64 addr, void* ptr, DWORD sz)
|
||||
{
|
||||
DWORD bytes_read = 0;
|
||||
if (csw->is32)
|
||||
return csw->u.s32.f_read_mem(csw->hProcess, addr, ptr, sz, &bytes_read);
|
||||
else
|
||||
return csw->u.s64.f_read_mem(csw->hProcess, addr, ptr, sz, &bytes_read);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
|
||||
#define IMAGE_NO_MAP ((void*)-1)
|
||||
|
||||
#ifdef __ELF__
|
||||
#if defined(__ELF__) && !defined(DBGHELP_STATIC_LIB)
|
||||
|
||||
#ifdef _WIN64
|
||||
#define Elf_Ehdr Elf64_Ehdr
|
||||
|
@ -85,7 +85,7 @@ struct image_file_map
|
|||
const char* shstrtab;
|
||||
struct image_file_map* alternate; /* another ELF file (linked to this one) */
|
||||
char* target_copy;
|
||||
#ifdef __ELF__
|
||||
#if defined(__ELF__) && !defined(DBGHELP_STATIC_LIB)
|
||||
Elf_Ehdr elfhdr;
|
||||
struct
|
||||
{
|
||||
|
@ -135,7 +135,9 @@ static inline BOOL image_find_section(struct image_file_map* fmap, const char* n
|
|||
{
|
||||
switch (fmap->modtype)
|
||||
{
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_ELF: return elf_find_section(fmap, name, SHT_NULL, ism);
|
||||
#endif
|
||||
case DMT_PE: return pe_find_section(fmap, name, ism);
|
||||
default: assert(0); return FALSE;
|
||||
}
|
||||
|
@ -146,7 +148,9 @@ static inline const char* image_map_section(struct image_section_map* ism)
|
|||
if (!ism->fmap) return NULL;
|
||||
switch (ism->fmap->modtype)
|
||||
{
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_ELF: return elf_map_section(ism);
|
||||
#endif
|
||||
case DMT_PE: return pe_map_section(ism);
|
||||
default: assert(0); return NULL;
|
||||
}
|
||||
|
@ -157,7 +161,9 @@ static inline void image_unmap_section(struct image_section_map* ism)
|
|||
if (!ism->fmap) return;
|
||||
switch (ism->fmap->modtype)
|
||||
{
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_ELF: elf_unmap_section(ism); break;
|
||||
#endif
|
||||
case DMT_PE: pe_unmap_section(ism); break;
|
||||
default: assert(0); return;
|
||||
}
|
||||
|
@ -168,7 +174,9 @@ static inline DWORD_PTR image_get_map_rva(const struct image_section_map* ism)
|
|||
if (!ism->fmap) return 0;
|
||||
switch (ism->fmap->modtype)
|
||||
{
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_ELF: return elf_get_map_rva(ism);
|
||||
#endif
|
||||
case DMT_PE: return pe_get_map_rva(ism);
|
||||
default: assert(0); return 0;
|
||||
}
|
||||
|
@ -179,7 +187,9 @@ static inline unsigned image_get_map_size(const struct image_section_map* ism)
|
|||
if (!ism->fmap) return 0;
|
||||
switch (ism->fmap->modtype)
|
||||
{
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_ELF: return elf_get_map_size(ism);
|
||||
#endif
|
||||
case DMT_PE: return pe_get_map_size(ism);
|
||||
default: assert(0); return 0;
|
||||
}
|
||||
|
|
|
@ -26,9 +26,12 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
#include <psapi.h>
|
||||
//#include "winternl.h"
|
||||
#include <wine/debug.h>
|
||||
#endif
|
||||
//#include "winternl.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
|
||||
|
@ -346,9 +349,11 @@ BOOL module_get_debug(struct module_pair* pair)
|
|||
if (pair->effective->is_virtual) ret = FALSE;
|
||||
else switch (pair->effective->type)
|
||||
{
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_ELF:
|
||||
ret = elf_load_debug_info(pair->effective);
|
||||
break;
|
||||
#endif
|
||||
case DMT_PE:
|
||||
idslW64.SizeOfStruct = sizeof(idslW64);
|
||||
idslW64.BaseOfImage = pair->effective->module.BaseOfImage;
|
||||
|
@ -365,9 +370,11 @@ BOOL module_get_debug(struct module_pair* pair)
|
|||
ret ? CBA_DEFERRED_SYMBOL_LOAD_COMPLETE : CBA_DEFERRED_SYMBOL_LOAD_FAILURE,
|
||||
&idslW64);
|
||||
break;
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
case DMT_MACHO:
|
||||
ret = macho_load_debug_info(pair->effective, NULL);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
ret = FALSE;
|
||||
break;
|
||||
|
@ -506,11 +513,13 @@ enum module_type module_get_type_by_name(const WCHAR* name)
|
|||
/******************************************************************
|
||||
* refresh_module_list
|
||||
*/
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
static BOOL refresh_module_list(struct process* pcs)
|
||||
{
|
||||
/* force transparent ELF and Mach-O loading / unloading */
|
||||
return elf_synchronize_module_list(pcs) || macho_synchronize_module_list(pcs);
|
||||
}
|
||||
#endif
|
||||
|
||||
/***********************************************************************
|
||||
* SymLoadModule (DBGHELP.@)
|
||||
|
@ -594,7 +603,9 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
|
|||
if (Flags & ~(SLMFLAG_VIRTUAL))
|
||||
FIXME("Unsupported Flags %08x for %s\n", Flags, debugstr_w(wImageName));
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
refresh_module_list(pcs);
|
||||
#endif
|
||||
|
||||
/* this is a Wine extension to the API just to redo the synchronisation */
|
||||
if (!wImageName && !hFile) return 0;
|
||||
|
@ -618,6 +629,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
|
|||
wImageName)
|
||||
{
|
||||
/* and finally an ELF or Mach-O module */
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
switch (module_get_type_by_name(wImageName))
|
||||
{
|
||||
case DMT_ELF:
|
||||
|
@ -630,6 +642,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE hProcess, HANDLE hFile, PCWSTR wImageNam
|
|||
/* Ignored */
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (!module)
|
||||
|
@ -819,6 +832,7 @@ BOOL WINAPI SymEnumerateModulesW64(HANDLE hProcess,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
/******************************************************************
|
||||
* EnumerateLoadedModules64 (DBGHELP.@)
|
||||
*
|
||||
|
@ -919,6 +933,7 @@ BOOL WINAPI EnumerateLoadedModulesW64(HANDLE hProcess,
|
|||
|
||||
return sz != 0 && i == sz;
|
||||
}
|
||||
#endif /* DBGHELP_STATIC_LIB */
|
||||
|
||||
/******************************************************************
|
||||
* SymGetModuleInfo (DBGHELP.@)
|
||||
|
@ -1131,7 +1146,11 @@ BOOL WINAPI SymRefreshModuleList(HANDLE hProcess)
|
|||
|
||||
if (!(pcs = process_find_by_handle(hProcess))) return FALSE;
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
return refresh_module_list(pcs);
|
||||
#else
|
||||
return TRUE;
|
||||
#endif
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
|
|
|
@ -31,8 +31,10 @@
|
|||
|
||||
#include "dbghelp_private.h"
|
||||
#include "image_private.h"
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
#include "winternl.h"
|
||||
#include "wine/debug.h"
|
||||
#endif
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
|
||||
|
@ -526,6 +528,7 @@ static BOOL pe_load_dwarf(struct module* module)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
/******************************************************************
|
||||
* pe_load_dbg_file
|
||||
*
|
||||
|
@ -625,6 +628,7 @@ done:
|
|||
pe_unmap_full(fmap);
|
||||
return ret;
|
||||
}
|
||||
#endif /* DBGHELP_STATIC_LIB */
|
||||
|
||||
/***********************************************************************
|
||||
* pe_load_export_debug_info
|
||||
|
@ -721,7 +725,9 @@ BOOL pe_load_debug_info(const struct process* pcs, struct module* module)
|
|||
{
|
||||
ret = pe_load_stabs(pcs, module);
|
||||
ret = pe_load_dwarf(module) || ret;
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
ret = pe_load_msc_debug_info(pcs, module) || ret;
|
||||
#endif
|
||||
ret = ret || pe_load_coff_symbol_table(module); /* FIXME */
|
||||
/* if we still have no debug info (we could only get SymExport at this
|
||||
* point), then do the SymExport except if we have an ELF container,
|
||||
|
|
|
@ -25,7 +25,10 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
#include <wine/debug.h>
|
||||
#endif
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
|
||||
|
|
|
@ -60,11 +60,15 @@
|
|||
|
||||
#include "dbghelp_private.h"
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
#include <wine/debug.h>
|
||||
#endif
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_stabs);
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
#define strtoull _strtoui64
|
||||
#endif
|
||||
|
||||
/* Masks for n_type field */
|
||||
#ifndef N_STAB
|
||||
|
|
|
@ -23,7 +23,10 @@
|
|||
#include "config.h"
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
#include "wine/debug.h"
|
||||
#endif
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
#ifdef USE_STATS
|
||||
|
|
|
@ -31,9 +31,12 @@
|
|||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "dbghelp_private.h"
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
#include "wine/debug.h"
|
||||
#include "winnls.h"
|
||||
#endif
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
WINE_DECLARE_DEBUG_CHANNEL(dbghelp_symt);
|
||||
|
|
|
@ -29,10 +29,13 @@
|
|||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifndef DBGHELP_STATIC_LIB
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winnls.h"
|
||||
#include "wine/debug.h"
|
||||
#endif
|
||||
|
||||
#include "dbghelp_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
|
||||
|
|
|
@ -5,6 +5,12 @@
|
|||
|
||||
#define HAVE_SPAWNVP 1
|
||||
|
||||
/* Define to 1 if you have the `z' library (-lz). */
|
||||
#define HAVE_ZLIB 1
|
||||
|
||||
/* Define to 1 if you have the <zlib.h> header file. */
|
||||
#define HAVE_ZLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <float.h> header file. */
|
||||
#define HAVE_FLOAT_H 1
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* Function attributes for GCC */
|
||||
#if !defined(_MSC_VER) && !defined(__fastcall)
|
||||
|
@ -46,22 +47,33 @@
|
|||
|
||||
/* Basic types
|
||||
Emulate a LLP64 memory model using a LP64 compiler */
|
||||
typedef void VOID, *PVOID;
|
||||
typedef char CHAR, CCHAR, *PCHAR, *PSTR;
|
||||
typedef void VOID, *PVOID, *LPVOID;
|
||||
typedef char CHAR, CCHAR, *PCHAR, *PSTR, *LPSTR;
|
||||
typedef const char *PCSTR, *LPCSTR;
|
||||
typedef unsigned char UCHAR, *PUCHAR, BYTE, *LPBYTE, BOOLEAN, *PBOOLEAN;
|
||||
typedef short SHORT, *PSHORT;
|
||||
typedef unsigned short USHORT, *PUSHORT, WORD, *PWORD, *LPWORD, WCHAR, *PWCHAR, *PWSTR, *LPWSTR;
|
||||
typedef const unsigned short *PCWSTR, *LPCWSTR;
|
||||
typedef int INT, LONG, *PLONG, *LPLONG, BOOL;
|
||||
typedef unsigned int UINT, *PUINT, *LPUINT, ULONG, *PULONG, DWORD, *LPDWORD;
|
||||
typedef long LONG_PTR, *PLONG_PTR, INT_PTR, *PINT_PTR;
|
||||
typedef unsigned long ULONG_PTR, DWORD_PTR, *PULONG_PTR, UINT_PTR, *PUINT_PTR;
|
||||
typedef long long LONGLONG;
|
||||
typedef unsigned long long ULONGLONG;
|
||||
typedef int16_t SHORT, *PSHORT;
|
||||
typedef uint16_t USHORT, *PUSHORT, WORD, *PWORD, *LPWORD, WCHAR, *PWCHAR, *PWSTR, *LPWSTR, UINT16;
|
||||
typedef const uint16_t *PCWSTR, *LPCWSTR;
|
||||
typedef int32_t INT, LONG, *PLONG, *LPLONG, BOOL, WINBOOL;
|
||||
typedef uint32_t UINT, *PUINT, *LPUINT, ULONG, *PULONG, DWORD, *PDWORD, *LPDWORD, UINT32;
|
||||
#ifdef _LP64
|
||||
typedef int64_t LONG_PTR, *PLONG_PTR, INT_PTR, *PINT_PTR;
|
||||
typedef uint64_t ULONG_PTR, DWORD_PTR, *PULONG_PTR, UINT_PTR, *PUINT_PTR;
|
||||
#else
|
||||
typedef int32_t LONG_PTR, *PLONG_PTR, INT_PTR, *PINT_PTR;
|
||||
typedef uint32_t ULONG_PTR, DWORD_PTR, *PULONG_PTR, UINT_PTR, *PUINT_PTR;
|
||||
#endif
|
||||
typedef uint64_t ULONG64, DWORD64, *PDWORD64, UINT64, ULONGLONG;
|
||||
typedef int64_t LONGLONG, LONG64;
|
||||
typedef float FLOAT;
|
||||
typedef double DOUBLE;
|
||||
|
||||
/* Derived types */
|
||||
typedef PVOID HANDLE, HKEY, *PHKEY;
|
||||
typedef PVOID HANDLE;
|
||||
#ifndef _HAVE_HKEY
|
||||
typedef HANDLE HKEY, *PHKEY;
|
||||
#endif
|
||||
typedef HANDLE HMODULE, HINSTANCE;
|
||||
typedef INT NTSTATUS, POOL_TYPE;
|
||||
typedef LONG HRESULT;
|
||||
typedef ULONG_PTR SIZE_T, *PSIZE_T;
|
||||
|
@ -71,6 +83,7 @@ typedef WORD LANGID;
|
|||
|
||||
/* Widely used structures */
|
||||
#include <pshpack4.h>
|
||||
#ifndef _HAVE_RTL_BITMAP
|
||||
typedef struct _RTL_BITMAP
|
||||
{
|
||||
ULONG SizeOfBitMap;
|
||||
|
@ -82,23 +95,34 @@ typedef struct _RTL_BITMAP_RUN
|
|||
ULONG StartingIndex;
|
||||
ULONG NumberOfBits;
|
||||
} RTL_BITMAP_RUN, *PRTL_BITMAP_RUN;
|
||||
#endif
|
||||
|
||||
#ifndef _HAVE_LARGE_INTEGER
|
||||
typedef union _LARGE_INTEGER
|
||||
{
|
||||
struct
|
||||
{
|
||||
DWORD LowPart;
|
||||
LONG HighPart;
|
||||
ULONG LowPart;
|
||||
LONG HighPart;
|
||||
};
|
||||
struct
|
||||
{
|
||||
ULONG LowPart;
|
||||
LONG HighPart;
|
||||
} u;
|
||||
LONGLONG QuadPart;
|
||||
} LARGE_INTEGER, *PLARGE_INTEGER;
|
||||
#endif
|
||||
|
||||
#ifndef _HAVE_LIST_ENTRY
|
||||
typedef struct _LIST_ENTRY
|
||||
{
|
||||
struct _LIST_ENTRY *Flink;
|
||||
struct _LIST_ENTRY *Blink;
|
||||
} LIST_ENTRY,*PLIST_ENTRY;
|
||||
#endif
|
||||
|
||||
#ifndef _HAVE_ANSI_STRING
|
||||
typedef struct _ANSI_STRING
|
||||
{
|
||||
USHORT Length;
|
||||
|
@ -112,8 +136,11 @@ typedef struct _UNICODE_STRING
|
|||
USHORT MaximumLength;
|
||||
PWSTR Buffer;
|
||||
} UNICODE_STRING, *PUNICODE_STRING;
|
||||
#endif
|
||||
|
||||
#include <poppack.h>
|
||||
|
||||
#ifndef _HAVE_LIST_ENTRY
|
||||
/* List Functions */
|
||||
static __inline
|
||||
VOID
|
||||
|
@ -207,8 +234,11 @@ RemoveTailList(
|
|||
Blink->Flink = ListHead;
|
||||
return Entry;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _HAVE_ANSI_STRING
|
||||
typedef const UNICODE_STRING *PCUNICODE_STRING;
|
||||
#endif
|
||||
|
||||
/* Widely used macros */
|
||||
#define LOBYTE(w) ((BYTE)(w))
|
||||
|
@ -243,3 +273,4 @@ typedef const UNICODE_STRING *PCUNICODE_STRING;
|
|||
#define RTL_H
|
||||
|
||||
#endif
|
||||
|
||||
|
|
1
reactos/include/host/wine/mscvpdb.h
Normal file
1
reactos/include/host/wine/mscvpdb.h
Normal file
|
@ -0,0 +1 @@
|
|||
#include "../../reactos/wine/mscvpdb.h"
|
1
reactos/include/host/wine/rbtree.h
Normal file
1
reactos/include/host/wine/rbtree.h
Normal file
|
@ -0,0 +1 @@
|
|||
#include "../../reactos/wine/rbtree.h"
|
|
@ -1,6 +1,7 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <typedefs.h>
|
||||
#include "../pecoff.h"
|
||||
|
||||
static
|
||||
|
|
|
@ -44,32 +44,6 @@
|
|||
#define IMAGE_REL_I386_ABSOLUTE 0x0001
|
||||
#define IMAGE_REL_I386_DIR32 0x0006
|
||||
|
||||
typedef unsigned char BYTE;
|
||||
typedef unsigned char UCHAR;
|
||||
typedef unsigned short WORD;
|
||||
typedef short SHORT;
|
||||
typedef unsigned short USHORT;
|
||||
typedef unsigned long long ULONGLONG;
|
||||
|
||||
#if defined(__x86_64__) && !defined(_WIN64)
|
||||
typedef signed int LONG;
|
||||
typedef unsigned int ULONG;
|
||||
typedef unsigned int DWORD;
|
||||
#else
|
||||
typedef signed long LONG;
|
||||
typedef unsigned long ULONG;
|
||||
typedef unsigned long DWORD;
|
||||
#endif
|
||||
#if defined(_WIN64)
|
||||
typedef unsigned __int64 ULONG_PTR;
|
||||
#else
|
||||
#if defined(__x86_64__) && !defined(_WIN64)
|
||||
typedef unsigned int ULONG_PTR;
|
||||
#else
|
||||
typedef unsigned long ULONG_PTR;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#pragma pack(push,2)
|
||||
typedef struct _IMAGE_DOS_HEADER {
|
||||
WORD e_magic;
|
||||
|
@ -266,3 +240,11 @@ typedef struct _IMAGE_SYMBOL {
|
|||
} IMAGE_SYMBOL;
|
||||
typedef struct _IMAGE_SYMBOL UNALIGNED *PIMAGE_SYMBOL;
|
||||
#pragma pack(pop)
|
||||
|
||||
#define IMAGE_DOS_SIGNATURE 0x5A4D
|
||||
#define IMAGE_OS2_SIGNATURE 0x454E
|
||||
#define IMAGE_OS2_SIGNATURE_LE 0x454C
|
||||
#define IMAGE_VXD_SIGNATURE 0x454C
|
||||
#define IMAGE_NT_SIGNATURE 0x00004550
|
||||
|
||||
#define IMAGE_FIRST_SECTION(h) ((PIMAGE_SECTION_HEADER) ((ULONG_PTR)h+FIELD_OFFSET(IMAGE_NT_HEADERS,OptionalHeader)+((PIMAGE_NT_HEADERS)(h))->FileHeader.SizeOfOptionalHeader))
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
include_directories(${REACTOS_SOURCE_DIR}/tools)
|
||||
add_library(rsym_common rsym_common.c)
|
||||
|
||||
if(ARCH STREQUAL "i386")
|
||||
add_definitions(-D_X86_)
|
||||
add_executable(rsym rsym.c)
|
||||
elseif(ARCH STREQUAL "amd64")
|
||||
add_executable(rsym rsym64.c)
|
||||
endif()
|
||||
target_link_libraries(rsym rsym_common)
|
||||
target_link_libraries(rsym rsym_common dbghelphost zlibhost unicode)
|
||||
add_executable(raddr2line rsym_common.c raddr2line.c)
|
||||
|
|
|
@ -20,13 +20,19 @@
|
|||
* non-zero is failure.
|
||||
*/
|
||||
|
||||
#include "../../dll/win32/dbghelp/compat.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "rsym.h"
|
||||
|
||||
#define MAX_PATH 260
|
||||
#define MAX_SYM_NAME 2000
|
||||
|
||||
static int
|
||||
CompareSymEntry(const PROSSYM_ENTRY SymEntry1, const PROSSYM_ENTRY SymEntry2)
|
||||
{
|
||||
|
@ -272,7 +278,7 @@ ConvertCoffs(ULONG *SymbolsCount, PROSSYM_ENTRY *SymbolsBase,
|
|||
{
|
||||
ULONG Count, i;
|
||||
PCOFF_SYMENT CoffEntry;
|
||||
char FuncName[256];
|
||||
char FuncName[256], FileName[1024];
|
||||
char *p;
|
||||
PROSSYM_ENTRY Current;
|
||||
|
||||
|
@ -346,6 +352,215 @@ ConvertCoffs(ULONG *SymbolsCount, PROSSYM_ENTRY *SymbolsBase,
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct DbgHelpLineEntry {
|
||||
ULONG vma;
|
||||
ULONG fileId;
|
||||
ULONG functionId;
|
||||
ULONG line;
|
||||
};
|
||||
|
||||
struct DbgHelpStringTab {
|
||||
ULONG Length;
|
||||
ULONG Bytes;
|
||||
char ***Table;
|
||||
ULONG LineEntries, CurLineEntries;
|
||||
struct DbgHelpLineEntry *LineEntryData;
|
||||
ULONG NumberOfSymbols;
|
||||
void *process;
|
||||
DWORD module_base;
|
||||
struct DbgHelpLineEntry *lastLineEntry;
|
||||
};
|
||||
|
||||
/* This is the famous DJB hash */
|
||||
static unsigned int
|
||||
ComputeDJBHash(const char *name)
|
||||
{
|
||||
unsigned int val = 5381;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0; name[i]; i++)
|
||||
{
|
||||
val = (33 * val) + name[i];
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static struct DbgHelpLineEntry*
|
||||
DbgHelpAddLineEntry(struct DbgHelpStringTab *tab)
|
||||
{
|
||||
if (tab->CurLineEntries == tab->LineEntries)
|
||||
{
|
||||
struct DbgHelpLineEntry *newEntries = realloc(tab->LineEntryData,
|
||||
tab->LineEntries * 2 * sizeof(struct DbgHelpLineEntry));
|
||||
|
||||
if (!newEntries)
|
||||
return 0;
|
||||
|
||||
tab->LineEntryData = newEntries;
|
||||
|
||||
memset(tab->LineEntryData + tab->LineEntries, 0, sizeof(struct DbgHelpLineEntry) * tab->LineEntries);
|
||||
tab->LineEntries *= 2;
|
||||
}
|
||||
|
||||
return &tab->LineEntryData[tab->CurLineEntries++];
|
||||
}
|
||||
|
||||
static int
|
||||
DbgHelpAddStringToTable(struct DbgHelpStringTab *tab, char *name)
|
||||
{
|
||||
unsigned int bucket = ComputeDJBHash(name) % tab->Length;
|
||||
char **tabEnt = tab->Table[bucket];
|
||||
int i;
|
||||
char **newBucket;
|
||||
|
||||
if (tabEnt)
|
||||
{
|
||||
for (i = 0; tabEnt[i] && strcmp(tabEnt[i], name); i++);
|
||||
if (tabEnt[i])
|
||||
{
|
||||
free(name);
|
||||
return (i << 10) | bucket;
|
||||
}
|
||||
}
|
||||
else
|
||||
i = 0;
|
||||
|
||||
/* At this point, we need to insert */
|
||||
tab->Bytes += strlen(name) + 1;
|
||||
|
||||
newBucket = realloc(tab->Table[bucket], (i+2) * sizeof(char *));
|
||||
|
||||
if (!newBucket)
|
||||
{
|
||||
fprintf(stderr, "realloc failed!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
tab->Table[bucket] = newBucket;
|
||||
tab->Table[bucket][i+1] = 0;
|
||||
tab->Table[bucket][i] = name;
|
||||
return (i << 10) | bucket;
|
||||
}
|
||||
|
||||
const char*
|
||||
DbgHelpGetString(struct DbgHelpStringTab *tab, int id)
|
||||
{
|
||||
int i = id >> 10;
|
||||
int bucket = id & 0x3ff;
|
||||
return tab->Table[bucket][i];
|
||||
}
|
||||
|
||||
static BOOL
|
||||
DbgHelpAddLineNumber(PSRCCODEINFO LineInfo, void *UserContext)
|
||||
{
|
||||
struct DbgHelpStringTab *tab = (struct DbgHelpStringTab *)UserContext;
|
||||
DWORD64 disp;
|
||||
int fileId, functionId;
|
||||
PSYMBOL_INFO pSymbol = malloc(FIELD_OFFSET(SYMBOL_INFO, Name[MAX_SYM_NAME]));
|
||||
if (!pSymbol) return FALSE;
|
||||
memset(pSymbol, 0, FIELD_OFFSET(SYMBOL_INFO, Name[MAX_SYM_NAME]));
|
||||
|
||||
fileId = DbgHelpAddStringToTable(tab, strdup(LineInfo->FileName));
|
||||
|
||||
pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO);
|
||||
pSymbol->MaxNameLen = MAX_SYM_NAME;
|
||||
|
||||
if (!SymFromAddr(tab->process, LineInfo->Address, &disp, pSymbol))
|
||||
{
|
||||
//fprintf(stderr, "SymFromAddr failed.\n");
|
||||
free(pSymbol);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
functionId = DbgHelpAddStringToTable(tab, strdup(pSymbol->Name));
|
||||
|
||||
if (LineInfo->Address == 0)
|
||||
fprintf(stderr, "Address is 0.\n");
|
||||
|
||||
tab->lastLineEntry = DbgHelpAddLineEntry(tab);
|
||||
tab->lastLineEntry->vma = LineInfo->Address - LineInfo->ModBase;
|
||||
tab->lastLineEntry->functionId = functionId;
|
||||
tab->lastLineEntry->fileId = fileId;
|
||||
tab->lastLineEntry->line = LineInfo->LineNumber;
|
||||
|
||||
free(pSymbol);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int
|
||||
ConvertDbgHelp(void *process, DWORD module_base,
|
||||
ULONG *SymbolsCount, PROSSYM_ENTRY *SymbolsBase,
|
||||
ULONG *StringsLength, void **StringsBase)
|
||||
{
|
||||
char *strings, *strings_copy;
|
||||
int i, j, bucket, entry;
|
||||
PROSSYM_ENTRY rossym;
|
||||
struct DbgHelpStringTab strtab = { 0 };
|
||||
|
||||
strtab.process = process;
|
||||
strtab.module_base = module_base;
|
||||
strtab.Bytes = 1;
|
||||
strtab.Length = 1024;
|
||||
strtab.Table = calloc(1024, sizeof(const char **));
|
||||
strtab.Table[0] = calloc(2, sizeof(const char *));
|
||||
strtab.Table[0][0] = strdup(""); // The zero string
|
||||
strtab.CurLineEntries = 0;
|
||||
strtab.LineEntries = 16384;
|
||||
strtab.LineEntryData = calloc(strtab.LineEntries, sizeof(struct DbgHelpLineEntry));
|
||||
|
||||
SymEnumLines(process, module_base, NULL, NULL, DbgHelpAddLineNumber, &strtab);
|
||||
|
||||
/* Transcribe necessary strings */
|
||||
*StringsLength = strtab.Bytes;
|
||||
strings = strings_copy = ((char *)(*StringsBase = malloc(strtab.Bytes)));
|
||||
|
||||
/* Copy in strings */
|
||||
for (i = 0; i < strtab.Length; i++)
|
||||
{
|
||||
for (j = 0; strtab.Table[i] && strtab.Table[i][j]; j++)
|
||||
{
|
||||
/* Each entry is replaced by its corresponding entry in our string
|
||||
section. We can substract the strings origin to get an offset. */
|
||||
char *toFree = strtab.Table[i][j];
|
||||
strtab.Table[i][j] = strcpy(strings_copy, strtab.Table[i][j]);
|
||||
free(toFree);
|
||||
strings_copy += strlen(strings_copy) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
assert(strings_copy == strings + strtab.Bytes);
|
||||
|
||||
*SymbolsBase = calloc(strtab.CurLineEntries, sizeof(ROSSYM_ENTRY));
|
||||
*SymbolsCount = strtab.CurLineEntries;
|
||||
|
||||
/* Copy symbols into rossym entries */
|
||||
for (i = 0; i < strtab.CurLineEntries; i++)
|
||||
{
|
||||
rossym = &(*SymbolsBase)[i];
|
||||
rossym->Address = strtab.LineEntryData[i].vma;
|
||||
bucket = strtab.LineEntryData[i].fileId & 0x3ff;
|
||||
entry = strtab.LineEntryData[i].fileId >> 10;
|
||||
rossym->FileOffset = strtab.Table[bucket][entry] - strings;
|
||||
bucket = strtab.LineEntryData[i].functionId & 0x3ff;
|
||||
entry = strtab.LineEntryData[i].functionId >> 10;
|
||||
rossym->FunctionOffset = strtab.Table[bucket][entry] - strings;
|
||||
rossym->SourceLine = strtab.LineEntryData[i].line;
|
||||
}
|
||||
|
||||
/* Free stringtab */
|
||||
for (i = 0; i < strtab.Length; i++)
|
||||
{
|
||||
free(strtab.Table[i]);
|
||||
}
|
||||
|
||||
free(strtab.LineEntryData);
|
||||
|
||||
qsort(*SymbolsBase, *SymbolsCount, sizeof(ROSSYM_ENTRY), (int (*)(const void *, const void *))CompareSymEntry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
MergeStabsAndCoffs(ULONG *MergedSymbolCount, PROSSYM_ENTRY *MergedSymbols,
|
||||
ULONG StabSymbolsCount, PROSSYM_ENTRY StabSymbols,
|
||||
|
@ -362,7 +577,7 @@ MergeStabsAndCoffs(ULONG *MergedSymbolCount, PROSSYM_ENTRY *MergedSymbols,
|
|||
*MergedSymbols = NULL;
|
||||
return 0;
|
||||
}
|
||||
*MergedSymbols = malloc(StabSymbolsCount * sizeof(ROSSYM_ENTRY));
|
||||
*MergedSymbols = malloc((StabSymbolsCount + CoffSymbolsCount) * sizeof(ROSSYM_ENTRY));
|
||||
if (*MergedSymbols == NULL)
|
||||
{
|
||||
fprintf(stderr, "Unable to allocate memory for merged symbols\n");
|
||||
|
@ -406,6 +621,7 @@ MergeStabsAndCoffs(ULONG *MergedSymbolCount, PROSSYM_ENTRY *MergedSymbols,
|
|||
CoffSymbols[CoffIndex].FunctionOffset != 0)
|
||||
{
|
||||
(*MergedSymbols)[*MergedSymbolCount].FunctionOffset = CoffSymbols[CoffIndex].FunctionOffset;
|
||||
CoffSymbols[CoffIndex].FileOffset = CoffSymbols[CoffIndex].FunctionOffset = 0;
|
||||
}
|
||||
if (StabFunctionStringOffset != NewStabFunctionStringOffset)
|
||||
{
|
||||
|
@ -414,6 +630,18 @@ MergeStabsAndCoffs(ULONG *MergedSymbolCount, PROSSYM_ENTRY *MergedSymbols,
|
|||
StabFunctionStringOffset = NewStabFunctionStringOffset;
|
||||
(*MergedSymbolCount)++;
|
||||
}
|
||||
/* Handle functions that have no analog in the upstream data */
|
||||
for (CoffIndex = 0; CoffIndex < CoffSymbolsCount; CoffIndex++)
|
||||
{
|
||||
if (CoffSymbols[CoffIndex].Address &&
|
||||
CoffSymbols[CoffIndex].FunctionOffset)
|
||||
{
|
||||
(*MergedSymbols)[*MergedSymbolCount] = CoffSymbols[CoffIndex];
|
||||
(*MergedSymbolCount)++;
|
||||
}
|
||||
}
|
||||
|
||||
qsort(*MergedSymbols, *MergedSymbolCount, sizeof(ROSSYM_ENTRY), (int (*)(const void *, const void *)) CompareSymEntry);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -510,6 +738,18 @@ ProcessRelocations(ULONG *ProcessedRelocsLength, void **ProcessedRelocs,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static const BYTE*
|
||||
GetSectionName(void *StringsBase, const BYTE *SectionTitle)
|
||||
{
|
||||
if (SectionTitle[0] == '/')
|
||||
{
|
||||
int offset = atoi((char*)SectionTitle+1);
|
||||
return ((BYTE *)StringsBase) + offset;
|
||||
}
|
||||
else
|
||||
return SectionTitle;
|
||||
}
|
||||
|
||||
static int
|
||||
CreateOutputFile(FILE *OutFile, void *InData,
|
||||
PIMAGE_DOS_HEADER InDosHeader, PIMAGE_FILE_HEADER InFileHeader,
|
||||
|
@ -529,14 +769,19 @@ CreateOutputFile(FILE *OutFile, void *InData,
|
|||
ULONG RosSymOffset, RosSymFileLength;
|
||||
int InRelocSectionIndex;
|
||||
PIMAGE_SECTION_HEADER OutRelocSection;
|
||||
/* Each coff symbol is 18 bytes and the string table follows */
|
||||
char *StringTable = (char *)InData +
|
||||
InFileHeader->PointerToSymbolTable + 18 * InFileHeader->NumberOfSymbols;
|
||||
|
||||
StartOfRawData = 0;
|
||||
for (Section = 0; Section < InFileHeader->NumberOfSections; Section++)
|
||||
{
|
||||
if ((StartOfRawData == 0 ||
|
||||
InSectionHeaders[Section].PointerToRawData < StartOfRawData)
|
||||
const BYTE *SectionName = GetSectionName(StringTable,
|
||||
InSectionHeaders[Section].Name);
|
||||
if ((StartOfRawData == 0 || InSectionHeaders[Section].PointerToRawData < StartOfRawData)
|
||||
&& InSectionHeaders[Section].PointerToRawData != 0
|
||||
&& (strncmp((char *) InSectionHeaders[Section].Name, ".stab", 5)) != 0)
|
||||
&& (strncmp((char *) SectionName, ".stab", 5)) != 0
|
||||
&& (strncmp((char *) SectionName, ".debug_", 7)) != 0)
|
||||
{
|
||||
StartOfRawData = InSectionHeaders[Section].PointerToRawData;
|
||||
}
|
||||
|
@ -594,7 +839,10 @@ CreateOutputFile(FILE *OutFile, void *InData,
|
|||
OutRelocSection = NULL;
|
||||
for (Section = 0; Section < InFileHeader->NumberOfSections; Section++)
|
||||
{
|
||||
if ((strncmp((char *) InSectionHeaders[Section].Name, ".stab", 5)) != 0)
|
||||
const BYTE *SectionName = GetSectionName(StringTable,
|
||||
InSectionHeaders[Section].Name);
|
||||
if ((strncmp((char *) SectionName, ".stab", 5) != 0) &&
|
||||
(strncmp((char *) SectionName, ".debug_", 7)) != 0)
|
||||
{
|
||||
*CurrentSectionHeader = InSectionHeaders[Section];
|
||||
CurrentSectionHeader->PointerToLinenumbers = 0;
|
||||
|
@ -778,19 +1026,22 @@ int main(int argc, char* argv[])
|
|||
char* path1;
|
||||
char* path2;
|
||||
FILE* out;
|
||||
void *StringBase;
|
||||
ULONG StringsLength;
|
||||
ULONG StabSymbolsCount;
|
||||
PROSSYM_ENTRY StabSymbols;
|
||||
ULONG CoffSymbolsCount;
|
||||
PROSSYM_ENTRY CoffSymbols;
|
||||
ULONG MergedSymbolsCount;
|
||||
PROSSYM_ENTRY MergedSymbols;
|
||||
void *StringBase = NULL;
|
||||
ULONG StringsLength = 0;
|
||||
ULONG StabSymbolsCount = 0;
|
||||
PROSSYM_ENTRY StabSymbols = NULL;
|
||||
ULONG CoffSymbolsCount = 0;
|
||||
PROSSYM_ENTRY CoffSymbols = NULL;
|
||||
ULONG MergedSymbolsCount = 0;
|
||||
PROSSYM_ENTRY MergedSymbols = NULL;
|
||||
size_t FileSize;
|
||||
void *FileData;
|
||||
ULONG RosSymLength;
|
||||
void *RosSymSection;
|
||||
DWORD module_base;
|
||||
void *file;
|
||||
char elfhdr[4] = { '\177', 'E', 'L', 'F' };
|
||||
BOOLEAN UseDbgHelp = FALSE;
|
||||
|
||||
if (argc != 3)
|
||||
{
|
||||
|
@ -808,6 +1059,8 @@ int main(int argc, char* argv[])
|
|||
exit(1);
|
||||
}
|
||||
|
||||
file = fopen(path1, "rb");
|
||||
|
||||
/* Check if MZ header exists */
|
||||
PEDosHeader = (PIMAGE_DOS_HEADER) FileData;
|
||||
if (PEDosHeader->e_magic != IMAGE_DOS_MAGIC ||
|
||||
|
@ -845,6 +1098,33 @@ int main(int argc, char* argv[])
|
|||
exit(1);
|
||||
}
|
||||
|
||||
if (StabsLength == 0)
|
||||
{
|
||||
// SYMOPT_AUTO_PUBLICS
|
||||
// SYMOPT_FAVOR_COMPRESSED
|
||||
// SYMOPT_LOAD_ANYTHING
|
||||
// SYMOPT_LOAD_LINES
|
||||
SymSetOptions(0x10000 | 0x800000 | 0x40 | 0x10);
|
||||
SymInitialize(FileData, ".", 0);
|
||||
|
||||
module_base = SymLoadModule(FileData, file, path1, path1, 0, FileSize) & 0xffffffff;
|
||||
|
||||
if (ConvertDbgHelp(FileData,
|
||||
module_base,
|
||||
&StabSymbolsCount,
|
||||
&StabSymbols,
|
||||
&StringsLength,
|
||||
&StringBase))
|
||||
{
|
||||
free(FileData);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
UseDbgHelp = TRUE;
|
||||
SymUnloadModule(FileData, module_base);
|
||||
SymCleanup(FileData);
|
||||
}
|
||||
|
||||
if (GetCoffInfo(FileData,
|
||||
PEFileHeader,
|
||||
PESectionHeaders,
|
||||
|
@ -857,34 +1137,47 @@ int main(int argc, char* argv[])
|
|||
exit(1);
|
||||
}
|
||||
|
||||
StringBase = malloc(1 + StabStringsLength + CoffStringsLength +
|
||||
(CoffsLength / sizeof(ROSSYM_ENTRY)) * (E_SYMNMLEN + 1));
|
||||
if (StringBase == NULL)
|
||||
if (!UseDbgHelp)
|
||||
{
|
||||
free(FileData);
|
||||
fprintf(stderr, "Failed to allocate memory for strings table\n");
|
||||
exit(1);
|
||||
}
|
||||
/* Make offset 0 into an empty string */
|
||||
*((char *) StringBase) = '\0';
|
||||
StringsLength = 1;
|
||||
StringBase = malloc(1 + StringsLength + CoffStringsLength +
|
||||
(CoffsLength / sizeof(ROSSYM_ENTRY)) * (E_SYMNMLEN + 1));
|
||||
if (StringBase == NULL)
|
||||
{
|
||||
free(FileData);
|
||||
fprintf(stderr, "Failed to allocate memory for strings table\n");
|
||||
exit(1);
|
||||
}
|
||||
/* Make offset 0 into an empty string */
|
||||
*((char *) StringBase) = '\0';
|
||||
StringsLength = 1;
|
||||
|
||||
if (ConvertStabs(&StabSymbolsCount,
|
||||
&StabSymbols,
|
||||
&StringsLength,
|
||||
StringBase,
|
||||
StabsLength,
|
||||
StabBase,
|
||||
StabStringsLength,
|
||||
StabStringBase,
|
||||
ImageBase,
|
||||
PEFileHeader,
|
||||
PESectionHeaders))
|
||||
if (ConvertStabs(&StabSymbolsCount,
|
||||
&StabSymbols,
|
||||
&StringsLength,
|
||||
StringBase,
|
||||
StabsLength,
|
||||
StabBase,
|
||||
StabStringsLength,
|
||||
StabStringBase,
|
||||
ImageBase,
|
||||
PEFileHeader,
|
||||
PESectionHeaders))
|
||||
{
|
||||
free(StringBase);
|
||||
free(FileData);
|
||||
fprintf(stderr, "Failed to allocate memory for strings table\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
free(StringBase);
|
||||
free(FileData);
|
||||
fprintf(stderr, "Failed to allocate memory for strings table\n");
|
||||
exit(1);
|
||||
StringBase = realloc(StringBase, StringsLength + CoffStringsLength);
|
||||
if (!StringBase)
|
||||
{
|
||||
free(FileData);
|
||||
fprintf(stderr, "Failed to allocate memory for strings table\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (ConvertCoffs(&CoffSymbolsCount,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* rsym.h */
|
||||
|
||||
#pragma once
|
||||
#include <typedefs.h>
|
||||
#include "../pecoff.h"
|
||||
|
||||
typedef struct {
|
||||
|
|
Loading…
Reference in a new issue