Robert Shearman a écrit :
Hi,
On startup, the debugger usually prompted me to type the path where "/winternl.h" can be found. This was due to the path being stored internally as "../../include/winternl.h", i.e. relative to the source directory. This patch adds the ability to store the source directory and then use it when encountering an include path of this type to get the full path, which means no more prompting.
Rob
Changelog: Store the current source directory and use it when encountering a relative include so that the full path to it is stored instead.
Robert, normally currpath is supposed to be the directory where the file has been compiled. So, IMO currpath and srcpath duplicate the same stuff.
Does it mean that you only get one N_SO per compilation unit ? (the code assumes two: the first one for the dir, the second for the path).
A+
Eric Pouech wrote:
Robert Shearman a écrit :
Hi,
On startup, the debugger usually prompted me to type the path where "/winternl.h" can be found. This was due to the path being stored internally as "../../include/winternl.h", i.e. relative to the source directory. This patch adds the ability to store the source directory and then use it when encountering an include path of this type to get the full path, which means no more prompting.
Rob
Changelog: Store the current source directory and use it when encountering a relative include so that the full path to it is stored instead.
Robert, normally currpath is supposed to be the directory where the file has been compiled. So, IMO currpath and srcpath duplicate the same stuff.
Does it mean that you only get one N_SO per compilation unit ? (the code assumes two: the first one for the dir, the second for the path).
[dm@rob dm]$ objdump -G /usr/local/lib/wine/dbghelp.dll.so | grep " SO " | more
0 SO 0 0 00015d9c 11 /home/dm/wine/dlls/dbghelp/ 1 SO 0 0 00015d9c 1 dbghelp.c 2204 SO 0 0 000163b9 0 2205 SO 0 0 000163bc 11 /home/dm/wine/dlls/dbghelp/ 2206 SO 0 0 000163bc 166272 elf_module.c 4978 SO 0 0 00017c24 0 4979 SO 0 0 00017c24 11 /home/dm/wine/dlls/dbghelp/ 4980 SO 0 0 00017c24 346388 image.c 6782 SO 0 0 00017cf6 0 ...
The real problem is the N_SOL entries, which is what the patch fixes:
[dm@rob dm]$ objdump -G /usr/local/lib/wine/dbghelp.dll.so | grep " SOL " | more 1917 SOL 0 0 00015ddf 35504 ../../include/winbase.h 1934 SOL 0 0 00015dec 1 dbghelp.c 1941 SOL 0 0 00015e16 35504 ../../include/winbase.h 1946 SOL 0 0 00015e56 1 dbghelp.c 2013 SOL 0 0 00015fc6 35504 ../../include/winbase.h 2016 SOL 0 0 00015fda 1 dbghelp.c 2020 SOL 0 0 00015ff1 35504 ../../include/winbase.h 2023 SOL 0 0 00016020 1 dbghelp.c ...
Rob
which means that: - we create a new compilation unit (for example) on 2205 => this gives the source directory - we start the main compilation unit on 2206 => /home/dm/wine/dlls/dbghelp/elf_module.c - in this CU, we start a new include file (on xxxx), => /home/dm/wine/dlls/dbghelp/../../include/winbase.h - ... - we close the CU on 4978 Basically, as I wrote, you don't need two different beasts: currpath and srcpath. They refer to the same object, but the code is wrong.
We should: - store the current directory on first SO (or the SO ended by a '/', which would be better) - on a non NULL SO, not ended by a '/' create a new compilation unit by concatening curr dir and the file name (or if file name is absolute, use the filename) - for each SOL, get the file name by concatening the curr dir with the file name (this operation is the same as above). - nuke the curr dir when getting a NULL SO
current code is wrong as it creates two compilands for each compilation unit (one for each non NULL SO)
A+
Eric Pouech wrote:
which means that:
- we create a new compilation unit (for example) on 2205 => this gives
the source directory
- we start the main compilation unit on 2206 =>
/home/dm/wine/dlls/dbghelp/elf_module.c
- in this CU, we start a new include file (on xxxx), =>
/home/dm/wine/dlls/dbghelp/../../include/winbase.h
- ...
- we close the CU on 4978
Basically, as I wrote, you don't need two different beasts: currpath and srcpath. They refer to the same object, but the code is wrong.
We should:
- store the current directory on first SO (or the SO ended by a '/',
which would be better)
- on a non NULL SO, not ended by a '/' create a new compilation unit
by concatening curr dir and the file name (or if file name is absolute, use the filename)
- for each SOL, get the file name by concatening the curr dir with the
file name (this operation is the same as above).
- nuke the curr dir when getting a NULL SO
current code is wrong as it creates two compilands for each compilation unit (one for each non NULL SO)
How does the attached patch look?
Rob
Index: wine/dlls/dbghelp/stabs.c =================================================================== RCS file: /home/wine/wine/dlls/dbghelp/stabs.c,v retrieving revision 1.8 diff -u -p -r1.8 stabs.c --- wine/dlls/dbghelp/stabs.c 23 Aug 2004 17:56:07 -0000 1.8 +++ wine/dlls/dbghelp/stabs.c 24 Aug 2004 17:33:07 -0000 @@ -1085,8 +1085,8 @@ SYM_TYPE stabs_parse(struct module* modu struct symt_function* curr_func = NULL; struct symt_block* block = NULL; struct symt_compiland* compiland = NULL; - char currpath[PATH_MAX]; - char srcpath[PATH_MAX]; + char currpath[PATH_MAX]; /* path to current file */ + char srcpath[PATH_MAX]; /* path to directory source file is in */ int i, j; int nstab; const char* ptr; @@ -1387,20 +1387,17 @@ SYM_TYPE stabs_parse(struct module* modu } else { - stabs_reset_includes(); - if (*ptr != '/') + int len = strlen(ptr); + if (ptr[len-1] != '/') { strcpy(currpath, srcpath); strcat(currpath, ptr); + stabs_reset_includes(); compiland = symt_new_compiland(module, currpath); source_idx = source_new(module, currpath); } else - { strcpy(srcpath, ptr); - compiland = symt_new_compiland(module, srcpath); - source_idx = source_new(module, srcpath); - } } break; case N_SOL:
Robert Shearman a écrit :
How does the attached patch look?
better, but you should to nuke srcpath (and no longer currpath) in N_SO case, when *ptr is '\0' (it's defensive code, so it shouldn't harm on normally formed stabs file). As a side effect, you don't need also to memset currpath to 0 at the beginning of func
A+
Eric Pouech wrote:
Robert Shearman a écrit :
How does the attached patch look?
better, but you should to nuke srcpath (and no longer currpath) in N_SO case, when *ptr is '\0' (it's defensive code, so it shouldn't harm on normally formed stabs file). As a side effect, you don't need also to memset currpath to 0 at the beginning of func
Is the attached patch correct?
Rob
Index: wine/dlls/dbghelp/stabs.c =================================================================== RCS file: /home/wine/wine/dlls/dbghelp/stabs.c,v retrieving revision 1.8 diff -u -p -r1.8 stabs.c --- wine/dlls/dbghelp/stabs.c 23 Aug 2004 17:56:07 -0000 1.8 +++ wine/dlls/dbghelp/stabs.c 24 Aug 2004 20:49:54 -0000 @@ -1085,8 +1085,8 @@ SYM_TYPE stabs_parse(struct module* modu struct symt_function* curr_func = NULL; struct symt_block* block = NULL; struct symt_compiland* compiland = NULL; - char currpath[PATH_MAX]; - char srcpath[PATH_MAX]; + char currpath[PATH_MAX]; /* path to current file */ + char srcpath[PATH_MAX]; /* path to directory source file is in */ int i, j; int nstab; const char* ptr; @@ -1108,7 +1108,6 @@ SYM_TYPE stabs_parse(struct module* modu stab_ptr = (const struct stab_nlist*)(addr + staboff); strs = (const char*)(addr + strtaboff);
- memset(currpath, 0, sizeof(currpath)); memset(srcpath, 0, sizeof(srcpath)); memset(stabs_basic, 0, sizeof(stabs_basic));
@@ -1377,7 +1376,7 @@ SYM_TYPE stabs_parse(struct module* modu if (*ptr == '\0') /* end of N_SO file */ { /* Nuke old path. */ - currpath[0] = '\0'; + srcpath[0] = '\0'; stabs_finalize_function(module, curr_func); curr_func = NULL; source_idx = -1; @@ -1387,20 +1386,17 @@ SYM_TYPE stabs_parse(struct module* modu } else { - stabs_reset_includes(); - if (*ptr != '/') + int len = strlen(ptr); + if (ptr[len-1] != '/') { strcpy(currpath, srcpath); strcat(currpath, ptr); + stabs_reset_includes(); compiland = symt_new_compiland(module, currpath); source_idx = source_new(module, currpath); } else - { strcpy(srcpath, ptr); - compiland = symt_new_compiland(module, srcpath); - source_idx = source_new(module, srcpath); - } } break; case N_SOL: