• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Revisioneeb1af437c6f1ca111bc31b63eefc5344b553681 (tree)
Zeit2016-02-10 03:02:53
AutorKeith Seitz <keiths@redh...>
CommiterKeith Seitz

Log Message

Refactor string_to_event_location for legacy linespec support.

This patch refactors string_to_event_location, breaking it into two
separate functions:

1) string_to_event_location_basic
A "basic" string parser that implements support for "legacy" linespecs
(linespec, address, and probe locations). This function is intended to
be used by any UI wishing/needing to support this legacy behavior.

2) string_to_event_location
This is now intended as a CLI-only function which adds explicit location
parsing in a CLI-appropriate manner (in the form of traditional option/value
pairs).

Together these patches serve to simplify string-to-event location parsing
for all existing non-CLI interfaces (MI, guile, and python).

gdb/ChangeLog

* location.c (string_to_explicit_location): Note that "-p" is
reserved for probe locations and return NULL for any input
that starts with that.
(string_to_event_location): Move "legacy" linespec code to ...
(string_to_event_location_basic): ... here.
* location.h (string_to_event_location): Update comment.
(string_to_event_location_basic): New function.

Ändern Zusammenfassung

Diff

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
1+2016-02-09 Keith Seitz <keiths@redhat.com>
2+
3+ * location.c (string_to_explicit_location): Note that "-p" is
4+ reserved for probe locations and return NULL for any input
5+ that starts with that.
6+ (string_to_event_location): Move "legacy" linespec code to ...
7+ (string_to_event_location_basic): ... here.
8+ * location.h (string_to_event_location): Update comment.
9+ (string_to_event_location_basic): New function.
10+
111 2016-02-09 Simon Marchi <simon.marchi@ericsson.com>
212
313 * configure.ac: Use AC_CONFIG_FILES instead of passing arguments
--- a/gdb/location.c
+++ b/gdb/location.c
@@ -522,11 +522,13 @@ string_to_explicit_location (const char **argp,
522522 struct event_location *location;
523523
524524 /* It is assumed that input beginning with '-' and a non-digit
525- character is an explicit location. */
525+ character is an explicit location. "-p" is reserved, though,
526+ for probe locations. */
526527 if (argp == NULL
527528 || *argp == '\0'
528529 || *argp[0] != '-'
529- || !isalpha ((*argp)[1]))
530+ || !isalpha ((*argp)[1])
531+ || ((*argp)[0] == '-' && (*argp)[1] == 'p'))
530532 return NULL;
531533
532534 location = new_explicit_location (NULL);
@@ -634,51 +636,36 @@ string_to_explicit_location (const char **argp,
634636 /* See description in location.h. */
635637
636638 struct event_location *
637-string_to_event_location (char **stringp,
638- const struct language_defn *language)
639+string_to_event_location_basic (char **stringp,
640+ const struct language_defn *language)
639641 {
640642 struct event_location *location;
643+ const char *arg, *orig, *cs;
641644
642- /* First, check if the string is an address location. */
643- if (*stringp != NULL && **stringp == '*')
645+ /* Try the input as a probe spec. */
646+ cs = *stringp;
647+ if (cs != NULL && probe_linespec_to_ops (&cs) != NULL)
644648 {
645- const char *arg, *orig;
646- CORE_ADDR addr;
647-
648- orig = arg = *stringp;
649- addr = linespec_expression_to_pc (&arg);
650- location = new_address_location (addr, orig, arg - orig);
651- *stringp += arg - orig;
649+ location = new_probe_location (*stringp);
650+ *stringp += strlen (*stringp);
652651 }
653652 else
654653 {
655- const char *cs;
656-
657- /* Next, try the input as a probe spec. */
658- cs = *stringp;
659- if (cs != NULL && probe_linespec_to_ops (&cs) != NULL)
660- {
661- location = new_probe_location (*stringp);
662- *stringp += strlen (*stringp);
663- }
664- else
654+ /* Try an address location. */
655+ if (*stringp != NULL && **stringp == '*')
665656 {
666657 const char *arg, *orig;
658+ CORE_ADDR addr;
667659
668- /* Next, try an explicit location. */
669660 orig = arg = *stringp;
670- location = string_to_explicit_location (&arg, language, 0);
671- if (location != NULL)
672- {
673- /* It was a valid explicit location. Advance STRINGP to
674- the end of input. */
675- *stringp += arg - orig;
676- }
677- else
678- {
679- /* Everything else is a linespec. */
680- location = new_linespec_location (stringp);
681- }
661+ addr = linespec_expression_to_pc (&arg);
662+ location = new_address_location (addr, orig, arg - orig);
663+ *stringp += arg - orig;
664+ }
665+ else
666+ {
667+ /* Everything else is a linespec. */
668+ location = new_linespec_location (stringp);
682669 }
683670 }
684671
@@ -687,6 +674,34 @@ string_to_event_location (char **stringp,
687674
688675 /* See description in location.h. */
689676
677+struct event_location *
678+string_to_event_location (char **stringp,
679+ const struct language_defn *language)
680+{
681+ struct event_location *location;
682+ const char *arg, *orig;
683+
684+ /* Try an explicit location. */
685+ orig = arg = *stringp;
686+ location = string_to_explicit_location (&arg, language, 0);
687+ if (location != NULL)
688+ {
689+ /* It was a valid explicit location. Advance STRINGP to
690+ the end of input. */
691+ *stringp += arg - orig;
692+ }
693+ else
694+ {
695+ /* Everything else is a "basic" linespec, address, or probe
696+ location. */
697+ location = string_to_event_location_basic (stringp, language);
698+ }
699+
700+ return location;
701+}
702+
703+/* See description in location.h. */
704+
690705 int
691706 event_location_empty_p (const struct event_location *location)
692707 {
--- a/gdb/location.h
+++ b/gdb/location.h
@@ -207,12 +207,24 @@ extern struct event_location *
207207 but invalid, input, e.g., if it is called with missing argument parameters
208208 or invalid options.
209209
210- The return result must be freed with delete_event_location. */
210+ The return result must be freed with delete_event_location.
211+
212+ This function is intended to be used by CLI commands and will parse
213+ explicit locations in a CLI-centric way. Other interfaces should use
214+ string_to_event_location_basic if they want to maintain support for
215+ legacy specifications of probe, address, and linespec locations. */
211216
212217 extern struct event_location *
213218 string_to_event_location (char **argp,
214219 const struct language_defn *langauge);
215220
221+/* Like string_to_event_location, but does not attempt to parse explicit
222+ locations. */
223+
224+extern struct event_location *
225+ string_to_event_location_basic (char **argp,
226+ const struct language_defn *language);
227+
216228 /* Attempt to convert the input string in *ARGP into an explicit location.
217229 ARGP is advanced past any processed input. Returns an event_location
218230 (malloc'd) if an explicit location was successfully found in *ARGP,