• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No 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

Revisión6677510b29809dd3729916dda282764f57f457a9 (tree)
Tiempo2019-06-05 07:30:03
AutorPedro Alves <palves@redh...>
CommiterPedro Alves

Log Message

Delete parse_flags/parse_flags_qcs

Now that "thread/frame apply" have been converted to the gdb::option
framework, these functions are no longer used.

For a while, I thought about keeping the unit tests, by making a local
version of parse_flags_qcs in the unit tests file. But all that would
really test that is used by GDB itself, is the validate_flags_qcs
function. So in the end, I went through all the unit tests, and
converted any that wasn't already covered to gdb.base/options.exp
tests. And those have all already been added in previous patches.

gdb/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>

* cli/cli-utils.c (parse_flags, parse_flags_qcs): Delete.
* cli/cli-utils.h (parse_flags, parse_flags_qcs): Delete.
* unittests/cli-utils-selftests.c (test_parse_flags)
(test_parse_flags_qcs): Delete.
(test_cli_utils): Don't call deleted functions.

Cambiar Resumen

Diferencia incremental

--- a/gdb/cli/cli-utils.c
+++ b/gdb/cli/cli-utils.c
@@ -524,62 +524,6 @@ check_for_argument (const char **str, const char *arg, int arg_len)
524524
525525 /* See documentation in cli-utils.h. */
526526
527-int
528-parse_flags (const char **str, const char *flags)
529-{
530- const char *p = skip_spaces (*str);
531-
532- if (p[0] == '-'
533- && isalpha (p[1])
534- && (p[2] == '\0' || isspace (p[2])))
535- {
536- const char pf = p[1];
537- const char *f = flags;
538-
539- while (*f != '\0')
540- {
541- if (*f == pf)
542- {
543- *str = skip_spaces (p + 2);
544- return f - flags + 1;
545- }
546- f++;
547- }
548- }
549-
550- return 0;
551-}
552-
553-/* See documentation in cli-utils.h. */
554-
555-bool
556-parse_flags_qcs (const char *which_command, const char **str,
557- qcs_flags *flags)
558-{
559- switch (parse_flags (str, "qcs"))
560- {
561- case 0:
562- return false;
563- case 1:
564- flags->quiet = true;
565- break;
566- case 2:
567- flags->cont = true;
568- break;
569- case 3:
570- flags->silent = true;
571- break;
572- default:
573- gdb_assert_not_reached ("int qcs flag out of bound");
574- }
575-
576- validate_flags_qcs (which_command, flags);
577-
578- return true;
579-}
580-
581-/* See documentation in cli-utils.h. */
582-
583527 void
584528 validate_flags_qcs (const char *which_command, qcs_flags *flags)
585529 {
--- a/gdb/cli/cli-utils.h
+++ b/gdb/cli/cli-utils.h
@@ -220,15 +220,6 @@ check_for_argument (char **str, const char *arg)
220220 return check_for_argument (str, arg, strlen (arg));
221221 }
222222
223-/* A helper function that looks for a set of flags at the start of a
224- string. The possible flags are given as a null terminated string.
225- A flag in STR must either be at the end of the string,
226- or be followed by whitespace.
227- Returns 0 if no valid flag is found at the start of STR.
228- Otherwise updates *STR, and returns N (which is > 0),
229- such that FLAGS [N - 1] is the valid found flag. */
230-extern int parse_flags (const char **str, const char *flags);
231-
232223 /* qcs_flags struct groups the -q, -c, and -s flags parsed by "thread
233224 apply" and "frame apply" commands */
234225
@@ -239,27 +230,6 @@ struct qcs_flags
239230 int silent = false;
240231 };
241232
242-/* A helper function that uses parse_flags to handle the flags qcs :
243- A flag -q sets FLAGS->QUIET to true.
244- A flag -c sets FLAGS->CONT to true.
245- A flag -s sets FLAGS->SILENT to true.
246-
247- The caller is responsible to initialize *FLAGS to false before the (first)
248- call to parse_flags_qcs.
249- parse_flags_qcs can then be called iteratively to search for more
250- valid flags, as part of a 'main parsing loop' searching for -q/-c/-s
251- flags together with other flags and options.
252-
253- Returns true and updates *STR and one of FLAGS->QUIET, FLAGS->CONT,
254- FLAGS->SILENT if it finds a valid flag.
255- Returns false if no valid flag is found at the beginning of STR.
256-
257- Throws an error if a flag is found such that both FLAGS->CONT and
258- FLAGS->SILENT are true. */
259-
260-extern bool parse_flags_qcs (const char *which_command, const char **str,
261- qcs_flags *flags);
262-
263233 /* Validate FLAGS. Throws an error if both FLAGS->CONT and
264234 FLAGS->SILENT are true. WHICH_COMMAND is included in the error
265235 message. */
--- a/gdb/unittests/cli-utils-selftests.c
+++ b/gdb/unittests/cli-utils-selftests.c
@@ -102,142 +102,9 @@ test_number_or_range_parser ()
102102 }
103103
104104 static void
105-test_parse_flags ()
106-{
107- const char *flags = "abc";
108- const char *non_flags_args = "non flags args";
109-
110- /* Extract twice the same flag, separated by one space. */
111- {
112- const char *t1 = "-a -a non flags args";
113-
114- SELF_CHECK (parse_flags (&t1, flags) == 1);
115- SELF_CHECK (parse_flags (&t1, flags) == 1);
116- SELF_CHECK (strcmp (t1, non_flags_args) == 0);
117- }
118-
119- /* Extract some flags, separated by one or more spaces. */
120- {
121- const char *t2 = "-c -b -c -b -c non flags args";
122-
123- SELF_CHECK (parse_flags (&t2, flags) == 3);
124- SELF_CHECK (parse_flags (&t2, flags) == 2);
125- SELF_CHECK (parse_flags (&t2, flags) == 3);
126- SELF_CHECK (parse_flags (&t2, flags) == 2);
127- SELF_CHECK (parse_flags (&t2, flags) == 3);
128- SELF_CHECK (strcmp (t2, non_flags_args) == 0);
129- }
130-
131- /* Check behaviour where there is no flag to extract. */
132- {
133- const char *t3 = non_flags_args;
134-
135- SELF_CHECK (parse_flags (&t3, flags) == 0);
136- SELF_CHECK (strcmp (t3, non_flags_args) == 0);
137- }
138-
139- /* Extract 2 known flags in front of unknown flags. */
140- {
141- const char *t4 = "-c -b -x -y -z -c";
142-
143- SELF_CHECK (parse_flags (&t4, flags) == 3);
144- SELF_CHECK (parse_flags (&t4, flags) == 2);
145- SELF_CHECK (strcmp (t4, "-x -y -z -c") == 0);
146- SELF_CHECK (parse_flags (&t4, flags) == 0);
147- SELF_CHECK (strcmp (t4, "-x -y -z -c") == 0);
148- }
149-
150- /* Check combined flags are not recognised. */
151- {
152- const char *t5 = "-c -cb -c";
153-
154- SELF_CHECK (parse_flags (&t5, flags) == 3);
155- SELF_CHECK (parse_flags (&t5, flags) == 0);
156- SELF_CHECK (strcmp (t5, "-cb -c") == 0);
157- }
158-}
159-
160-static void
161-test_parse_flags_qcs ()
162-{
163- const char *non_flags_args = "non flags args";
164-
165- /* Test parsing of 2 flags out of the known 3. */
166- {
167- const char *t1 = "-q -s non flags args";
168- qcs_flags flags;
169-
170- SELF_CHECK (parse_flags_qcs ("test_parse_flags_qcs.t1.q",
171- &t1,
172- &flags) == 1);
173- SELF_CHECK (flags.quiet && !flags.cont && !flags.silent);
174- SELF_CHECK (parse_flags_qcs ("test_parse_flags_qcs.t1.s",
175- &t1,
176- &flags) == 1);
177- SELF_CHECK (flags.quiet && !flags.cont && flags.silent);
178- SELF_CHECK (strcmp (t1, non_flags_args) == 0);
179- }
180-
181- /* Test parsing when there is no flag. */
182- {
183- const char *t2 = "non flags args";
184- qcs_flags flags;
185-
186- SELF_CHECK (parse_flags_qcs ("test_parse_flags_qcs.t2",
187- &t2,
188- &flags) == 0);
189- SELF_CHECK (!flags.quiet && !flags.cont && !flags.silent);
190- SELF_CHECK (strcmp (t2, non_flags_args) == 0);
191- }
192-
193- /* Test parsing stops at a negative integer. */
194- {
195- const char *t3 = "-123 non flags args";
196- const char *orig_t3 = t3;
197- qcs_flags flags;
198-
199- SELF_CHECK (parse_flags_qcs ("test_parse_flags_qcs.t3",
200- &t3,
201- &flags) == 0);
202- SELF_CHECK (!flags.quiet && !flags.cont && !flags.silent);
203- SELF_CHECK (strcmp (t3, orig_t3) == 0);
204- }
205-
206- /* Test mutual exclusion between -c and -s. */
207- {
208- const char *t4 = "-c -s non flags args";
209- qcs_flags flags;
210-
211- try
212- {
213- SELF_CHECK (parse_flags_qcs ("test_parse_flags_qcs.t4.cs",
214- &t4,
215- &flags) == 1);
216-
217- (void) parse_flags_qcs ("test_parse_flags_qcs.t4.cs",
218- &t4,
219- &flags);
220- SELF_CHECK (false);
221- }
222- catch (const gdb_exception_error &ex)
223- {
224- SELF_CHECK (ex.reason == RETURN_ERROR);
225- SELF_CHECK (ex.error == GENERIC_ERROR);
226- SELF_CHECK
227- (strcmp (ex.what (),
228- "test_parse_flags_qcs.t4.cs: "
229- "-c and -s are mutually exclusive") == 0);
230- }
231- }
232-
233-}
234-
235-static void
236105 test_cli_utils ()
237106 {
238107 selftests::cli_utils::test_number_or_range_parser ();
239- selftests::cli_utils::test_parse_flags ();
240- selftests::cli_utils::test_parse_flags_qcs ();
241108 }
242109
243110 }