From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15203 invoked by alias); 29 Jun 2012 22:49:03 -0000 Received: (qmail 15182 invoked by uid 22791); 29 Jun 2012 22:49:00 -0000 X-SWARE-Spam-Status: No, hits=-4.1 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,KHOP_RCVD_TRUST,RCVD_IN_DNSWL_LOW,RCVD_IN_HOSTKARMA_YE,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail-gh0-f201.google.com (HELO mail-gh0-f201.google.com) (209.85.160.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 29 Jun 2012 22:48:45 +0000 Received: by ghbg15 with SMTP id g15so437483ghb.0 for ; Fri, 29 Jun 2012 15:48:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:cc:subject:message-id:date:from:x-gm-message-state; bh=d7LRRWq0el4WF4O8s/LExFs5RzPYGoJwZvuVlh5x0zM=; b=kNgRxUFrfGas21e7mzBitUt9wdWdiOyBVjj0DlIYrt5do1zFkPlhRyrJz5zEvhlDVy 99GviY1RNGzKH5H+aTEGt8UXwsfibtQ5CF5+K+g5P/io0BtZ5lrC6YAFmR7Ykt41n57d MzlNXlaDKlYS7aFh8mWnqv+lsiIkqnTgR4eEFaXcUxQP229WHuDXNvMHNlaELXhmFw3d bAsBbIBg7EvOb1ZvE0cR90pfRcHuJYmMiOtuQy1IM8ffEe8hz9CFZ2tKMNs1oef+LHm5 LzPaPZVciTIuFzb9bceQ7ZcoNs5xLidNIlr/wwRcwDO3+pG/Irb7mDJY8yC/Y3LfJC5s Opuw== Received: by 10.101.179.36 with SMTP id g36mr1636637anp.2.1341010124554; Fri, 29 Jun 2012 15:48:44 -0700 (PDT) Received: by 10.101.179.36 with SMTP id g36mr1636631anp.2.1341010124472; Fri, 29 Jun 2012 15:48:44 -0700 (PDT) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id q35si1337659yhe.6.2012.06.29.15.48.44 (version=TLSv1/SSLv3 cipher=AES128-SHA); Fri, 29 Jun 2012 15:48:44 -0700 (PDT) Received: from ruffy2.mtv.corp.google.com (ruffy2.mtv.corp.google.com [172.18.110.129]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 406E41E0043; Fri, 29 Jun 2012 15:48:44 -0700 (PDT) Received: by ruffy2.mtv.corp.google.com (Postfix, from userid 67641) id E4B971E1259; Fri, 29 Jun 2012 15:48:43 -0700 (PDT) To: gdb-patches@sourceware.org cc: tromey@redhat.com Subject: Re: [RFA] decode_line_spec_* cleanup Message-Id: <20120629224843.E4B971E1259@ruffy2.mtv.corp.google.com> Date: Fri, 29 Jun 2012 22:49:00 -0000 From: dje@google.com (Doug Evans) X-Gm-Message-State: ALoCoQn8HgMBqHsqTPNoybI1B6h59VrHqVkNi/9qTqmY+swYAKljPeJHf2ttnHAhXSi33LBqSGE51XBZfIxA8YFGryoRMniMNLuPn6JjGp/Fw+qz0Ff31POET/IlMIXBUEWIlLTFHKp9IADJo9vTkvctmKHf6Ge9/1gH5IKfMgOU7WfJIfEwagrPiEZFDsFXqFiB5kdmKmO8 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: 2012-06/txt/msg00875.txt.bz2 Hi. Tom approved this version in irc. Committed. 2012-06-29 Doug Evans * linespec.c: #include "stack.h". (decode_line_with_current_source): Moved here from symtab.c and renamed from decode_line_spec. All callers updated. (decode_line_with_last_displayed): Moved here from breakpoint.c and renamed from decode_line_spec_1. All callers updated. * linespec.h (decode_line_with_current_source): Move declaration here from symtab.h and renamed from decode_line_spec. (decode_line_with_last_displayed): Move declaration here from symtab.h and renamed from decode_line_spec_1. * macrocmd.c: #include "linespec.h". * symtab.c: Remove #include "linespec.h". Index: breakpoint.c =================================================================== RCS file: /cvs/src/src/gdb/breakpoint.c,v retrieving revision 1.685 diff -u -p -r1.685 breakpoint.c --- breakpoint.c 27 Jun 2012 18:08:39 -0000 1.685 +++ breakpoint.c 29 Jun 2012 22:41:01 -0000 @@ -11532,8 +11532,9 @@ clear_command (char *arg, int from_tty) if (arg) { - sals = decode_line_spec (arg, (DECODE_LINE_FUNFIRSTLINE - | DECODE_LINE_LIST_MODE)); + sals = decode_line_with_current_source (arg, + (DECODE_LINE_FUNFIRSTLINE + | DECODE_LINE_LIST_MODE)); default_match = 0; } else @@ -14494,27 +14495,6 @@ invalidate_bp_value_on_memory_change (CO } } -/* Use the last displayed codepoint's values, or nothing - if they aren't valid. */ - -struct symtabs_and_lines -decode_line_spec_1 (char *string, int flags) -{ - struct symtabs_and_lines sals; - - if (string == 0) - error (_("Empty line specification.")); - if (last_displayed_sal_is_valid ()) - sals = decode_line_1 (&string, flags, - get_last_displayed_symtab (), - get_last_displayed_line ()); - else - sals = decode_line_1 (&string, flags, (struct symtab *) NULL, 0); - if (*string) - error (_("Junk at end of line specification: %s"), string); - return sals; -} - /* Create and insert a raw software breakpoint at PC. Return an identifier, which should be used to remove the breakpoint later. In general, places which call this should be using something on the Index: infcmd.c =================================================================== RCS file: /cvs/src/src/gdb/infcmd.c,v retrieving revision 1.305 diff -u -p -r1.305 infcmd.c --- infcmd.c 12 Jun 2012 16:36:42 -0000 1.305 +++ infcmd.c 29 Jun 2012 22:41:02 -0000 @@ -1140,7 +1140,7 @@ jump_command (char *arg, int from_tty) if (!arg) error_no_arg (_("starting address")); - sals = decode_line_spec_1 (arg, DECODE_LINE_FUNFIRSTLINE); + sals = decode_line_with_last_displayed (arg, DECODE_LINE_FUNFIRSTLINE); if (sals.nelts != 1) { error (_("Unreasonable jump request")); Index: linespec.c =================================================================== RCS file: /cvs/src/src/gdb/linespec.c,v retrieving revision 1.158 diff -u -p -r1.158 linespec.c --- linespec.c 4 Jun 2012 02:57:28 -0000 1.158 +++ linespec.c 29 Jun 2012 22:41:02 -0000 @@ -43,6 +43,7 @@ #include "cli/cli-utils.h" #include "filenames.h" #include "ada-lang.h" +#include "stack.h" typedef struct symtab *symtab_p; DEF_VEC_P (symtab_p); @@ -2325,6 +2326,8 @@ decode_line_full (char **argptr, int fla do_cleanups (cleanups); } +/* See linespec.h. */ + struct symtabs_and_lines decode_line_1 (char **argptr, int flags, struct symtab *default_symtab, @@ -2345,6 +2348,51 @@ decode_line_1 (char **argptr, int flags, return result; } +/* See linespec.h. */ + +struct symtabs_and_lines +decode_line_with_current_source (char *string, int flags) +{ + struct symtabs_and_lines sals; + struct symtab_and_line cursal; + + if (string == 0) + error (_("Empty line specification.")); + + /* We use whatever is set as the current source line. We do not try + and get a default source symtab+line or it will recursively call us! */ + cursal = get_current_source_symtab_and_line (); + + sals = decode_line_1 (&string, flags, + cursal.symtab, cursal.line); + + if (*string) + error (_("Junk at end of line specification: %s"), string); + return sals; +} + +/* See linespec.h. */ + +struct symtabs_and_lines +decode_line_with_last_displayed (char *string, int flags) +{ + struct symtabs_and_lines sals; + + if (string == 0) + error (_("Empty line specification.")); + + if (last_displayed_sal_is_valid ()) + sals = decode_line_1 (&string, flags, + get_last_displayed_symtab (), + get_last_displayed_line ()); + else + sals = decode_line_1 (&string, flags, (struct symtab *) NULL, 0); + + if (*string) + error (_("Junk at end of line specification: %s"), string); + return sals; +} + /* First, some functions to initialize stuff at the beggining of the Index: linespec.h =================================================================== RCS file: /cvs/src/src/gdb/linespec.h,v retrieving revision 1.16 diff -u -p -r1.16 linespec.h --- linespec.h 4 Jan 2012 08:17:05 -0000 1.16 +++ linespec.h 29 Jun 2012 22:41:02 -0000 @@ -93,6 +93,8 @@ extern void destroy_linespec_result (str extern struct cleanup * make_cleanup_destroy_linespec_result (struct linespec_result *); +/* Decode a linespec using the provided default symtab and line. */ + extern struct symtabs_and_lines decode_line_1 (char **argptr, int flags, struct symtab *default_symtab, int default_line); @@ -139,4 +141,15 @@ extern void decode_line_full (char **arg const char *select_mode, const char *filter); +/* Given a string, return the line specified by it, using the current + source symtab and line as defaults. + This is for commands like "list" and "breakpoint". */ + +extern struct symtabs_and_lines decode_line_with_current_source (char *, int); + +/* Given a string, return the line specified by it, using the last displayed + codepoint's values as defaults, or nothing if they aren't valid. */ + +extern struct symtabs_and_lines decode_line_with_last_displayed (char *, int); + #endif /* defined (LINESPEC_H) */ Index: macrocmd.c =================================================================== RCS file: /cvs/src/src/gdb/macrocmd.c,v retrieving revision 1.28 diff -u -p -r1.28 macrocmd.c --- macrocmd.c 4 Jan 2012 08:17:06 -0000 1.28 +++ macrocmd.c 29 Jun 2012 22:41:02 -0000 @@ -26,6 +26,7 @@ #include "command.h" #include "gdbcmd.h" #include "gdb_string.h" +#include "linespec.h" /* The `macro' prefix command. */ @@ -282,7 +283,8 @@ info_macros_command (char *args, int fro ms = default_macro_scope (); else { - struct symtabs_and_lines sals = decode_line_spec (args, 0); + struct symtabs_and_lines sals = + decode_line_with_current_source (args, 0); if (sals.nelts) ms = sal_macro_scope (sals.sals[0]); Index: source.c =================================================================== RCS file: /cvs/src/src/gdb/source.c,v retrieving revision 1.135 diff -u -p -r1.135 source.c --- source.c 30 May 2012 03:42:21 -0000 1.135 +++ source.c 29 Jun 2012 22:41:02 -0000 @@ -243,7 +243,8 @@ select_source_symtab (struct symtab *s) if one exists. */ if (lookup_symbol (main_name (), 0, VAR_DOMAIN, 0)) { - sals = decode_line_spec (main_name (), DECODE_LINE_FUNFIRSTLINE); + sals = decode_line_with_current_source (main_name (), + DECODE_LINE_FUNFIRSTLINE); sal = sals.sals[0]; xfree (sals.sals); current_source_pspace = sal.pspace; @@ -1405,7 +1406,7 @@ line_info (char *arg, int from_tty) } else { - sals = decode_line_spec_1 (arg, DECODE_LINE_LIST_MODE); + sals = decode_line_with_last_displayed (arg, DECODE_LINE_LIST_MODE); dont_repeat (); } Index: stack.c =================================================================== RCS file: /cvs/src/src/gdb/stack.c,v retrieving revision 1.253 diff -u -p -r1.253 stack.c --- stack.c 18 May 2012 21:02:50 -0000 1.253 +++ stack.c 29 Jun 2012 22:41:02 -0000 @@ -2373,7 +2373,7 @@ func_command (char *arg, int from_tty) return; frame = parse_frame_specification ("0"); - sals = decode_line_spec (arg, DECODE_LINE_FUNFIRSTLINE); + sals = decode_line_with_current_source (arg, DECODE_LINE_FUNFIRSTLINE); cleanups = make_cleanup (xfree, sals.sals); func_bounds = (struct function_bounds *) xmalloc ( sizeof (struct function_bounds) * sals.nelts); Index: symtab.c =================================================================== RCS file: /cvs/src/src/gdb/symtab.c,v retrieving revision 1.315 diff -u -p -r1.315 symtab.c --- symtab.c 28 Jun 2012 18:56:52 -0000 1.315 +++ symtab.c 29 Jun 2012 22:41:02 -0000 @@ -33,7 +33,6 @@ #include "language.h" #include "demangle.h" #include "inferior.h" -#include "linespec.h" #include "source.h" #include "filenames.h" /* for FILENAME_CMP */ #include "objc-lang.h" @@ -4821,27 +4820,6 @@ skip_prologue_using_sal (struct gdbarch return prologue_sal.pc; } -struct symtabs_and_lines -decode_line_spec (char *string, int flags) -{ - struct symtabs_and_lines sals; - struct symtab_and_line cursal; - - if (string == 0) - error (_("Empty line specification.")); - - /* We use whatever is set as the current source line. We do not try - and get a default or it will recursively call us! */ - cursal = get_current_source_symtab_and_line (); - - sals = decode_line_1 (&string, flags, - cursal.symtab, cursal.line); - - if (*string) - error (_("Junk at end of line specification: %s"), string); - return sals; -} - /* Track MAIN */ static char *name_of_main; enum language language_of_main = language_unknown; Index: symtab.h =================================================================== RCS file: /cvs/src/src/gdb/symtab.h,v retrieving revision 1.209 diff -u -p -r1.209 symtab.h --- symtab.h 26 Jun 2012 20:14:02 -0000 1.209 +++ symtab.h 29 Jun 2012 22:41:02 -0000 @@ -1113,13 +1113,6 @@ extern int find_line_pc_range (struct sy extern void resolve_sal_pc (struct symtab_and_line *); -/* Given a string, return the line specified by it. For commands like "list" - and "breakpoint". */ - -extern struct symtabs_and_lines decode_line_spec (char *, int); - -extern struct symtabs_and_lines decode_line_spec_1 (char *, int); - /* Symmisc.c */ void maintenance_print_symbols (char *, int); Index: tracepoint.c =================================================================== RCS file: /cvs/src/src/gdb/tracepoint.c,v retrieving revision 1.259 diff -u -p -r1.259 tracepoint.c --- tracepoint.c 27 Jun 2012 18:08:40 -0000 1.259 +++ tracepoint.c 29 Jun 2012 22:41:02 -0000 @@ -2494,7 +2494,7 @@ trace_find_line_command (char *args, int } else { - sals = decode_line_spec (args, DECODE_LINE_FUNFIRSTLINE); + sals = decode_line_with_current_source (args, DECODE_LINE_FUNFIRSTLINE); sal = sals.sals[0]; } Index: mi/mi-main.c =================================================================== RCS file: /cvs/src/src/gdb/mi/mi-main.c,v retrieving revision 1.218 diff -u -p -r1.218 mi-main.c --- mi/mi-main.c 24 May 2012 16:51:38 -0000 1.218 +++ mi/mi-main.c 29 Jun 2012 22:41:02 -0000 @@ -2436,7 +2436,8 @@ mi_cmd_trace_find (char *command, char * if (argc != 2) error (_("Line is required")); - sals = decode_line_spec (argv[1], DECODE_LINE_FUNFIRSTLINE); + sals = decode_line_with_current_source (argv[1], + DECODE_LINE_FUNFIRSTLINE); back_to = make_cleanup (xfree, sals.sals); sal = sals.sals[0];