This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to debug those functions in a .h file


Hi,

> Hi all
> 	I meet a problem when using gdb. Suppose I have the following dir
> structure:
>        /project/include/myfun.h
>        /project/src/demo.c
>
> 	Under /project/src, after compile and link those 2 files, I get demo.o
> file. Then, I run
> 	gdb demo.o
> and go into the interface of gdb. I can break such functions in demo.c
> file but failed to break those in myfun.h unless I copy myfun.h under dir
> /project/src.
> It seems that gdb will only search the .h file in the current dir but not
> other dir. Then how can I debug the functions in /project/include/myfun.h
> without copying the file to current dir?


You could use the dir command .
The manual says and I quote .

`dir DIRNAME ...'
     Add directory DIRNAME to the front of the source path.  Several
     directory names may be given to this command, separated by `:'
     (`;' on MS-DOS and MS-Windows, where `:' usually appears as part
     of absolute file names) or whitespace.  You may specify a
     directory that is already in the source path; this moves it
     forward, so GDB searches it sooner.

     You can use the string `$cdir' to refer to the compilation
     directory (if one is recorded), and `$cwd' to refer to the current
     working directory.  `$cwd' is not the same as `.'--the former
     tracks the current working directory as it changes during your GDB
     session, while the latter is immediately expanded to the current
     directory at the time you add an entry to the source path.


 So set the directories for the source path and things should work .


cheers
Ramana
>
> 	Thanx.
>
> Aaron
>
> Intel China Software Lab
>
> Tel:  8621-52574545 Ext.1587
>
> E_mail:yukun.chen@intel.com
>
>


----
Ramana Radhakrishnan
Codito Technologies


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]