[DBGHELP]
[reactos.git] / reactos / dll / win32 / dbghelp / dbghelp_ros.diff
1 diff -prudN e:\Wine\dlls\dbghelp/cpu_i386.c e:\reactos\dll\win32\dbghelp/cpu_i386.c
2 --- e:\Wine\dlls\dbghelp/cpu_i386.c 2012-12-09 09:57:02.223180200 +0100
3 +++ e:\reactos\dll\win32\dbghelp/cpu_i386.c 2013-07-31 14:07:19.201466300 +0100
4 @@ -20,12 +20,17 @@
5
6 #include <assert.h>
7
8 +#ifndef DBGHELP_STATIC_LIB
9 #include "ntstatus.h"
10 -#define WIN32_NO_STATUS
11 +#endif
12 +
13 #include "dbghelp_private.h"
14 +
15 +#ifndef DBGHELP_STATIC_LIB
16 #include "wine/winbase16.h"
17 #include "winternl.h"
18 #include "wine/debug.h"
19 +#endif
20
21 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
22
23 @@ -34,7 +39,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
24
25 #define IS_VM86_MODE(ctx) (ctx->EFlags & V86_FLAG)
26
27 -#ifdef __i386__
28 +
29 +#if defined(__i386__) && !defined(DBGHELP_STATIC_LIB)
30 static ADDRESS_MODE get_selector_type(HANDLE hThread, const CONTEXT* ctx, WORD sel)
31 {
32 LDT_ENTRY le;
33 @@ -73,6 +79,7 @@ static unsigned i386_build_addr(HANDLE h
34 }
35 #endif
36
37 +#ifndef DBGHELP_STATIC_LIB
38 static unsigned i386_get_addr(HANDLE hThread, const CONTEXT* ctx,
39 enum cpu_addr ca, ADDRESS64* addr)
40 {
41 @@ -86,8 +93,9 @@ static unsigned i386_get_addr(HANDLE hTh
42 #endif
43 return FALSE;
44 }
45 +#endif /* DBGHELP_STATIC_LIB */
46
47 -#ifdef __i386__
48 +#if defined(__i386__) && !defined(DBGHELP_STATIC_LIB)
49 /* fetch_next_frame32()
50 *
51 * modify (at least) context.{eip, esp, ebp} using unwind information
52 @@ -110,7 +118,9 @@ static BOOL fetch_next_frame32(struct cp
53 cpair[2].name = "$eip"; cpair[2].pvalue = &context->Eip;
54 cpair[3].name = NULL; cpair[3].pvalue = NULL;
55
56 +#ifndef DBGHELP_STATIC_LIB
57 if (!pdb_virtual_unwind(csw, curr_pc, context, cpair))
58 +#endif
59 {
60 /* do a simple unwind using ebp
61 * we assume a "regular" prologue in the function has been used
62 @@ -148,6 +158,7 @@ enum st_mode {stm_start, stm_32bit, stm_
63 #define set_curr_mode(m) {frame->Reserved[__CurrentModeCount] &= ~0x0F; frame->Reserved[__CurrentModeCount] |= (m & 0x0F);}
64 #define inc_curr_count() (frame->Reserved[__CurrentModeCount] += 0x10)
65
66 +#ifndef DBGHELP_STATIC_LIB
67 static BOOL i386_stack_walk(struct cpu_stack_walk* csw, LPSTACKFRAME64 frame, CONTEXT* context)
68 {
69 STACK32FRAME frame32;
70 @@ -513,6 +524,7 @@ done_err:
71 set_curr_mode(stm_done);
72 return FALSE;
73 }
74 +#endif /* DBGHELP_STATIC_LIB */
75
76 static unsigned i386_map_dwarf_register(unsigned regno)
77 {
78 @@ -662,6 +674,7 @@ static const char* i386_fetch_regname(un
79 return NULL;
80 }
81
82 +#ifndef DBGHELP_STATIC_LIB
83 static BOOL i386_fetch_minidump_thread(struct dump_context* dc, unsigned index, unsigned flags, const CONTEXT* ctx)
84 {
85 if (ctx->ContextFlags && (flags & ThreadWriteInstructionWindow))
86 @@ -675,6 +688,7 @@ static BOOL i386_fetch_minidump_thread(s
87
88 return TRUE;
89 }
90 +#endif
91
92 static BOOL i386_fetch_minidump_module(struct dump_context* dc, unsigned index, unsigned flags)
93 {
94 @@ -688,12 +702,22 @@ DECLSPEC_HIDDEN struct cpu cpu_i386 = {
95 IMAGE_FILE_MACHINE_I386,
96 4,
97 CV_REG_EBP,
98 +#ifndef DBGHELP_STATIC_LIB
99 i386_get_addr,
100 i386_stack_walk,
101 +#else
102 + NULL,
103 + NULL,
104 +#endif
105 NULL,
106 i386_map_dwarf_register,
107 i386_fetch_context_reg,
108 i386_fetch_regname,
109 +#ifndef DBGHELP_STATIC_LIB
110 i386_fetch_minidump_thread,
111 i386_fetch_minidump_module,
112 +#else
113 + NULL,
114 + NULL,
115 +#endif
116 };
117 diff -prudN e:\Wine\dlls\dbghelp/cpu_x86_64.c e:\reactos\dll\win32\dbghelp/cpu_x86_64.c
118 --- e:\Wine\dlls\dbghelp/cpu_x86_64.c 2012-04-02 20:39:57.749333300 +0100
119 +++ e:\reactos\dll\win32\dbghelp/cpu_x86_64.c 2013-06-16 10:06:39.482074000 +0100
120 @@ -302,10 +302,10 @@ static BOOL is_inside_epilog(struct cpu_
121 if ((op0 & 0xf8) == 0x48)
122 {
123 if (!sw_read_mem(csw, pc + 1, &op1, 1)) return FALSE;
124 + if (!sw_read_mem(csw, pc + 2, &op2, 1)) return FALSE;
125 switch (op1)
126 {
127 case 0x81: /* add $nnnn,%rsp */
128 - if (!sw_read_mem(csw, pc + 2, &op2, 1)) return FALSE;
129 if (op0 == 0x48 && op2 == 0xc4)
130 {
131 pc += 7;
132 @@ -313,7 +313,6 @@ static BOOL is_inside_epilog(struct cpu_
133 }
134 return FALSE;
135 case 0x83: /* add $n,%rsp */
136 - if (!sw_read_mem(csw, pc + 2, &op2, 1)) return FALSE;
137 if (op0 == 0x48 && op2 == 0xc4)
138 {
139 pc += 4;
140 @@ -321,7 +320,6 @@ static BOOL is_inside_epilog(struct cpu_
141 }
142 return FALSE;
143 case 0x8d: /* lea n(reg),%rsp */
144 - if (!sw_read_mem(csw, pc + 2, &op2, 1)) return FALSE;
145 if (op0 & 0x06) return FALSE; /* rex.RX must be cleared */
146 if (((op2 >> 3) & 7) != 4) return FALSE; /* dest reg mus be %rsp */
147 if ((op2 & 7) == 4) return FALSE; /* no SIB byte allowed */
148 diff -prudN e:\Wine\dlls\dbghelp/dbghelp.c e:\reactos\dll\win32\dbghelp/dbghelp.c
149 --- e:\Wine\dlls\dbghelp/dbghelp.c 2013-03-16 11:54:52.395468000 +0100
150 +++ e:\reactos\dll\win32\dbghelp/dbghelp.c 2013-07-31 14:07:19.207470800 +0100
151 @@ -21,11 +21,14 @@
152 #include "config.h"
153
154 #include "dbghelp_private.h"
155 +#include "wdbgexts.h"
156 +
157 +#ifndef DBGHELP_STATIC_LIB
158 #include "winerror.h"
159 #include "psapi.h"
160 #include "wine/debug.h"
161 -#include "wdbgexts.h"
162 #include "winnls.h"
163 +#endif
164
165 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
166
167 @@ -133,6 +136,7 @@ void* fetch_buffer(struct process* pcs,
168 return pcs->buffer;
169 }
170
171 +#ifndef DBGHELP_STATIC_LIB
172 const char* wine_dbgstr_addr(const ADDRESS64* addr)
173 {
174 if (!addr) return "(null)";
175 @@ -150,12 +154,18 @@ const char* wine_dbgstr_addr(const ADDRE
176 return "unknown";
177 }
178 }
179 +#endif
180
181 extern struct cpu cpu_i386, cpu_x86_64, cpu_ppc, cpu_arm, cpu_arm64;
182
183 +#ifndef DBGHELP_STATIC_LIB
184 static struct cpu* dbghelp_cpus[] = {&cpu_i386, &cpu_x86_64, &cpu_ppc, &cpu_arm, &cpu_arm64, NULL};
185 +#else
186 +static struct cpu* dbghelp_cpus[] = {&cpu_i386, NULL};
187 +#endif
188 +
189 struct cpu* dbghelp_current_cpu =
190 -#if defined(__i386__)
191 +#if defined(__i386__) || defined(DBGHELP_STATIC_LIB)
192 &cpu_i386
193 #elif defined(__x86_64__)
194 &cpu_x86_64
195 @@ -280,8 +290,10 @@ static BOOL check_live_target(struct pro
196 {
197 if (!GetProcessId(pcs->handle)) return FALSE;
198 if (GetEnvironmentVariableA("DBGHELP_NOLIVE", NULL, 0)) return FALSE;
199 +#ifndef DBGHELP_STATIC_LIB
200 if (!elf_read_wine_loader_dbg_info(pcs))
201 macho_read_wine_loader_dbg_info(pcs);
202 +#endif
203 return TRUE;
204 }
205
206 @@ -370,7 +382,8 @@ BOOL WINAPI SymInitializeW(HANDLE hProce
207 pcs->dbg_hdr_addr = 0;
208 pcs->next = process_first;
209 process_first = pcs;
210 -
211 +
212 +#ifndef DBGHELP_STATIC_LIB
213 if (check_live_target(pcs))
214 {
215 if (fInvadeProcess)
216 @@ -384,6 +397,7 @@ BOOL WINAPI SymInitializeW(HANDLE hProce
217 SetLastError(ERROR_INVALID_PARAMETER);
218 return FALSE;
219 }
220 +#endif
221
222 return TRUE;
223 }
224
225 diff -prudN e:\Wine\dlls\dbghelp/dbghelp_private.h e:\reactos\dll\win32\dbghelp/dbghelp_private.h
226 --- e:\Wine\dlls\dbghelp/dbghelp_private.h 2012-04-02 20:39:57.749333300 +0100
227 +++ e:\reactos\dll\win32\dbghelp/dbghelp_private.h 2013-09-01 11:29:17.911557200 +0100
228 @@ -21,19 +21,30 @@
229 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
230 */
231
232 +#define WIN32_NO_STATUS
233 +#define _INC_WINDOWS
234 +#define COM_NO_WINDOWS_H
235 +
236 #include <stdarg.h>
237 -#include "windef.h"
238 -#include "winbase.h"
239 -#include "winver.h"
240 -#include "dbghelp.h"
241 -#include "objbase.h"
242 -#include "oaidl.h"
243 -#include "winnls.h"
244 -#include "wine/list.h"
245 -#include "wine/unicode.h"
246 -#include "wine/rbtree.h"
247
248 -#include "cvconst.h"
249 +#ifndef DBGHELP_STATIC_LIB
250 +#include <windef.h>
251 +#include <winbase.h>
252 +#include <winver.h>
253 +#include <dbghelp.h>
254 +#include <objbase.h>
255 +#include <cvconst.h>
256 +#include <wine/unicode.h>
257 +#else
258 +#include <string.h>
259 +#include "compat.h"
260 +#endif
261 +
262 +//#include "oaidl.h"
263 +//#include "winnls.h"
264 +#include <wine/list.h>
265 +#include <wine/rbtree.h>
266 +
267
268 /* #define USE_STATS */
269
270 @@ -352,6 +363,13 @@ struct module_format
271 } u;
272 };
273
274 +struct symt_idx_to_ptr
275 +{
276 + struct hash_table_elt hash_elt;
277 + DWORD idx;
278 + const struct symt *sym;
279 +};
280 +
281 extern const struct wine_rb_functions source_rb_functions DECLSPEC_HIDDEN;
282 struct module
283 {
284 @@ -376,6 +394,9 @@ struct module
285 unsigned sorttab_size;
286 struct symt_ht** addr_sorttab;
287 struct hash_table ht_symbols;
288 +#ifdef __x86_64__
289 + struct hash_table ht_symaddr;
290 +#endif
291
292 /* types */
293 struct hash_table ht_types;
294 @@ -671,7 +692,9 @@ extern BOOL dwarf2_virtual_unwin
295 CONTEXT* context, ULONG_PTR* cfa) DECLSPEC_HIDDEN;
296
297 /* stack.c */
298 +#ifndef DBGHELP_STATIC_LIB
299 extern BOOL sw_read_mem(struct cpu_stack_walk* csw, DWORD64 addr, void* ptr, DWORD sz) DECLSPEC_HIDDEN;
300 +#endif
301 extern DWORD64 sw_xlat_addr(struct cpu_stack_walk* csw, ADDRESS64* addr) DECLSPEC_HIDDEN;
302 extern void* sw_table_access(struct cpu_stack_walk* csw, DWORD64 addr) DECLSPEC_HIDDEN;
303 extern DWORD64 sw_module_base(struct cpu_stack_walk* csw, DWORD64 addr) DECLSPEC_HIDDEN;
304
305 diff -prudN e:\Wine\dlls\dbghelp/dwarf.c e:\reactos-dwarf\dll\win32\dbghelp/dwarf.c
306 --- e:\Wine\dlls\dbghelp/dwarf.c 2013-03-02 14:17:59.439371000 +0100
307 +++ e:\reactos\dll\win32\dbghelp/dwarf.c 2013-07-31 14:07:19.222482300 +0100
308 @@ -22,23 +22,23 @@
309
310 #define NONAMELESSUNION
311
312 -#include "config.h"
313 +#include <config.h>
314
315 -#include <sys/types.h>
316 -#include <fcntl.h>
317 +//#include <sys/types.h>
318 +//#include <fcntl.h>
319 #ifdef HAVE_SYS_STAT_H
320 # include <sys/stat.h>
321 #endif
322 #ifdef HAVE_SYS_MMAN_H
323 #include <sys/mman.h>
324 #endif
325 -#include <limits.h>
326 -#include <stdlib.h>
327 -#include <string.h>
328 +//#include <limits.h>
329 +//#include <stdlib.h>
330 +//#include <string.h>
331 #ifdef HAVE_UNISTD_H
332 # include <unistd.h>
333 #endif
334 -#include <stdio.h>
335 +//#include <stdio.h>
336 #include <assert.h>
337 #include <stdarg.h>
338
339 @@ -46,18 +46,20 @@
340 #include <zlib.h>
341 #endif
342
343 -#include "windef.h"
344 -#include "winternl.h"
345 -#include "winbase.h"
346 -#include "winuser.h"
347 -#include "ole2.h"
348 -#include "oleauto.h"
349 +//#include "windef.h"
350 +//#include "winbase.h"
351 +//#include "winuser.h"
352 +//#include "ole2.h"
353 +//#include "oleauto.h"
354 +
355 +#ifndef DBGHELP_STATIC_LIB
356 +#include <winternl.h>
357 +#include <wine/debug.h>
358 +#endif
359
360 #include "dbghelp_private.h"
361 #include "image_private.h"
362
363 -#include "wine/debug.h"
364 -
365 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_dwarf);
366
367 /* FIXME:
368 @@ -1888,8 +1890,10 @@ static struct symt* dwarf2_parse_subprog
369 * (not the case for stabs), we just drop Wine's thunks here...
370 * Actual thunks will be created in elf_module from the symbol table
371 */
372 +#ifndef DBGHELP_STATIC_LIB
373 if (elf_is_in_thunk_area(ctx->load_offset + low_pc, ctx->thunks) >= 0)
374 return NULL;
375 +#endif
376 if (!(ret_type = dwarf2_lookup_type(ctx, di)))
377 {
378 ret_type = ctx->symt_cache[sc_void];
379 diff -prudN e:\Wine\dlls\dbghelp/dwarf.h e:\reactos\dll\win32\dbghelp/dwarf.h
380 --- e:\Wine\dlls\dbghelp/dwarf.h 2011-09-16 23:22:36.194780200 +0100
381 +++ e:\reactos\dll\win32\dbghelp/dwarf.h 2013-07-31 14:07:19.227485700 +0100
382 @@ -554,3 +554,15 @@ enum dwarf_call_frame_info
383 #define DW_INL_inlined 0x01
384 #define DW_INL_declared_not_inlined 0x02
385 #define DW_INL_declared_inlined 0x03
386 +
387 +#ifdef DBGHELP_STATIC_LIB
388 +/* from stack.c */
389 +static BOOL sw_read_mem(struct cpu_stack_walk* csw, DWORD64 addr, void* ptr, DWORD sz)
390 +{
391 + DWORD bytes_read = 0;
392 + if (csw->is32)
393 + return csw->u.s32.f_read_mem(csw->hProcess, addr, ptr, sz, &bytes_read);
394 + else
395 + return csw->u.s64.f_read_mem(csw->hProcess, addr, ptr, sz, &bytes_read);
396 +}
397 +#endif
398
399 diff -prudN e:\Wine\dlls\dbghelp/image_private.h e:\reactos\dll\win32\dbghelp/image_private.h
400 --- e:\Wine\dlls\dbghelp/image_private.h 2012-04-02 20:39:57.752333500 +0100
401 +++ e:\reactos\dll\win32\dbghelp/image_private.h 2013-07-31 14:07:19.195462800 +0100
402 @@ -45,7 +45,7 @@
403
404 #define IMAGE_NO_MAP ((void*)-1)
405
406 -#ifdef __ELF__
407 +#if defined(__ELF__) && !defined(DBGHELP_STATIC_LIB)
408
409 #ifdef _WIN64
410 #define Elf_Ehdr Elf64_Ehdr
411 @@ -85,7 +85,7 @@ struct image_file_map
412 const char* shstrtab;
413 struct image_file_map* alternate; /* another ELF file (linked to this one) */
414 char* target_copy;
415 -#ifdef __ELF__
416 +#if defined(__ELF__) && !defined(DBGHELP_STATIC_LIB)
417 Elf_Ehdr elfhdr;
418 struct
419 {
420 @@ -135,7 +135,9 @@ static inline BOOL image_find_section(st
421 {
422 switch (fmap->modtype)
423 {
424 +#ifndef DBGHELP_STATIC_LIB
425 case DMT_ELF: return elf_find_section(fmap, name, SHT_NULL, ism);
426 +#endif
427 case DMT_PE: return pe_find_section(fmap, name, ism);
428 default: assert(0); return FALSE;
429 }
430 @@ -146,7 +148,9 @@ static inline const char* image_map_sect
431 if (!ism->fmap) return NULL;
432 switch (ism->fmap->modtype)
433 {
434 +#ifndef DBGHELP_STATIC_LIB
435 case DMT_ELF: return elf_map_section(ism);
436 +#endif
437 case DMT_PE: return pe_map_section(ism);
438 default: assert(0); return NULL;
439 }
440 @@ -157,7 +161,9 @@ static inline void image_unmap_section(s
441 if (!ism->fmap) return;
442 switch (ism->fmap->modtype)
443 {
444 +#ifndef DBGHELP_STATIC_LIB
445 case DMT_ELF: elf_unmap_section(ism); break;
446 +#endif
447 case DMT_PE: pe_unmap_section(ism); break;
448 default: assert(0); return;
449 }
450 @@ -168,7 +174,9 @@ static inline DWORD_PTR image_get_map_rv
451 if (!ism->fmap) return 0;
452 switch (ism->fmap->modtype)
453 {
454 +#ifndef DBGHELP_STATIC_LIB
455 case DMT_ELF: return elf_get_map_rva(ism);
456 +#endif
457 case DMT_PE: return pe_get_map_rva(ism);
458 default: assert(0); return 0;
459 }
460 @@ -179,7 +187,9 @@ static inline unsigned image_get_map_siz
461 if (!ism->fmap) return 0;
462 switch (ism->fmap->modtype)
463 {
464 +#ifndef DBGHELP_STATIC_LIB
465 case DMT_ELF: return elf_get_map_size(ism);
466 +#endif
467 case DMT_PE: return pe_get_map_size(ism);
468 default: assert(0); return 0;
469 }
470
471 diff -prudN e:\Wine\dlls\dbghelp/module.c e:\reactos\dll\win32\dbghelp/module.c
472 --- e:\Wine\dlls\dbghelp/module.c 2012-09-09 19:47:53.367024200 +0100
473 +++ e:\reactos\dll\win32\dbghelp/module.c 2013-09-01 11:29:17.840509700 +0100
474 @@ -19,16 +19,19 @@
475 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
476 */
477
478 -#include "config.h"
479 -#include <stdlib.h>
480 -#include <stdio.h>
481 -#include <string.h>
482 +#include <config.h>
483 +//#include <stdlib.h>
484 +//#include <stdio.h>
485 +//#include <string.h>
486 #include <assert.h>
487
488 #include "dbghelp_private.h"
489 -#include "psapi.h"
490 -#include "winternl.h"
491 -#include "wine/debug.h"
492 +
493 +#ifndef DBGHELP_STATIC_LIB
494 +#include <psapi.h>
495 +#include <wine/debug.h>
496 +#endif
497 +//#include "winternl.h"
498
499 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
500
501 @@ -220,6 +223,9 @@ struct module* module_new(struct process
502 */
503 hash_table_init(&module->pool, &module->ht_symbols, 4096);
504 hash_table_init(&module->pool, &module->ht_types, 4096);
505 +#ifdef __x86_64__
506 + hash_table_init(&module->pool, &module->ht_symaddr, 4096);
507 +#endif
508 vector_init(&module->vtypes, sizeof(struct symt*), 32);
509
510 module->sources_used = 0;
511 @@ -346,9 +352,11 @@ BOOL module_get_debug(struct module_pair
512 if (pair->effective->is_virtual) ret = FALSE;
513 else switch (pair->effective->type)
514 {
515 +#ifndef DBGHELP_STATIC_LIB
516 case DMT_ELF:
517 ret = elf_load_debug_info(pair->effective);
518 break;
519 +#endif
520 case DMT_PE:
521 idslW64.SizeOfStruct = sizeof(idslW64);
522 idslW64.BaseOfImage = pair->effective->module.BaseOfImage;
523 @@ -365,9 +373,11 @@ BOOL module_get_debug(struct module_pair
524 ret ? CBA_DEFERRED_SYMBOL_LOAD_COMPLETE : CBA_DEFERRED_SYMBOL_LOAD_FAILURE,
525 &idslW64);
526 break;
527 +#ifndef DBGHELP_STATIC_LIB
528 case DMT_MACHO:
529 ret = macho_load_debug_info(pair->effective, NULL);
530 break;
531 +#endif
532 default:
533 ret = FALSE;
534 break;
535 @@ -506,11 +516,13 @@ enum module_type module_get_type_by_name
536 /******************************************************************
537 * refresh_module_list
538 */
539 +#ifndef DBGHELP_STATIC_LIB
540 static BOOL refresh_module_list(struct process* pcs)
541 {
542 /* force transparent ELF and Mach-O loading / unloading */
543 return elf_synchronize_module_list(pcs) || macho_synchronize_module_list(pcs);
544 }
545 +#endif
546
547 /***********************************************************************
548 * SymLoadModule (DBGHELP.@)
549 @@ -594,7 +606,9 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE
550 if (Flags & ~(SLMFLAG_VIRTUAL))
551 FIXME("Unsupported Flags %08x for %s\n", Flags, debugstr_w(wImageName));
552
553 +#ifndef DBGHELP_STATIC_LIB
554 refresh_module_list(pcs);
555 +#endif
556
557 /* this is a Wine extension to the API just to redo the synchronisation */
558 if (!wImageName && !hFile) return 0;
559 @@ -618,6 +632,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE
560 wImageName)
561 {
562 /* and finally an ELF or Mach-O module */
563 +#ifndef DBGHELP_STATIC_LIB
564 switch (module_get_type_by_name(wImageName))
565 {
566 case DMT_ELF:
567 @@ -630,6 +645,7 @@ DWORD64 WINAPI SymLoadModuleExW(HANDLE
568 /* Ignored */
569 break;
570 }
571 +#endif
572 }
573 }
574 if (!module)
575 @@ -819,6 +835,7 @@ BOOL WINAPI SymEnumerateModulesW64(HAND
576 return TRUE;
577 }
578
579 +#ifndef DBGHELP_STATIC_LIB
580 /******************************************************************
581 * EnumerateLoadedModules64 (DBGHELP.@)
582 *
583 @@ -919,6 +936,7 @@ BOOL WINAPI EnumerateLoadedModulesW64(H
584
585 return sz != 0 && i == sz;
586 }
587 +#endif /* DBGHELP_STATIC_LIB */
588
589 /******************************************************************
590 * SymGetModuleInfo (DBGHELP.@)
591 @@ -1131,7 +1149,11 @@ BOOL WINAPI SymRefreshModuleList(HANDLE
592
593 if (!(pcs = process_find_by_handle(hProcess))) return FALSE;
594
595 +#ifndef DBGHELP_STATIC_LIB
596 return refresh_module_list(pcs);
597 +#else
598 + return TRUE;
599 +#endif
600 }
601
602 /***********************************************************************
603
604 diff -prudN e:\Wine\dlls\dbghelp/pe_module.c e:\reactos\dll\win32\dbghelp/pe_module.c
605 --- e:\Wine\dlls\dbghelp/pe_module.c 2012-04-02 20:39:57.755333700 +0100
606 +++ e:\reactos\dll\win32\dbghelp/pe_module.c 2013-07-31 14:07:19.229487000 +0100
607 @@ -31,8 +31,10 @@
608
609 #include "dbghelp_private.h"
610 #include "image_private.h"
611 +#ifndef DBGHELP_STATIC_LIB
612 #include "winternl.h"
613 #include "wine/debug.h"
614 +#endif
615
616 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
617
618 @@ -526,6 +528,7 @@ static BOOL pe_load_dwarf(struct module*
619 return ret;
620 }
621
622 +#ifndef DBGHELP_STATIC_LIB
623 /******************************************************************
624 * pe_load_dbg_file
625 *
626 @@ -625,6 +628,7 @@ done:
627 pe_unmap_full(fmap);
628 return ret;
629 }
630 +#endif /* DBGHELP_STATIC_LIB */
631
632 /***********************************************************************
633 * pe_load_export_debug_info
634 @@ -721,7 +725,9 @@ BOOL pe_load_debug_info(const struct pro
635 {
636 ret = pe_load_stabs(pcs, module);
637 ret = pe_load_dwarf(module) || ret;
638 + #ifndef DBGHELP_STATIC_LIB
639 ret = pe_load_msc_debug_info(pcs, module) || ret;
640 + #endif
641 ret = ret || pe_load_coff_symbol_table(module); /* FIXME */
642 /* if we still have no debug info (we could only get SymExport at this
643 * point), then do the SymExport except if we have an ELF container,
644
645 diff -prudN e:\Wine\dlls\dbghelp/source.c e:\reactos\dll\win32\dbghelp/source.c
646 --- e:\Wine\dlls\dbghelp/source.c 2011-09-16 23:22:36.198780400 +0100
647 +++ e:\reactos\dll\win32\dbghelp/source.c 2013-07-31 14:07:19.220481000 +0100
648 @@ -18,14 +18,17 @@
649 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
650 *
651 */
652 -#include "config.h"
653 -#include <stdlib.h>
654 -#include <stdio.h>
655 -#include <string.h>
656 +#include <config.h>
657 +//#include <stdlib.h>
658 +//#include <stdio.h>
659 +//#include <string.h>
660 #include <assert.h>
661
662 #include "dbghelp_private.h"
663 -#include "wine/debug.h"
664 +
665 +#ifndef DBGHELP_STATIC_LIB
666 +#include <wine/debug.h>
667 +#endif
668
669 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
670
671 diff -prudN e:\Wine\dlls\dbghelp/stabs.c e:\reactos\dll\win32\dbghelp/stabs.c
672 --- e:\Wine\dlls\dbghelp/stabs.c 2012-08-13 02:55:03.317206300 +0100
673 +++ e:\reactos\dll\win32\dbghelp/stabs.c 2013-07-31 14:07:19.210472800 +0100
674 @@ -29,41 +29,47 @@
675 * available (hopefully) from http://sources.redhat.com/gdb/onlinedocs
676 */
677
678 -#include "config.h"
679 -#include "wine/port.h"
680 +#include <config.h>
681 +//#include "wine/port.h"
682
683 -#include <sys/types.h>
684 -#include <fcntl.h>
685 +//#include <sys/types.h>
686 +//#include <fcntl.h>
687 #ifdef HAVE_SYS_STAT_H
688 # include <sys/stat.h>
689 #endif
690 #ifdef HAVE_SYS_MMAN_H
691 #include <sys/mman.h>
692 #endif
693 -#include <limits.h>
694 -#include <stdlib.h>
695 -#include <string.h>
696 +//#include <limits.h>
697 +//#include <stdlib.h>
698 +//#include <string.h>
699 #ifdef HAVE_UNISTD_H
700 # include <unistd.h>
701 #endif
702 -#include <stdio.h>
703 +//#include <stdio.h>
704 #include <assert.h>
705 -#include <stdarg.h>
706 +//#include <stdarg.h>
707
708 #ifdef HAVE_MACH_O_NLIST_H
709 # include <mach-o/nlist.h>
710 #endif
711
712 -#include "windef.h"
713 -#include "winbase.h"
714 -#include "winnls.h"
715 +//#include "windef.h"
716 +//#include "winbase.h"
717 +//#include "winnls.h"
718
719 #include "dbghelp_private.h"
720
721 -#include "wine/debug.h"
722 +#ifndef DBGHELP_STATIC_LIB
723 +#include <wine/debug.h>
724 +#endif
725
726 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp_stabs);
727
728 +#ifndef DBGHELP_STATIC_LIB
729 +#define strtoull _strtoui64
730 +#endif
731 +
732 /* Masks for n_type field */
733 #ifndef N_STAB
734 #define N_STAB 0xe0
735
736 diff -prudN e:\Wine\dlls\dbghelp/storage.c e:\reactos\dll\win32\dbghelp/storage.c
737 --- e:\Wine\dlls\dbghelp/storage.c 2011-09-16 23:22:36.199780500 +0100
738 +++ e:\reactos\dll\win32\dbghelp/storage.c 2013-07-31 14:07:19.203469700 +0100
739 @@ -23,7 +23,10 @@
740 #include "config.h"
741 #include <assert.h>
742 #include <stdlib.h>
743 +
744 +#ifndef DBGHELP_STATIC_LIB
745 #include "wine/debug.h"
746 +#endif
747
748 #include "dbghelp_private.h"
749 #ifdef USE_STATS
750
751 diff -prudN e:\Wine\dlls\dbghelp/symbol.c e:\reactos-dwarf\dll\win32\dbghelp/symbol.c
752 --- e:\Wine\dlls\dbghelp/symbol.c 2012-04-02 20:39:57.756333700 +0100
753 +++ e:\reactos\dll\win32\dbghelp/symbol.c 2013-09-01 11:31:20.334679400 +0100
754 @@ -31,9 +31,12 @@
755 #include <sys/types.h>
756 #include <assert.h>
757
758 -#include "wine/debug.h"
759 #include "dbghelp_private.h"
760 +
761 +#ifndef DBGHELP_STATIC_LIB
762 +#include "wine/debug.h"
763 #include "winnls.h"
764 +#endif
765
766 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);
767 WINE_DECLARE_DEBUG_CHANNEL(dbghelp_symt);
768 @@ -67,18 +70,39 @@ int symt_cmp_addr(const void* p1, const
769
770 DWORD symt_ptr2index(struct module* module, const struct symt* sym)
771 {
772 -#ifdef _WIN64
773 +#ifdef __x86_64__
774 const struct symt** c;
775 - int len = vector_length(&module->vsymt), i;
776 + int len = vector_length(&module->vsymt);
777 + struct hash_table_iter hti;
778 + void *ptr;
779 + struct symt_idx_to_ptr *idx_to_ptr;
780 + /* place enough storage on the stack to represent a pointer in %p form */
781 + char ptrbuf[3 + (sizeof(void *) * 2)];
782
783 - /* FIXME: this is inefficient */
784 - for (i = 0; i < len; i++)
785 - {
786 - if (*(struct symt**)vector_at(&module->vsymt, i) == sym)
787 - return i + 1;
788 + /* make a string representation of the pointer to use as a hash key */
789 + sprintf(ptrbuf, "%p", sym);
790 + hash_table_iter_init(&module->ht_symaddr, &hti, ptrbuf);
791 +
792 + /* try to find the pointer in our ht */
793 + while ((ptr = hash_table_iter_up(&hti))) {
794 + idx_to_ptr = GET_ENTRY(ptr, struct symt_idx_to_ptr, hash_elt);
795 + if (idx_to_ptr->sym == sym)
796 + return idx_to_ptr->idx;
797 }
798 +
799 /* not found */
800 + /* add the symbol to our symbol vector */
801 c = vector_add(&module->vsymt, &module->pool);
802 +
803 + /* add an idx to ptr mapping so we can find it again by address */
804 + if ((idx_to_ptr = pool_alloc(&module->pool, sizeof(*idx_to_ptr))))
805 + {
806 + idx_to_ptr->hash_elt.name = pool_strdup(&module->pool, ptrbuf);
807 + idx_to_ptr->sym = sym;
808 + idx_to_ptr->idx = len + 1;
809 + hash_table_add(&module->ht_symaddr, &idx_to_ptr->hash_elt);
810 + }
811 +
812 if (c) *c = sym;
813 return len + 1;
814 #else
815 @@ -88,7 +112,7 @@ DWORD symt_ptr2index(struct
816
817 struct symt* symt_index2ptr(struct module* module, DWORD id)
818 {
819 -#ifdef _WIN64
820 +#ifdef __x86_64__
821 if (!id-- || id >= vector_length(&module->vsymt)) return NULL;
822 return *(struct symt**)vector_at(&module->vsymt, id);
823 #else
824 diff -prudN e:\Wine\dlls\dbghelp/type.c e:\reactos\dll\win32\dbghelp/type.c
825 --- e:\Wine\dlls\dbghelp/type.c 2012-04-02 20:39:57.756333700 +0100
826 +++ e:\reactos\dll\win32\dbghelp/type.c 2013-07-31 14:07:19.197464100 +0100
827 @@ -29,10 +29,13 @@
828 #include <stdarg.h>
829 #include <assert.h>
830
831 +#ifndef DBGHELP_STATIC_LIB
832 #include "windef.h"
833 #include "winbase.h"
834 #include "winnls.h"
835 #include "wine/debug.h"
836 +#endif
837 +
838 #include "dbghelp_private.h"
839
840 WINE_DEFAULT_DEBUG_CHANNEL(dbghelp);