This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: How GDB looks for filenames/path?
- From: Dmitry Smirnov <divis1969 at mail dot ru>
- To: gdb at sourceware dot org
- Date: Mon, 04 Aug 2008 12:55:09 +0400
- Subject: Re: How GDB looks for filenames/path?
- References: <E1KG92Q-00004K-00.divis1969-mail-ru@f182.mail.ru>
- Reply-to: Dmitry Smirnov <divis1969 at mail dot ru>
Let me get back to this problem.
I've found that the issue with the path name occurs when dwarf2_start_subfile() (file dwarf2read.c) creates new subfile and corresponding symtabs.
Perhaps the exact problem is the DWARF info of the ELF file. ADS 1.2 (toolchain from Qualcomm) generated a directory list which contains a terminating backslash (like "dir1\\dir2\\") on Windows platform.
Thus, dwarf2_start_subfile() just concatenates the name (like file.c or file.h) with this path and a forward slash:
"dir1\\dir2\\/file.c"
Later, symtab for this subfile is used for line info search and this search is failed, of cource.
I've tried to fix this with the following code:
if( strlen(dirname) != 0 &&
IS_DIR_SEPARATOR(dirname[strlen(dirname)-1]) )
{
fullname = concat (dirname, filename, (char *)NULL);
}
else
{
fullname = concat (dirname, SLASH_STRING, filename, (char *)NULL);
}
This works fine, GDB is now able to find line info correctly.
BTW, I have to note that prior to this fix I've also used same method in dwarf_decode_lines() function which create similar psymtabs. This fix alone does not fix my problem, but probably both changes should be applied simultaneously.
Dmitry
-----Original Message-----
From: Dmitry Smirnov <divis1969@mail.ru>
To: gdb@sourceware.org
Date: Tue, 08 Jul 2008 12:59:06 +0400
Subject: How GDB looks for filenames/path?
>
> Hi,
>
> I'm trying to execute the program till some line and getting the following response from GDB (I'm using Eclipse a fron-end):
>
> 286-exec-until parb.c:343
> 286^error,msg="No line 343 in file \"drivers\\parb\\/parb.c\"."
>
> Previously, the source path was set as:
> 245-environment-directory C:/p4/views/myview
> 245^done,source-path="C:/p4/views/myview:$cdir:$cwd"
>
> Obviously, the problem is a forward slash "/parb.c". Or backslashes?
> Couple more examples that could help:
>
> 267-stack-list-frames 0 11
> 267^done,stack=[frame={level="0",addr="0x008c4a8e",func="ahb_bus_lock",file="drivers\\parb\\parb.c",line="333"} ...<cut>]
>
> 270-data-disassemble -f drivers\\parb\\parb.c -l 333 -n 100 -- 1
> 270^error,msg="mi_cmd_disassemble: Invalid filename."
> (gdb)
> 271-data-disassemble -s 0x8c4a8e -e 0x8c4af2 -- 0
> 271^done,asm_insns=[{address="0x008c4a8e",func-name="ahb_bus_lock",offset="2",inst="movs\tr4, #0"}...<cut>]
>
> The most weird thing is that GDB does not recognize the path drivers\\parb\\parb.c after it reported this file at the stack list.
>
> I'm debugging in Windows/Cygwin. My GDB is
> GNU gdb (GDB) 6.8.50.20080630
> This GDB was configured as "--host=i686-pc-cygwin --target=arm-elf".
>
> What function is doing lookup for a file path/name? I'm going to debug it...
>
> Dmitry
>