delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/03/01/22:59:14

Message-ID: <38BD9731.80042FBD@caresystems.com.au>
Date: Thu, 02 Mar 2000 08:18:25 +1000
From: leon <Leon AT caresystems DOT com DOT au>
X-Mailer: Mozilla 4.7 [en] (Win95; I)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: gdb problem or just silly me - please help
References: <20000226 DOT 001348 DOT -398121 DOT 2 DOT roberts DOT j DOT whitlock AT juno DOT com> <38B927C8 DOT EE0D58ED AT bigfoot DOT com> <38BB597F DOT 22B13248 AT caresystems DOT com DOT au> <83u2is4gax DOT fsf AT mercury DOT st DOT hmc DOT edu>
Reply-To: djgpp AT delorie DOT com

	Hello i have rather strange thing when trying to debug with gdb.

	First of all: i have a source file (eg test.cpp) which has main method
(ala int main()) I also use a class. 
	But this class is a template class. 
	Somewhere i read that having a source file for template class does not
really contain much logic - since templates are compiled at the
implementation level (ie that is why one needs to include the
definitions of template classes, not just declarations of those when
used) so compiling an object representing a template class (eg
template.cpp) will not do much good for linking at all. 
	As the result of such an approach - i have included definitions in the
header file of the template class ie:
class <T> 
SomeClass
{
	SomeClass();
	~SomeClass();
};
template <class T>
SomeClass<T>::SomeClass()
{
}
template <class T>
SomeClass<T>::~SomeClass()
{
}

	Now to the question at hand:
	I run gdb and put a breakpoint that is somewhere in the method of a
template class
	(eg SomeClass<int>::Go - provided of course that there is method Go,
etc.)
	So far so good.
	I run the program and it hits a breakpoint. I then type "l" (for
listing of source code around break point). Then it says that the line
number of a breakpoint is out of range with the length of file test.cpp
(the one containing entry method int main()). In other words gdb reports
a breakpoint to be at line say 175 while the total lines it test.cpp is
35 (because header file of template is included in test.cpp?)
	HUH?
	The problem is that i cannot specify a source file to put a breakpoint
in since there is no source file for template class (its header is
included in test.cpp of course).
	Any solutions at all?!
	With best regards - Leon.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019