* [RFC]: Disallow ObjC search when resetting breakpoint.
@ 2003-10-17 4:02 Adam Fedor
2003-11-06 20:19 ` Elena Zannoni
0 siblings, 1 reply; 4+ messages in thread
From: Adam Fedor @ 2003-10-17 4:02 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1561 bytes --]
This patch fixes PR objc/1238, where you get frustrating behavior if
there is an ObjC method with the same name as a function:
(gdb) break init
[0] cancel
[1] all
[2] -[MyObject init] at gdb-objc-test.m:50
[3] -[NewObject init] at gdb-objc-test.m:18
[4] init at gdb-objc-test.m:62
> 4
Breakpoint 1 at 0x10001a40: file gdb-objc-test.m, line 62.
(gdb) run
Starting program:
/home/users/fedor/src/gstep/Tester/shared_debug_obj/gdb-objc-test
[0] cancel
[1] all
[2] -[MyObject init] at gdb-objc-test.m:50
[3] -[NewObject init] at gdb-objc-test.m:18
[4] init at gdb-objc-test.m:62
> 0
Error in re-setting breakpoint 1:
canceled
[Thread debugging using libthread_db enabled]
[New Thread 16384 (LWP 2249)]
[0] cancel
[1] all
[2] -[MyObject init] at gdb-objc-test.m:50
[3] -[NewObject init] at gdb-objc-test.m:18
[4] init at gdb-objc-test.m:62
>
[... on and on ad infinitum ...]
What happens is that every time you try to reset a breakpoint,
decode_line_1 gets called and we search through all the ObjC selectors
for a match to the breakpoint and there are always multiple matches to
"init".
I don't particularly like the solution (It's the way Apple does it,
although it might be for more reasons than this, e.g. there's no reason
to go through the ObjC selector search when resetting a breakpoint
anyway). I can't think of any other way to do it though, unless perhaps
there is some way to canonicalize the symbol name for the breakpoint -
so it's something like "gdb-objc-test.m:init", and not just "init" -
then you won't get multiple matches.
Any comments?
[-- Attachment #2: allow_objc.patch --]
[-- Type: text/plain, Size: 1913 bytes --]
2003-10-16 Adam Fedor <fedor@gnu.org>
* gdb/linespec.c (decode_line_1): Search for ObjC selectors
only if allow_objc_selectors_flag.
* gdb/breakpoint.c (breakpoint_re_set_one): Don't allow search
for ObjC selectors when resetting a breakpoint.
Index: gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.132
diff -u -p -r1.132 breakpoint.c
--- gdb/breakpoint.c 13 Oct 2003 23:53:20 -0000 1.132
+++ gdb/breakpoint.c 17 Oct 2003 03:41:32 -0000
@@ -52,6 +52,8 @@
#include "gdb-events.h"
+extern int allow_objc_selectors_flag;
+
/* Prototypes for local functions. */
static void until_break_command_continuation (struct continuation_arg *arg);
@@ -6854,7 +6856,9 @@ breakpoint_re_set_one (void *bint)
set_language (b->language);
input_radix = b->input_radix;
s = b->addr_string;
+ allow_objc_selectors_flag = 0;
sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, (char ***) NULL);
+ allow_objc_selectors_flag = 1;
for (i = 0; i < sals.nelts; i++)
{
resolve_sal_pc (&sals.sals[i]);
Index: gdb/linespec.c
===================================================================
RCS file: /cvs/src/src/gdb/linespec.c,v
retrieving revision 1.51
diff -u -p -r1.51 linespec.c
--- gdb/linespec.c 2 Aug 2003 03:59:40 -0000 1.51
+++ gdb/linespec.c 17 Oct 2003 03:41:34 -0000
@@ -36,6 +36,8 @@
#include "objc-lang.h"
#include "linespec.h"
+int allow_objc_selectors_flag = 1;
+
/* We share this one with symtab.c, but it is not exported widely. */
extern char *operator_chars (char *, char **);
@@ -698,6 +700,7 @@ decode_line_1 (char **argptr, int funfir
/* Check if the symbol could be an Objective-C selector. */
+ if (allow_objc_selectors_flag)
{
struct symtabs_and_lines values;
values = decode_objc (argptr, funfirstline, NULL,
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC]: Disallow ObjC search when resetting breakpoint.
2003-10-17 4:02 [RFC]: Disallow ObjC search when resetting breakpoint Adam Fedor
@ 2003-11-06 20:19 ` Elena Zannoni
2003-11-06 20:27 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Elena Zannoni @ 2003-11-06 20:19 UTC (permalink / raw)
To: Adam Fedor; +Cc: gdb-patches
Adam Fedor writes:
> This patch fixes PR objc/1238, where you get frustrating behavior if
> there is an ObjC method with the same name as a function:
>
> (gdb) break init
> [0] cancel
> [1] all
> [2] -[MyObject init] at gdb-objc-test.m:50
> [3] -[NewObject init] at gdb-objc-test.m:18
> [4] init at gdb-objc-test.m:62
> > 4
> Breakpoint 1 at 0x10001a40: file gdb-objc-test.m, line 62.
> (gdb) run
> Starting program:
> /home/users/fedor/src/gstep/Tester/shared_debug_obj/gdb-objc-test
> [0] cancel
> [1] all
> [2] -[MyObject init] at gdb-objc-test.m:50
> [3] -[NewObject init] at gdb-objc-test.m:18
> [4] init at gdb-objc-test.m:62
> > 0
> Error in re-setting breakpoint 1:
> canceled
> [Thread debugging using libthread_db enabled]
> [New Thread 16384 (LWP 2249)]
> [0] cancel
> [1] all
> [2] -[MyObject init] at gdb-objc-test.m:50
> [3] -[NewObject init] at gdb-objc-test.m:18
> [4] init at gdb-objc-test.m:62
> >
> [... on and on ad infinitum ...]
>
> What happens is that every time you try to reset a breakpoint,
> decode_line_1 gets called and we search through all the ObjC selectors
> for a match to the breakpoint and there are always multiple matches to
> "init".
>
> I don't particularly like the solution (It's the way Apple does it,
> although it might be for more reasons than this, e.g. there's no reason
> to go through the ObjC selector search when resetting a breakpoint
> anyway). I can't think of any other way to do it though, unless perhaps
> there is some way to canonicalize the symbol name for the breakpoint -
> so it's something like "gdb-objc-test.m:init", and not just "init" -
> then you won't get multiple matches.
>
> Any comments?
>
>
> 2003-10-16 Adam Fedor <fedor@gnu.org>
>
> * gdb/linespec.c (decode_line_1): Search for ObjC selectors
> only if allow_objc_selectors_flag.
> * gdb/breakpoint.c (breakpoint_re_set_one): Don't allow search
> for ObjC selectors when resetting a breakpoint.
>
> Index: gdb/breakpoint.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/breakpoint.c,v
> retrieving revision 1.132
> diff -u -p -r1.132 breakpoint.c
> --- gdb/breakpoint.c 13 Oct 2003 23:53:20 -0000 1.132
> +++ gdb/breakpoint.c 17 Oct 2003 03:41:32 -0000
> @@ -52,6 +52,8 @@
>
> #include "gdb-events.h"
>
> +extern int allow_objc_selectors_flag;
> +
> /* Prototypes for local functions. */
>
> static void until_break_command_continuation (struct continuation_arg *arg);
> @@ -6854,7 +6856,9 @@ breakpoint_re_set_one (void *bint)
> set_language (b->language);
> input_radix = b->input_radix;
> s = b->addr_string;
> + allow_objc_selectors_flag = 0;
> sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, (char ***) NULL);
> + allow_objc_selectors_flag = 1;
> for (i = 0; i < sals.nelts; i++)
> {
> resolve_sal_pc (&sals.sals[i]);
> Index: gdb/linespec.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/linespec.c,v
> retrieving revision 1.51
> diff -u -p -r1.51 linespec.c
> --- gdb/linespec.c 2 Aug 2003 03:59:40 -0000 1.51
> +++ gdb/linespec.c 17 Oct 2003 03:41:34 -0000
> @@ -36,6 +36,8 @@
> #include "objc-lang.h"
> #include "linespec.h"
>
> +int allow_objc_selectors_flag = 1;
> +
> /* We share this one with symtab.c, but it is not exported widely. */
>
> extern char *operator_chars (char *, char **);
> @@ -698,6 +700,7 @@ decode_line_1 (char **argptr, int funfir
>
> /* Check if the symbol could be an Objective-C selector. */
>
> + if (allow_objc_selectors_flag)
> {
> struct symtabs_and_lines values;
> values = decode_objc (argptr, funfirstline, NULL,
Hmm, not sure about this. Maybe it is the code that follows your new
'if' in decode_line_1 that should be changed. Definitely saving more
info in the breakpoints would be helpful.
Question: how does this work for overloaded functions in c++?
decode_line_1 calls decode_compounds, which calls find_method, which
calls decode_line_2, which asks the user. I would think a similar
problem arises there. If not, then can we make objc do the same thing
that c++ does?
elena
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC]: Disallow ObjC search when resetting breakpoint.
2003-11-06 20:19 ` Elena Zannoni
@ 2003-11-06 20:27 ` Daniel Jacobowitz
2003-11-06 21:03 ` Elena Zannoni
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2003-11-06 20:27 UTC (permalink / raw)
To: gdb-patches
On Thu, Nov 06, 2003 at 03:19:42PM -0500, Elena Zannoni wrote:
> Hmm, not sure about this. Maybe it is the code that follows your new
> 'if' in decode_line_1 that should be changed. Definitely saving more
> info in the breakpoints would be helpful.
>
> Question: how does this work for overloaded functions in c++?
> decode_line_1 calls decode_compounds, which calls find_method, which
> calls decode_line_2, which asks the user. I would think a similar
> problem arises there. If not, then can we make objc do the same thing
> that c++ does?
For C++, the problem doesn't arise. I think that ObjC's problem is
that one of the options is the same as the ambiguous form; C++ can
always generate a description of which overloaded function is meant.
Well, except when it can't.
I have some ideas on how to address this, but I haven't even created
the branch for it yet :)
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC]: Disallow ObjC search when resetting breakpoint.
2003-11-06 20:27 ` Daniel Jacobowitz
@ 2003-11-06 21:03 ` Elena Zannoni
0 siblings, 0 replies; 4+ messages in thread
From: Elena Zannoni @ 2003-11-06 21:03 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
Daniel Jacobowitz writes:
> On Thu, Nov 06, 2003 at 03:19:42PM -0500, Elena Zannoni wrote:
> > Hmm, not sure about this. Maybe it is the code that follows your new
> > 'if' in decode_line_1 that should be changed. Definitely saving more
> > info in the breakpoints would be helpful.
> >
> > Question: how does this work for overloaded functions in c++?
> > decode_line_1 calls decode_compounds, which calls find_method, which
> > calls decode_line_2, which asks the user. I would think a similar
> > problem arises there. If not, then can we make objc do the same thing
> > that c++ does?
>
> For C++, the problem doesn't arise. I think that ObjC's problem is
> that one of the options is the same as the ambiguous form; C++ can
> always generate a description of which overloaded function is meant.
> Well, except when it can't.
>
ah, right.
> I have some ideas on how to address this, but I haven't even created
> the branch for it yet :)
>
Ok I was hoping you'd say that! :-)
Let's wait then on this.
elena
> --
> Daniel Jacobowitz
> MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-11-06 21:03 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-10-17 4:02 [RFC]: Disallow ObjC search when resetting breakpoint Adam Fedor
2003-11-06 20:19 ` Elena Zannoni
2003-11-06 20:27 ` Daniel Jacobowitz
2003-11-06 21:03 ` Elena Zannoni
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox