From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22524 invoked by alias); 11 Feb 2009 19:07:45 -0000 Received: (qmail 22515 invoked by uid 22791); 11 Feb 2009 19:07:44 -0000 X-SWARE-Spam-Status: No, hits=1.0 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,SPF_NEUTRAL X-Spam-Check-By: sourceware.org Received: from honeysuckle.london.02.net (HELO honeysuckle.london.02.net) (87.194.255.144) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 Feb 2009 19:07:37 +0000 Received: from Unknown-00-00-00-60-23-cc.config (87.194.37.195) by honeysuckle.london.02.net (8.5.016.1) id 497A2AF0003D977D; Wed, 11 Feb 2009 19:07:35 +0000 Date: Wed, 11 Feb 2009 19:07:00 -0000 From: Karen Osmond Reply-To: karen.osmond@gmail.com To: gdb-patches@sourceware.org Subject: [patch] not able to set pending breakpoint at qualified C++ function names Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-IsSubscribed: yes 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: 2009-02/txt/msg00241.txt.bz2 Hello, I noticed that it's not possible to set a pending breakpoint of the (C++) form "break X::Y::Z" (with breakpoint pending auto, gdb doesn't ask, and with it on, no breakpoint is added). It works fine with "break Q" or to whatever the equivalent of X::Y::Z is in terms of filename and linenumber. Patch follows; I've only just met the gdb source so make of it what you will :) * Added not_found_ptr param to decode_compound, find_method and throw NOT_FOUND_ERROR to bring them in line with symtab_from_filename, decode_variable. * Removed cplusplus_error helper function, as these were the only uses. (Though, it was adding an extra hint to the error, which perhaps should still happen. Erm, I must admit to not understanding the hint). cheers, -karen. Index: gdb/linespec.c =================================================================== RCS file: /cvs/src/src/gdb/linespec.c,v retrieving revision 1.84 diff -c -p -r1.84 linespec.c *** gdb/linespec.c 3 Jan 2009 05:57:52 -0000 1.84 --- gdb/linespec.c 11 Feb 2009 18:09:12 -0000 *************** static struct symtabs_and_lines decode_c *** 65,71 **** int funfirstline, char ***canonical, char *saved_arg, ! char *p); static struct symbol *lookup_prefix_sym (char **argptr, char *p); --- 65,72 ---- int funfirstline, char ***canonical, char *saved_arg, ! char *p, ! int *not_found_ptr); static struct symbol *lookup_prefix_sym (char **argptr, char *p); *************** static struct symtabs_and_lines find_met *** 74,89 **** char *saved_arg, char *copy, struct type *t, ! struct symbol *sym_class); static int collect_methods (char *copy, struct type *t, struct symbol *sym_class, struct symbol **sym_arr); - static NORETURN void cplusplus_error (const char *name, - const char *fmt, ...) - ATTR_NORETURN ATTR_FORMAT (printf, 2, 3); - static int total_number_of_methods (struct type *type); static int find_methods (struct type *, char *, --- 75,87 ---- char *saved_arg, char *copy, struct type *t, ! struct symbol *sym_class, ! int *not_found_ptr); static int collect_methods (char *copy, struct type *t, struct symbol *sym_class, struct symbol **sym_arr); static int total_number_of_methods (struct type *type); static int find_methods (struct type *, char *, *************** symtabs_and_lines minsym_found (int funf *** 144,176 **** /* Helper functions. */ - /* Issue a helpful hint on using the command completion feature on - single quoted demangled C++ symbols as part of the completion - error. */ - - static NORETURN void - cplusplus_error (const char *name, const char *fmt, ...) - { - struct ui_file *tmp_stream; - tmp_stream = mem_fileopen (); - make_cleanup_ui_file_delete (tmp_stream); - - { - va_list args; - va_start (args, fmt); - vfprintf_unfiltered (tmp_stream, fmt, args); - va_end (args); - } - - while (*name == '\'') - name++; - fprintf_unfiltered (tmp_stream, - ("Hint: try '%s or '%s\n" - "(Note leading single quote.)"), - name, name); - error_stream (tmp_stream); - } - /* Return the number of methods described for TYPE, including the methods from types it derives from. This can't be done in the symbol reader because the type of the baseclass might still be stubbed --- 142,147 ---- *************** decode_line_1 (char **argptr, int funfir *** 765,771 **** if (p[0] == '.' || p[1] == ':') return decode_compound (argptr, funfirstline, canonical, ! saved_arg, p); /* No, the first part is a filename; set file_symtab to be that file's symtab. Also, move argptr past the filename. */ --- 736,742 ---- if (p[0] == '.' || p[1] == ':') return decode_compound (argptr, funfirstline, canonical, ! saved_arg, p, not_found_ptr); /* No, the first part is a filename; set file_symtab to be that file's symtab. Also, move argptr past the filename. */ *************** decode_objc (char **argptr, int funfirst *** 1195,1201 **** static struct symtabs_and_lines decode_compound (char **argptr, int funfirstline, char ***canonical, ! char *saved_arg, char *p) { struct symtabs_and_lines values; char *p2; --- 1166,1172 ---- static struct symtabs_and_lines decode_compound (char **argptr, int funfirstline, char ***canonical, ! char *saved_arg, char *p, int* not_found_ptr) { struct symtabs_and_lines values; char *p2; *************** decode_compound (char **argptr, int funf *** 1362,1368 **** we'll lookup the whole string in the symbol tables. */ return find_method (funfirstline, canonical, saved_arg, ! copy, t, sym_class); } /* End if symbol found */ --- 1333,1339 ---- we'll lookup the whole string in the symbol tables. */ return find_method (funfirstline, canonical, saved_arg, ! copy, t, sym_class, not_found_ptr); } /* End if symbol found */ *************** decode_compound (char **argptr, int funf *** 1385,1392 **** /* Couldn't find any interpretation as classes/namespaces, so give up. The quotes are important if copy is empty. */ ! cplusplus_error (saved_arg, ! "Can't find member of namespace, class, struct, or union named \"%s\"\n", copy); } --- 1356,1365 ---- /* Couldn't find any interpretation as classes/namespaces, so give up. The quotes are important if copy is empty. */ ! if (not_found_ptr) ! *not_found_ptr = 1; ! throw_error (NOT_FOUND_ERROR, ! _("Can't find member of namespace, class, struct, or union named \"%s\""), copy); } *************** lookup_prefix_sym (char **argptr, char * *** 1430,1436 **** static struct symtabs_and_lines find_method (int funfirstline, char ***canonical, char *saved_arg, ! char *copy, struct type *t, struct symbol *sym_class) { struct symtabs_and_lines values; struct symbol *sym = NULL; --- 1403,1409 ---- static struct symtabs_and_lines find_method (int funfirstline, char ***canonical, char *saved_arg, ! char *copy, struct type *t, struct symbol *sym_class, int *not_found_ptr) { struct symtabs_and_lines values; struct symbol *sym = NULL; *************** find_method (int funfirstline, char ***c *** 1481,1493 **** } else tmp = copy; if (tmp[0] == '~') ! cplusplus_error (saved_arg, ! "the class `%s' does not have destructor defined\n", SYMBOL_PRINT_NAME (sym_class)); else ! cplusplus_error (saved_arg, ! "the class %s does not have any method named %s\n", SYMBOL_PRINT_NAME (sym_class), tmp); } } --- 1454,1468 ---- } else tmp = copy; + if (not_found_ptr) + *not_found_ptr = 1; if (tmp[0] == '~') ! throw_error (NOT_FOUND_ERROR, ! _("the class `%s' does not have destructor defined"), SYMBOL_PRINT_NAME (sym_class)); else ! throw_error (NOT_FOUND_ERROR, ! _("the class %s does not have any method named %s"), SYMBOL_PRINT_NAME (sym_class), tmp); } }