From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29295 invoked by alias); 18 Sep 2008 00:34:40 -0000 Received: (qmail 29287 invoked by uid 22791); 18 Sep 2008 00:34:40 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 18 Sep 2008 00:33:47 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 10E8B2A96AA; Wed, 17 Sep 2008 20:33:45 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id PdlqLA7ZWtFf; Wed, 17 Sep 2008 20:33:44 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 9CDA42A96A8; Wed, 17 Sep 2008 20:33:44 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 556F3E7ACD; Wed, 17 Sep 2008 17:33:42 -0700 (PDT) Date: Thu, 18 Sep 2008 00:34:00 -0000 From: Joel Brobecker To: "Pierre Muller (gmail)" Cc: gdb-patches@sourceware.org Subject: Re: [RFC] Allow overloaded general functions Message-ID: <20080918003342.GA3651@adacore.com> References: <47ed1b31.0af6660a.3ddc.ffffb9c5@mx.google.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <47ed1b31.0af6660a.3ddc.ffffb9c5@mx.google.com> User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-09/txt/msg00379.txt.bz2 On Fri, Mar 28, 2008 at 05:22:03PM +0100, Pierre Muller (gmail) wrote: > I tried to write a patch that allows to > set a breakpoint at each overloaded version of a procedure or function, > which is a fairly common feature in pascal language. Sorry for being so late in replying to this, but I was really REALLY hoping to look at the same sort of issue for Ada as well before answering. Bad luck, I have been so tied up that I never found the time. Nevertheless, I don't believe that Pascal and Ada are the only languages affected. Not sure how the C++ mode handles overloading in GDB, buti presumably, C++ should have the same issue - perhaps the user is expected to fully qualify his entity? I suggest you have a look at a patch I sent last January: http://www.sourceware.org/ml/gdb-patches/2008-01/msg00008.html The way we handle overloading is by creating several breakpoints that have only one location, as opposed to multiple-location breakpoints. Just like you. If creating several breakpoints is easier in the short term, I really think we should try to transition towards multiple-location breakpoint when we can. The problem, as you have found out, is when we re-evaluate each breakpoint we just created. Using your example: > [2] ADD at addstring.pp:16 > [3] ADD at addlongint.pp:17 > [4] ADD at addint.pp:17 Since you chose "all", you created 3 breakpoints. I'll number them 1, 2 and 3 in the order above. When you "run" your program, or when a new shared library is mapped, you need to re-evaluate each of them, meaning we need to verify that the actual address hasn't changed. If you do not add some kind of information in each breakpoint to say which instance it is refering to, then you'll never be able to determine that breakpoint 2 is at addlongint.pp:17. For Ada, we handled that issue by rewriting the breakpoint string into a canonical form that allows us to uniquely identify the location of each of them. From memory, it should look like this: addstring.pp:ADD:16 (or, said different in a general way: FILE:FUNCTION_NAME:LINE_NO). Feedback about this approach was not entirely enthousiastic, unfortunately, largely because I was using that form for Ada only, which was a divergence that Daniel wanted to avoid if possible. But also, when I proposed to see if that form could be generalized to all languages , Daniel pointed out: > I think the entire concept of a location specification which is both > canonical and user-inputable is on its last legs. If you want to > identify just one line of one homonym, what about one inlined instance > of that line? One instantiation in a particular shared library? > I've looked at the problem before but never got anywhere. This was part of a very small private discussion because I wasn't sure how bad Daniel was feeling about my patch. I was hoping to be able to look at this problem again in the near future, and since then nothing :-(. I can propose the following: We can look again at working from the Ada approach (and patch) and make it work for all languages instead of just Ada. We can use this canonical form, or any way we find convenient, to specify the breakpoint location. As Daniel points out, it won't cover all possible cases and a more powerful approach will eventually be needed if we want to support some of them. But in the meantime, we will be able to insert breakpoints on homonyms in both Pascal and Ada (and possibly C++) for the vast majority of cases. Daniel, what do you think? -- Joel