From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26387 invoked by alias); 28 Jun 2012 19:55:55 -0000 Received: (qmail 26374 invoked by uid 22791); 28 Jun 2012 19:55:53 -0000 X-SWARE-Spam-Status: No, hits=-4.4 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-wi0-f201.google.com (HELO mail-wi0-f201.google.com) (209.85.212.201) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 28 Jun 2012 19:55:39 +0000 Received: by wibhm2 with SMTP id hm2so22795wib.0 for ; Thu, 28 Jun 2012 12:55:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=to:subject:message-id:date:from:x-gm-message-state; bh=Qa5wNDwbwwID8Me83I2hr0mnxkJe/E6H1e+vu29WH5M=; b=C7ZsVN5rPBUvmgWxHdTGfVEEe9ByiAJ5vf9fgP/Cp9eg+kvFCC/gM0+tdjjvTA0lfE x4ChASr72LKgCqo/lcWMf15oIDkmQOGn5QoVGGeWCzUldhld33xGSrXaikgDYi8h6Ohy 4Vv4blLkywr2AVjWU5JT14RmQx+IOXDddwGKyNslg5qwvqfkIScMYqosSPHSyh7FfcQ7 eO9Ic3jk5NXVehM1iBFUzKoeLuy29rdJanZPV/Dj66g+nZ32gT9ILq6z8M7YRXGzDtJA q/OdAUVd0abBMU6WTZamqlFFWVEPAqDSCECfJwao7z+2ra5q2W6jwKLi9H5LTHk1yHXe jK/Q== Received: by 10.14.94.207 with SMTP id n55mr1276481eef.16.1340913338526; Thu, 28 Jun 2012 12:55:38 -0700 (PDT) Received: by 10.14.94.207 with SMTP id n55mr1276475eef.16.1340913338416; Thu, 28 Jun 2012 12:55:38 -0700 (PDT) Received: from hpza9.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id b15si192713een.0.2012.06.28.12.55.38 (version=TLSv1/SSLv3 cipher=AES128-SHA); Thu, 28 Jun 2012 12:55:38 -0700 (PDT) Received: from ruffy2.mtv.corp.google.com (ruffy2.mtv.corp.google.com [172.18.110.129]) by hpza9.eem.corp.google.com (Postfix) with ESMTP id DF8F75C0050 for ; Thu, 28 Jun 2012 12:55:37 -0700 (PDT) Received: by ruffy2.mtv.corp.google.com (Postfix, from userid 67641) id 3B6D01E13A1; Thu, 28 Jun 2012 12:55:37 -0700 (PDT) To: gdb-patches@sourceware.org Subject: [RFA] decode_line_spec_* cleanup Message-Id: <20120628195537.3B6D01E13A1@ruffy2.mtv.corp.google.com> Date: Thu, 28 Jun 2012 19:55:00 -0000 From: dje@google.com (Doug Evans) X-Gm-Message-State: ALoCoQlUcY8/9Xao4qXoC7ma9VO6DJDui5vQ3nX7LfZGTwYSlIQRh20lob2xHYqKwf+vidinqjyCTfGGDw7LimANjrc7N2xXYERyprn6l1f0wq7MfsXpQzj6AzU/7K81WSzWfkfWt3W4vPx78miw3OLbs6wo4hHm0BtYO5x3Bcv5SKB/Tw2mhmO3IXbb+0U6/n1ymC17i8CaBSrFHzT0T/k9fwAcgZmdCA== 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/msg00861.txt.bz2 Hi. First: Yes, I know these function names are really long :-). I'm not advocating doing this in general. I'm happy to change them, but decode_line_spec and decode_line_spec_1 just don't work for me. Ok to check in? 2012-06-28 Doug Evans * linespec.c: #include "stack.h". (decode_line_spec_with_current_source_as_default): Moved here from symtab.c and renamed from decode_line_spec. All callers updated. (decode_line_spec_with_last_displayed_as_default): Moved here from breakpoint.c and renamed from decode_line_spec_1. All callers updated. * linespec.h (decode_line_spec_with_current_source_as_default): Move declaration here from symtab.h and renamed from decode_line_spec. (decode_line_spec_with_last_displayed_as_default): 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 28 Jun 2012 19:46:35 -0000 @@ -11532,8 +11532,8 @@ clear_command (char *arg, int from_tty) if (arg) { - sals = decode_line_spec (arg, (DECODE_LINE_FUNFIRSTLINE - | DECODE_LINE_LIST_MODE)); + sals = decode_line_spec_with_current_source_as_default + (arg, DECODE_LINE_FUNFIRSTLINE | DECODE_LINE_LIST_MODE); default_match = 0; } else @@ -14494,27 +14494,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 28 Jun 2012 19:46:35 -0000 @@ -1140,7 +1140,8 @@ 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_spec_with_last_displayed_as_default + (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 28 Jun 2012 19:46:35 -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,49 @@ decode_line_1 (char **argptr, int flags, return result; } +/* See linespec.h. */ + +struct symtabs_and_lines +decode_line_spec_with_current_source_as_default (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; +} + +/* See linespec.h. */ + +struct symtabs_and_lines +decode_line_spec_with_last_displayed_as_default (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 28 Jun 2012 19:46:35 -0000 @@ -93,10 +93,25 @@ 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); +/* 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_spec_with_current_source_as_default (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_spec_with_last_displayed_as_default (char *, int); + /* Parse *ARGPTR as a linespec and return results. This is the "full" interface to this module, which handles multiple results properly. 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 28 Jun 2012 19:46:35 -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_spec_with_current_source_as_default (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 28 Jun 2012 19:46:35 -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_spec_with_current_source_as_default + (main_name (), DECODE_LINE_FUNFIRSTLINE); sal = sals.sals[0]; xfree (sals.sals); current_source_pspace = sal.pspace; @@ -1405,7 +1406,8 @@ line_info (char *arg, int from_tty) } else { - sals = decode_line_spec_1 (arg, DECODE_LINE_LIST_MODE); + sals = decode_line_spec_with_last_displayed_as_default + (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 28 Jun 2012 19:46:35 -0000 @@ -2373,7 +2373,8 @@ func_command (char *arg, int from_tty) return; frame = parse_frame_specification ("0"); - sals = decode_line_spec (arg, DECODE_LINE_FUNFIRSTLINE); + sals = decode_line_spec_with_current_source_as_default + (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 28 Jun 2012 19:46:35 -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 28 Jun 2012 19:46:35 -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 28 Jun 2012 19:46:35 -0000 @@ -2494,7 +2494,8 @@ trace_find_line_command (char *args, int } else { - sals = decode_line_spec (args, DECODE_LINE_FUNFIRSTLINE); + sals = decode_line_spec_with_current_source_as_default + (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 28 Jun 2012 19:46:35 -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_spec_with_current_source_as_default + (argv[1], DECODE_LINE_FUNFIRSTLINE); back_to = make_cleanup (xfree, sals.sals); sal = sals.sals[0];