char * extract_arg (char **arg) { char *result, *copy; if (!*arg) return NULL; /* Find the start of the argument. */ *arg = skip_spaces (*arg); if (!**arg) return NULL; result = *arg; /* Find the end of the argument. */ *arg = skip_to_space (*arg + 1); if (result == *arg) return NULL; copy = xmalloc (*arg - result + 1); memcpy (copy, result, *arg - result); copy[*arg - result] = '\0'; return copy; }
bool producer_is_icc (const char *producer, int *major, int *minor) { if (producer == NULL || !startswith (producer, "Intel(R)")) return false; /* Prepare the used fields. */ int maj, min; if (major == NULL) major = &maj; if (minor == NULL) minor = &min; *minor = 0; *major = 0; /* Consumes the string till a "Version" is found. */ const char *cs = strstr (producer, "Version"); if (cs != NULL) { cs = skip_to_space (cs); int intermediate = 0; int nof = sscanf (cs, "%d.%d.%d.%*d", major, &intermediate, minor); /* Internal versions are represented only as MAJOR.MINOR, where minor is usually 0. Public versions have 3 fields as described with the command above. */ if (nof == 3) return true; if (nof == 2) { *minor = intermediate; return true; } } static bool warning_printed = false; /* Not recognized as Intel, let the user know. */ if (!warning_printed) { warning (_("Could not recognize version of Intel Compiler in: \"%s\""), producer); warning_printed = true; } return false; }
/* The implementation of the `info macro' command. */ static void info_macro_command (char *args, int from_tty) { struct macro_scope *ms = NULL; struct cleanup *cleanup_chain; char *name; int show_all_macros_named = 0; char *arg_start = args; int processing_args = 1; while (processing_args && arg_start && *arg_start == '-' && *arg_start != '\0') { char *p = skip_to_space (arg_start); if (strncmp (arg_start, "-a", p - arg_start) == 0 || strncmp (arg_start, "-all", p - arg_start) == 0) show_all_macros_named = 1; else if (strncmp (arg_start, "--", p - arg_start) == 0) /* Our macro support seems rather C specific but this would seem necessary for languages allowing - in macro names. e.g. Scheme's (defmacro ->foo () "bar\n") */ processing_args = 0; else { /* Relies on modified 'args' not making it in to history */ *p = '\0'; error (_("Unrecognized option '%s' to info macro command. " "Try \"help info macro\"."), arg_start); } arg_start = skip_spaces (p); } name = arg_start; if (! name || ! *name) error (_("You must follow the `info macro' command with the name" " of the macro\n" "whose definition you want to see.")); ms = default_macro_scope (); cleanup_chain = make_cleanup (free_current_contents, &ms); if (! ms) macro_inform_no_debuginfo (); else if (show_all_macros_named) macro_for_each (ms->file->table, print_macro_callback, name); else { struct macro_definition *d; d = macro_lookup_definition (ms->file, ms->line, name); if (d) { int line; struct macro_source_file *file = macro_definition_location (ms->file, ms->line, name, &line); print_macro_definition (name, d, file, line); } else { fprintf_filtered (gdb_stdout, "The symbol `%s' has no definition as a C/C++" " preprocessor macro\n" "at ", name); show_pp_source_pos (gdb_stdout, ms->file, ms->line); } } do_cleanups (cleanup_chain); }
/* The implementation of the `info macro' command. */ static void info_macro_command (const char *args, int from_tty) { gdb::unique_xmalloc_ptr<struct macro_scope> ms; const char *name; int show_all_macros_named = 0; const char *arg_start = args; int processing_args = 1; while (processing_args && arg_start && *arg_start == '-' && *arg_start != '\0') { const char *p = skip_to_space (arg_start); if (strncmp (arg_start, "-a", p - arg_start) == 0 || strncmp (arg_start, "-all", p - arg_start) == 0) show_all_macros_named = 1; else if (strncmp (arg_start, "--", p - arg_start) == 0) /* Our macro support seems rather C specific but this would seem necessary for languages allowing - in macro names. e.g. Scheme's (defmacro ->foo () "bar\n") */ processing_args = 0; else { error (_("Unrecognized option '%.*s' to info macro command. " "Try \"help info macro\"."), int (p - arg_start), arg_start); } arg_start = skip_spaces (p); } name = arg_start; if (! name || ! *name) error (_("You must follow the `info macro' command with the name" " of the macro\n" "whose definition you want to see.")); ms = default_macro_scope (); if (! ms) macro_inform_no_debuginfo (); else if (show_all_macros_named) macro_for_each (ms->file->table, [&] (const char *macro_name, const macro_definition *macro, macro_source_file *source, int line) { if (strcmp (name, macro_name) == 0) print_macro_definition (name, macro, source, line); }); else { struct macro_definition *d; d = macro_lookup_definition (ms->file, ms->line, name); if (d) { int line; struct macro_source_file *file = macro_definition_location (ms->file, ms->line, name, &line); print_macro_definition (name, d, file, line); } else { fprintf_filtered (gdb_stdout, "The symbol `%s' has no definition as a C/C++" " preprocessor macro\n" "at ", name); show_pp_source_pos (gdb_stdout, ms->file, ms->line); } } }
static int get_tid_or_range (struct tid_range_parser *parser, int *inf_num, int *thr_start, int *thr_end) { if (parser->state == TID_RANGE_STATE_INFERIOR) { const char *p; const char *space; space = skip_to_space (parser->string); p = parser->string; while (p < space && *p != '.') p++; if (p < space) { const char *dot = p; /* Parse number to the left of the dot. */ p = parser->string; parser->inf_num = get_positive_number_trailer (&p, '.', parser->string); if (parser->inf_num == 0) return 0; parser->qualified = 1; p = dot + 1; if (isspace (*p)) return 0; } else { parser->inf_num = parser->default_inferior; parser->qualified = 0; p = parser->string; } init_number_or_range (&parser->range_parser, p); if (p[0] == '*' && (p[1] == '\0' || isspace (p[1]))) { /* Setup the number range parser to return numbers in the whole [1,INT_MAX] range. */ number_range_setup_range (&parser->range_parser, 1, INT_MAX, skip_spaces_const (p + 1)); parser->state = TID_RANGE_STATE_STAR_RANGE; } else parser->state = TID_RANGE_STATE_THREAD_RANGE; } *inf_num = parser->inf_num; *thr_start = get_number_or_range (&parser->range_parser); if (*thr_start < 0) error (_("negative value: %s"), parser->string); if (*thr_start == 0) { parser->state = TID_RANGE_STATE_INFERIOR; return 0; } /* If we successfully parsed a thread number or finished parsing a thread range, switch back to assuming the next TID is inferior-qualified. */ if (parser->range_parser.end_ptr == NULL || parser->range_parser.string == parser->range_parser.end_ptr) { parser->state = TID_RANGE_STATE_INFERIOR; parser->string = parser->range_parser.string; if (thr_end != NULL) *thr_end = *thr_start; } /* If we're midway through a range, and the caller wants the end value, return it and skip to the end of the range. */ if (thr_end != NULL && (parser->state == TID_RANGE_STATE_THREAD_RANGE || parser->state == TID_RANGE_STATE_STAR_RANGE)) { *thr_end = parser->range_parser.end_value; tid_range_parser_skip (parser); } return (*inf_num != 0 && *thr_start != 0); }