unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Breakpoints in C++ templates
@ 2007-11-14  9:19 Nick Roberts
  0 siblings, 0 replies; only message in thread
From: Nick Roberts @ 2007-11-14  9:19 UTC (permalink / raw)
  To: Frank Schmitt; +Cc: Emacs developers


On Thu, 19 Oct 2006 13:46:35 +0200, Frank Schmitt wrote:

> First for those who have no idea about what we are talking about: In C++
> you can write something like
> 
> -----------------------------------------------------------------------------
> template <typename imgtype1, typename imgtype2>
> void doSomething(imgtype1* img1, imgtype2* img2){
>   //do something with image img1 and image img2 which can both be either
>   //8 or 16 bits per pixel
> }
> 
> int main(){
>   unsigned char* image1 = getRawImageData1();
>   int bpp1 = getBitsPerPixel1();
>   unsigned char* image2 = getRawImageData2():
>   int bpp2 = getBitsPerPixel2();
>   if (bpp1==8 && bpp2==8)
>      doSomething<unsigned char, unsigned char>(image1, image2);
>   if (bpp1==8 && bpp2==16)
>      doSomething<unsigned char, unsigned short>(image1, (unsigned short*)image2);
>   if (bpp1==16 && bpp2==8)
>      doSomething<unsigned short, unsigned char>((unsigned short*)image1, image2);
>   if (bpp1==16 && bpp2==16)
>      doSomething<unsigned short, unsigned short>((unsigned short*)image1, (unsigned short*)image2);
> }
> -----------------------------------------------------------------------------

> If you compile this, four instances of the function doSomething are
> generated, in each imgtype1 and imgtype2 is substituted with a real data
> type. If you now start the program in gdb and say "break doSomething",
> the breakpoint will always be set at the first instance of the function
> which gdb finds. If this isn't the instance your program is just using,
> you can't debug the function. (Ok, there are some tricks, but even if
> you managed to set the breakpoint correctly there's still reakage in
> e.g. "until".)

GDB now handles these breakpoints correctly and the breakpoints buffer
in Emacs' Graphical Interface should also work with this new code.  Could
you please test these two programs and send feedback to the appropriate
mailing list?  You will need a recent checkout from the CVS repositories
of both GDB and Emacs.

> If gdb had a leader who said "we don't ship broken code", gdb developers
> would be at annoyed because their favorite new feature of which they are
> proud and fond isn't released to the public and would eventually sit
> down and fix it, just as it happens in Emacs.

Yes, and all without the need for such a leader.

-- 
Nick                                           http://www.inet.net.nz/~nickrob

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-11-14  9:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-14  9:19 Breakpoints in C++ templates Nick Roberts

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).