2012-07-19 07:37:58 +08:00
|
|
|
|
/* *INDENT-OFF* */ /* ATTRIBUTE_PRINTF confuses indent, avoid running it
|
|
|
|
|
for now. */
|
|
|
|
|
/* I/O, string, cleanup, and other random utilities for GDB.
|
2016-01-01 12:33:14 +08:00
|
|
|
|
Copyright (C) 1986-2016 Free Software Foundation, Inc.
|
2012-07-19 07:37:58 +08:00
|
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
|
|
#ifndef UTILS_H
|
|
|
|
|
#define UTILS_H
|
|
|
|
|
|
2013-05-15 20:49:05 +08:00
|
|
|
|
#include "exceptions.h"
|
2012-07-19 07:37:58 +08:00
|
|
|
|
|
|
|
|
|
extern void initialize_utils (void);
|
|
|
|
|
|
|
|
|
|
/* String utilities. */
|
|
|
|
|
|
|
|
|
|
extern int sevenbit_strings;
|
|
|
|
|
|
|
|
|
|
extern int strcmp_iw (const char *, const char *);
|
|
|
|
|
|
|
|
|
|
extern int strcmp_iw_ordered (const char *, const char *);
|
|
|
|
|
|
|
|
|
|
extern int streq (const char *, const char *);
|
|
|
|
|
|
|
|
|
|
extern int subset_compare (char *, char *);
|
|
|
|
|
|
|
|
|
|
int compare_positive_ints (const void *ap, const void *bp);
|
|
|
|
|
int compare_strings (const void *ap, const void *bp);
|
|
|
|
|
|
|
|
|
|
/* A wrapper for bfd_errmsg to produce a more helpful error message
|
|
|
|
|
in the case of bfd_error_file_ambiguously recognized.
|
|
|
|
|
MATCHING, if non-NULL, is the corresponding argument to
|
|
|
|
|
bfd_check_format_matches, and will be freed. */
|
|
|
|
|
|
|
|
|
|
extern const char *gdb_bfd_errmsg (bfd_error_type error_tag, char **matching);
|
New commands "mt set per-command {space,time,symtab} {on,off}".
* NEWS: Add entry.
* event-top.c: #include "maint.h".
* main.c: #include "maint.h".
* maint.c: #include <sys/time.h>, <time.h>, block.h, top.h,
timeval-utils.h, maint.h, cli/cli-setshow.h.
(per_command_time, per_command_space): New static globals.
(per_command_symtab): New static global.
(per_command_setlist, per_command_showlist): New static globals.
(struct cmd_stats): Move here from utils.c.
(set_per_command_time): Renamed from set_display_time in utils.c
and moved here. All callers updated.
(set_per_command_space): Renamed from set_display_space in utils.c
and moved here. All callers updated.
(count_symtabs_and_blocks): New function.
(report_command_stats): Moved here from utils.c. Add support for
printing symtab stats. Only print data if enabled before command
executed.
(make_command_stats_cleanup): Ditto.
(sert_per_command_cmd, show_per_command_cmd): New functions.
(_initialize_maint_cmds): Add new commands
mt set per-command {space,time,symtab} {on,off}.
* maint.h: New file.
* top.c: #include "maint.h".
* utils.c (reset_prompt_for_continue_wait_time): New function.
(get_prompt_for_continue_wait_time): New function.
* utils.h (reset_prompt_for_continue_wait_time): Declare
(get_prompt_for_continue_wait_time): Declare.
(make_command_stats_cleanup): Moved to maint.h.
(set_display_time, set_display_space): Moved to maint.h and renamed
to set_per_command_time, set_per_command_space.
* cli/cli-setshow.c (parse_cli_boolean_value): Renamed from
parse_binary_operation and made non-static. Don't call error,
just return an error marker. All callers updated.
* cli/cli-setshow.h (parse_cli_boolean_value): Declare.
doc/
* gdb.texinfo (Maintenance Commands): Add docs for
"mt set per-command {space,time,symtab} {on,off}".
testsuite/
* gdb.base/maint.exp: Update tests for per-command stats.
2013-03-22 01:37:30 +08:00
|
|
|
|
|
|
|
|
|
/* Reset the prompt_for_continue clock. */
|
|
|
|
|
void reset_prompt_for_continue_wait_time (void);
|
|
|
|
|
/* Return the time spent in prompt_for_continue. */
|
|
|
|
|
struct timeval get_prompt_for_continue_wait_time (void);
|
2012-07-19 07:37:58 +08:00
|
|
|
|
|
|
|
|
|
/* Parsing utilites. */
|
|
|
|
|
|
2013-04-15 23:40:57 +08:00
|
|
|
|
extern int parse_pid_to_attach (const char *args);
|
2012-07-19 07:37:58 +08:00
|
|
|
|
|
2013-10-02 08:46:07 +08:00
|
|
|
|
extern int parse_escape (struct gdbarch *, const char **);
|
2012-07-19 07:37:58 +08:00
|
|
|
|
|
|
|
|
|
char **gdb_buildargv (const char *);
|
|
|
|
|
|
|
|
|
|
/* Cleanup utilities. */
|
|
|
|
|
|
|
|
|
|
extern struct cleanup *make_cleanup_freeargv (char **);
|
|
|
|
|
|
|
|
|
|
struct dyn_string;
|
|
|
|
|
extern struct cleanup *make_cleanup_dyn_string_delete (struct dyn_string *);
|
|
|
|
|
|
|
|
|
|
struct ui_file;
|
|
|
|
|
extern struct cleanup *make_cleanup_ui_file_delete (struct ui_file *);
|
|
|
|
|
|
|
|
|
|
struct ui_out;
|
|
|
|
|
extern struct cleanup *
|
|
|
|
|
make_cleanup_ui_out_redirect_pop (struct ui_out *uiout);
|
|
|
|
|
|
|
|
|
|
struct section_addr_info;
|
|
|
|
|
extern struct cleanup *(make_cleanup_free_section_addr_info
|
|
|
|
|
(struct section_addr_info *));
|
|
|
|
|
|
2015-06-10 21:28:43 +08:00
|
|
|
|
/* For make_cleanup_close see common/filestuff.h. */
|
2012-07-19 07:37:58 +08:00
|
|
|
|
|
|
|
|
|
extern struct cleanup *make_cleanup_fclose (FILE *file);
|
|
|
|
|
|
|
|
|
|
extern struct cleanup *make_cleanup_bfd_unref (bfd *abfd);
|
|
|
|
|
|
|
|
|
|
struct obstack;
|
|
|
|
|
extern struct cleanup *make_cleanup_obstack_free (struct obstack *obstack);
|
|
|
|
|
|
|
|
|
|
extern struct cleanup *make_cleanup_restore_integer (int *variable);
|
|
|
|
|
extern struct cleanup *make_cleanup_restore_uinteger (unsigned int *variable);
|
|
|
|
|
|
|
|
|
|
struct target_ops;
|
|
|
|
|
extern struct cleanup *make_cleanup_unpush_target (struct target_ops *ops);
|
|
|
|
|
|
2016-02-29 22:16:19 +08:00
|
|
|
|
|
|
|
|
|
extern struct cleanup *
|
|
|
|
|
make_cleanup_restore_ui_out (struct ui_out **variable);
|
2012-07-19 07:37:58 +08:00
|
|
|
|
extern struct cleanup *
|
|
|
|
|
make_cleanup_restore_ui_file (struct ui_file **variable);
|
|
|
|
|
|
|
|
|
|
extern struct cleanup *make_cleanup_value_free_to_mark (struct value *);
|
|
|
|
|
extern struct cleanup *make_cleanup_value_free (struct value *);
|
|
|
|
|
|
|
|
|
|
struct so_list;
|
|
|
|
|
extern struct cleanup *make_cleanup_free_so (struct so_list *so);
|
|
|
|
|
|
2013-01-14 02:57:01 +08:00
|
|
|
|
extern struct cleanup *make_cleanup_restore_current_language (void);
|
|
|
|
|
|
2012-07-19 07:37:58 +08:00
|
|
|
|
extern struct cleanup *make_cleanup_htab_delete (htab_t htab);
|
|
|
|
|
|
Remove `expout*' globals from parser-defs.h
This commit removes the "expout*" globals from our parser code, turning
them into a structure that is passed when an expression needs to be
evaluated. This is the initial step to make our parser less
"globalized".
This is mostly a mechanical patch, which creates a structure containing
the "expout*" globals and then modify all the functions that handle them
in order to take the structure as argument. It is big, and has been
reviewed at least 4 times, so I think everything is covered.
Below you can see the message links from the discussions:
- First attempt:
<https://sourceware.org/ml/gdb-patches/2012-01/msg00522.html>
Message-ID: <m3k44s7qej.fsf@gmail.com>
- Second attempt:
<https://sourceware.org/ml/gdb-patches/2012-06/msg00054.html>
Message-Id: <1338665528-5932-1-git-send-email-sergiodj@redhat.com>
- Third attempt:
<https://sourceware.org/ml/gdb-patches/2014-01/msg00949.html>
Message-Id: <1390629467-27139-1-git-send-email-sergiodj@redhat.com>
- Fourth (last) attempt:
<https://sourceware.org/ml/gdb-patches/2014-03/msg00546.html>
Message-Id: <1395463432-29750-1-git-send-email-sergiodj@redhat.com>
gdb/
2014-03-27 Sergio Durigan Junior <sergiodj@redhat.com>
Remove some globals from our parser.
* language.c (unk_lang_parser): Add "struct parser_state"
argument.
* language.h (struct language_defn) <la_parser>: Likewise.
* parse.c (expout, expout_size, expout_ptr): Remove variables.
(initialize_expout): Add "struct parser_state" argument.
Rewrite function to use the parser state.
(reallocate_expout, write_exp_elt, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_block, write_exp_elt_objfile,
write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_msymbol, mark_struct_expression,
write_dollar_variable): Likewise.
(parse_exp_in_context_1): Use parser state.
(insert_type_address_space): Add "struct parser_state" argument.
Use parser state.
(increase_expout_size): New function.
* parser-defs.h: Forward declare "struct language_defn" and
"struct parser_state".
(expout, expout_size, expout_ptr): Remove extern declarations.
(parse_gdbarch, parse_language): Rewrite macro declarations to
accept the parser state.
(struct parser_state): New struct.
(initialize_expout, reallocate_expout, write_exp_elt_opcode,
write_exp_elt_sym, write_exp_elt_longcst, write_exp_elt_dblcst,
write_exp_elt_decfloatcst, write_exp_elt_type,
write_exp_elt_intern, write_exp_string, write_exp_string_vector,
write_exp_bitstring, write_exp_elt_block, write_exp_elt_objfile,
write_exp_msymbol, write_dollar_variable,
mark_struct_expression, insert_type_address_space): Add "struct
parser_state" argument.
(increase_expout_size): New function.
* utils.c (do_clear_parser_state): New function.
(make_cleanup_clear_parser_state): Likewise.
* utils.h (make_cleanup_clear_parser_state): New function
prototype.
* aarch64-linux-tdep.c (aarch64_stap_parse_special_token):
Update calls to write_exp* in order to pass the parser state.
* arm-linux-tdep.c (arm_stap_parse_special_token): Likewise.
* i386-tdep.c (i386_stap_parse_special_token_triplet): Likewise.
(i386_stap_parse_special_token_three_arg_disp): Likewise.
* ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise.
* stap-probe.c (stap_parse_register_operand): Likewise.
(stap_parse_single_operand): Likewise.
(stap_parse_argument_1): Likewise.
(stap_parse_argument): Use parser state.
* stap-probe.h: Include "parser-defs.h".
(struct stap_parse_info) <pstate>: New field.
* c-exp.y (parse_type): Rewrite to use parser state.
(yyparse): Redefine to c_parse_internal.
(pstate): New global variable.
(parse_number): Add "struct parser_state" argument.
(write_destructor_name): Likewise.
(type_exp): Update calls to write_exp* and similars in order to
use parser state.
(exp1, exp, variable, qualified_name, space_identifier,
typename, typebase): Likewise.
(write_destructor_name, parse_number, lex_one_token,
classify_name, classify_inner_name, c_parse): Add "struct
parser_state" argument. Update function to use parser state.
* c-lang.h: Forward declare "struct parser_state".
(c_parse): Add "struct parser_state" argument.
* ada-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to ada_parse_internal.
(pstate): New variable.
(write_int, write_object_renaming, write_var_or_type,
write_name_assoc, write_exp_op_with_string, write_ambiguous_var,
type_int, type_long, type_long_long, type_float, type_double,
type_long_double, type_char, type_boolean, type_system_address):
Add "struct parser_state" argument.
(exp1, primary, simple_exp, relation, and_exp, and_then_exp,
or_exp, or_else_exp, xor_exp, type_prefix, opt_type_prefix,
var_or_type, aggregate, aggregate_component_list,
positional_list, others, component_group,
component_associations): Update calls to write_exp* and similar
functions in order to use parser state.
(ada_parse, write_var_from_sym, write_int,
write_exp_op_with_string, write_object_renaming,
find_primitive_type, write_selectors, write_ambiguous_var,
write_var_or_type, write_name_assoc, type_int, type_long,
type_long_long, type_float, type_double, type_long_double,
type_char, type_boolean, type_system_address): Add "struct
parser_state" argument. Adjust function to use parser state.
* ada-lang.c (parse): Likewise.
* ada-lang.h: Forward declare "struct parser_state".
(ada_parse): Add "struct parser_state" argument.
* ada-lex.l (processInt, processReal): Likewise. Adjust all
calls to both functions.
* f-exp.y (parse_type, parse_f_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to f_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp, subrange, typebase): Update calls to write_exp*
and similars in order to use parser state.
(parse_number): Adjust code to use parser state.
(yylex): Likewise.
(f_parse): New function.
* f-lang.h: Forward declare "struct parser_state".
(f_parse): Add "struct parser_state" argument.
* jv-exp.y (parse_type, parse_java_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro for java_parse_internal.
(pstate): New variable.
(push_expression_name, push_expression_name, insert_exp): Add
"struct parser_state" argument.
(type_exp, StringLiteral, Literal, PrimitiveType, IntegralType,
FloatingPointType, exp1, PrimaryNoNewArray, FieldAccess,
FuncStart, MethodInvocation, ArrayAccess, PostfixExpression,
PostIncrementExpression, PostDecrementExpression,
UnaryExpression, PreIncrementExpression, PreDecrementExpression,
UnaryExpressionNotPlusMinus, CastExpression,
MultiplicativeExpression, AdditiveExpression, ShiftExpression,
RelationalExpression, EqualityExpression, AndExpression,
ExclusiveOrExpression, InclusiveOrExpression,
ConditionalAndExpression, ConditionalOrExpression,
ConditionalExpression, Assignment, LeftHandSide): Update
calls to write_exp* and similars in order to use parser state.
(parse_number): Ajust code to use parser state.
(yylex): Likewise.
(java_parse): New function.
(push_variable): Add "struct parser_state" argument. Adjust
code to user parser state.
(push_fieldnames, push_qualified_expression_name,
push_expression_name, insert_exp): Likewise.
* jv-lang.h: Forward declare "struct parser_state".
(java_parse): Add "struct parser_state" argument.
* m2-exp.y (parse_type, parse_m2_type): Rewrite macros to use
parser state.
(yyparse): Redefine macro to m2_parse_internal.
(pstate): New variable.
(type_exp, exp, fblock, variable, type): Update calls to
write_exp* and similars to use parser state.
(yylex): Likewise.
(m2_parse): New function.
* m2-lang.h: Forward declare "struct parser_state".
(m2_parse): Add "struct parser_state" argument.
* objc-lang.c (end_msglist): Add "struct parser_state" argument.
* objc-lang.h: Forward declare "struct parser_state".
(end_msglist): Add "struct parser_state" argument.
* p-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to pascal_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, qualified_name, variable): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, yylex): Adjust code to use parser state.
(pascal_parse): New function.
* p-lang.h: Forward declare "struct parser_state".
(pascal_parse): Add "struct parser_state" argument.
* go-exp.y (parse_type): Rewrite macro to use parser state.
(yyparse): Redefine macro to go_parse_internal.
(pstate): New variable.
(parse_number): Add "struct parser_state" argument.
(type_exp, exp1, exp, variable, type): Update calls to
write_exp* and similars in order to use parser state.
(parse_number, lex_one_token, classify_name, yylex): Adjust code
to use parser state.
(go_parse): Likewise.
* go-lang.h: Forward declare "struct parser_state".
(go_parse): Add "struct parser_state" argument.
2014-03-28 06:10:40 +08:00
|
|
|
|
struct parser_state;
|
|
|
|
|
extern struct cleanup *make_cleanup_clear_parser_state
|
|
|
|
|
(struct parser_state **p);
|
|
|
|
|
|
2012-07-19 07:37:58 +08:00
|
|
|
|
extern void free_current_contents (void *);
|
|
|
|
|
|
|
|
|
|
extern void init_page_info (void);
|
|
|
|
|
|
|
|
|
|
extern struct cleanup *make_cleanup_restore_page_info (void);
|
|
|
|
|
extern struct cleanup *
|
|
|
|
|
set_batch_flag_and_make_cleanup_restore_page_info (void);
|
|
|
|
|
|
|
|
|
|
extern struct cleanup *make_bpstat_clear_actions_cleanup (void);
|
|
|
|
|
|
|
|
|
|
/* Path utilities. */
|
|
|
|
|
|
|
|
|
|
extern char *gdb_realpath (const char *);
|
|
|
|
|
|
2013-10-14 00:11:08 +08:00
|
|
|
|
extern char *gdb_realpath_keepfile (const char *);
|
|
|
|
|
|
2013-12-03 05:24:32 +08:00
|
|
|
|
extern char *gdb_abspath (const char *);
|
|
|
|
|
|
2012-07-19 07:37:58 +08:00
|
|
|
|
extern int gdb_filename_fnmatch (const char *pattern, const char *string,
|
|
|
|
|
int flags);
|
|
|
|
|
|
|
|
|
|
extern void substitute_path_component (char **stringp, const char *from,
|
|
|
|
|
const char *to);
|
|
|
|
|
|
|
|
|
|
char *ldirname (const char *filename);
|
Extend "skip" command to support -file, -gfile, -function, -rfunction.
gdb/ChangeLog:
Extend "skip" command to support -file, -gfile, -function, -rfunction.
* NEWS: Document new features.
* skip.c: #include "fnmatch.h", "gdb_regex.h".
(skiplist_entry) <file>: Renamed from filename.
<function>: Renamed from function_name.
<file_is_glob, function_is_regexp>: New members.
<compiled_function_regexp, compiled_function_regexp_is_valid>:
New members.
(make_skip_entry): New function.
(free_skiplist_entry, free_skiplist_entry_cleanup): New functions.
(make_free_skiplist_entry_cleanup): New function.
(skip_file_command): Update.
(skip_function, skip_function_command): Update.
(compile_skip_regexp): New functions.
(skip_command): Add support for new options.
(skip_info): Update.
(skip_file_p, skip_gfile_p): New functions.
(skip_function_p, skip_rfunction_p): New functions.
(function_name_is_marked_for_skip): Update and simplify.
(_initialize_step_skip): Update.
* symtab.c: #include "fnmatch.h".
(compare_glob_filenames_for_search): New function.
* symtab.h (compare_glob_filenames_for_search): Declare.
* utils.c (count_path_elements): New function.
(strip_leading_path_elements): New function.
* utils.h (count_path_elements): Declare.
(strip_leading_path_elements): Declare.
gdb/doc/ChangeLog:
* gdb.texinfo (Skipping Over Functions and Files): Document new
options to "skip" command. Update docs of output of "info skip".
gdb/testsuite/ChangeLog:
* gdb.base/skip.c (test_skip): New function.
(end_test_skip_file_and_function): New function.
(test_skip_file_and_function): New function.
* gdb.base/skip1.c (test_skip): New function.
(skip1_test_skip_file_and_function): New function.
* gdb.base/skip.exp: Add tests for new skip options.
* gdb.base/skip-solib.exp: Update expected output.
* gdb.perf/skip-command.cc: New file.
* gdb.perf/skip-command.exp: New file.
* gdb.perf/skip-command.py: New file.
2016-02-24 05:25:18 +08:00
|
|
|
|
|
|
|
|
|
extern int count_path_elements (const char *path);
|
|
|
|
|
|
|
|
|
|
extern const char *strip_leading_path_elements (const char *path, int n);
|
2012-07-19 07:37:58 +08:00
|
|
|
|
|
|
|
|
|
/* GDB output, ui_file utilities. */
|
|
|
|
|
|
|
|
|
|
struct ui_file;
|
|
|
|
|
|
|
|
|
|
extern int query (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
|
|
|
|
|
extern int nquery (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
|
|
|
|
|
extern int yquery (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
|
|
|
|
|
|
|
|
|
|
extern void begin_line (void);
|
|
|
|
|
|
|
|
|
|
extern void wrap_here (char *);
|
|
|
|
|
|
|
|
|
|
extern void reinitialize_more_filter (void);
|
|
|
|
|
|
2013-06-29 01:19:39 +08:00
|
|
|
|
extern int pagination_enabled;
|
|
|
|
|
|
2012-07-19 07:37:58 +08:00
|
|
|
|
/* Global ui_file streams. These are all defined in main.c. */
|
|
|
|
|
/* Normal results */
|
|
|
|
|
extern struct ui_file *gdb_stdout;
|
|
|
|
|
/* Input stream */
|
|
|
|
|
extern struct ui_file *gdb_stdin;
|
|
|
|
|
/* Serious error notifications */
|
|
|
|
|
extern struct ui_file *gdb_stderr;
|
|
|
|
|
/* Log/debug/trace messages that should bypass normal stdout/stderr
|
|
|
|
|
filtering. For moment, always call this stream using
|
|
|
|
|
*_unfiltered. In the very near future that restriction shall be
|
|
|
|
|
removed - either call shall be unfiltered. (cagney 1999-06-13). */
|
|
|
|
|
extern struct ui_file *gdb_stdlog;
|
|
|
|
|
/* Target output that should bypass normal stdout/stderr filtering.
|
|
|
|
|
For moment, always call this stream using *_unfiltered. In the
|
|
|
|
|
very near future that restriction shall be removed - either call
|
|
|
|
|
shall be unfiltered. (cagney 1999-07-02). */
|
|
|
|
|
extern struct ui_file *gdb_stdtarg;
|
|
|
|
|
extern struct ui_file *gdb_stdtargerr;
|
|
|
|
|
extern struct ui_file *gdb_stdtargin;
|
|
|
|
|
|
2015-04-24 06:31:38 +08:00
|
|
|
|
/* Set the screen dimensions to WIDTH and HEIGHT. */
|
|
|
|
|
|
|
|
|
|
extern void set_screen_width_and_height (int width, int height);
|
|
|
|
|
|
2012-07-19 07:37:58 +08:00
|
|
|
|
/* More generic printf like operations. Filtered versions may return
|
|
|
|
|
non-locally on error. */
|
|
|
|
|
|
|
|
|
|
extern void fputs_filtered (const char *, struct ui_file *);
|
|
|
|
|
|
|
|
|
|
extern void fputs_unfiltered (const char *, struct ui_file *);
|
|
|
|
|
|
|
|
|
|
extern int fputc_filtered (int c, struct ui_file *);
|
|
|
|
|
|
|
|
|
|
extern int fputc_unfiltered (int c, struct ui_file *);
|
|
|
|
|
|
|
|
|
|
extern int putchar_filtered (int c);
|
|
|
|
|
|
|
|
|
|
extern int putchar_unfiltered (int c);
|
|
|
|
|
|
|
|
|
|
extern void puts_filtered (const char *);
|
|
|
|
|
|
|
|
|
|
extern void puts_unfiltered (const char *);
|
|
|
|
|
|
|
|
|
|
extern void puts_filtered_tabular (char *string, int width, int right);
|
|
|
|
|
|
|
|
|
|
extern void puts_debug (char *prefix, char *string, char *suffix);
|
|
|
|
|
|
|
|
|
|
extern void vprintf_filtered (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
|
|
|
|
|
|
|
|
|
|
extern void vfprintf_filtered (struct ui_file *, const char *, va_list)
|
|
|
|
|
ATTRIBUTE_PRINTF (2, 0);
|
|
|
|
|
|
|
|
|
|
extern void fprintf_filtered (struct ui_file *, const char *, ...)
|
|
|
|
|
ATTRIBUTE_PRINTF (2, 3);
|
|
|
|
|
|
|
|
|
|
extern void fprintfi_filtered (int, struct ui_file *, const char *, ...)
|
|
|
|
|
ATTRIBUTE_PRINTF (3, 4);
|
|
|
|
|
|
|
|
|
|
extern void printf_filtered (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
|
|
|
|
|
|
|
|
|
|
extern void printfi_filtered (int, const char *, ...) ATTRIBUTE_PRINTF (2, 3);
|
|
|
|
|
|
|
|
|
|
extern void vprintf_unfiltered (const char *, va_list) ATTRIBUTE_PRINTF (1, 0);
|
|
|
|
|
|
|
|
|
|
extern void vfprintf_unfiltered (struct ui_file *, const char *, va_list)
|
|
|
|
|
ATTRIBUTE_PRINTF (2, 0);
|
|
|
|
|
|
|
|
|
|
extern void fprintf_unfiltered (struct ui_file *, const char *, ...)
|
|
|
|
|
ATTRIBUTE_PRINTF (2, 3);
|
|
|
|
|
|
|
|
|
|
extern void printf_unfiltered (const char *, ...) ATTRIBUTE_PRINTF (1, 2);
|
|
|
|
|
|
|
|
|
|
extern void print_spaces (int, struct ui_file *);
|
|
|
|
|
|
|
|
|
|
extern void print_spaces_filtered (int, struct ui_file *);
|
|
|
|
|
|
|
|
|
|
extern char *n_spaces (int);
|
|
|
|
|
|
|
|
|
|
extern void fputstr_filtered (const char *str, int quotr,
|
|
|
|
|
struct ui_file * stream);
|
|
|
|
|
|
|
|
|
|
extern void fputstr_unfiltered (const char *str, int quotr,
|
|
|
|
|
struct ui_file * stream);
|
|
|
|
|
|
|
|
|
|
extern void fputstrn_filtered (const char *str, int n, int quotr,
|
|
|
|
|
struct ui_file * stream);
|
|
|
|
|
|
|
|
|
|
extern void fputstrn_unfiltered (const char *str, int n, int quotr,
|
|
|
|
|
struct ui_file * stream);
|
|
|
|
|
|
2014-08-05 18:42:21 +08:00
|
|
|
|
/* Return nonzero if filtered printing is initialized. */
|
|
|
|
|
extern int filtered_printing_initialized (void);
|
|
|
|
|
|
2012-07-19 07:37:58 +08:00
|
|
|
|
/* Display the host ADDR on STREAM formatted as ``0x%x''. */
|
2015-10-28 01:25:09 +08:00
|
|
|
|
extern void gdb_print_host_address_1 (const void *addr, struct ui_file *stream);
|
|
|
|
|
|
|
|
|
|
/* Wrapper that avoids adding a pointless cast to all callers. */
|
|
|
|
|
#define gdb_print_host_address(ADDR, STREAM) \
|
|
|
|
|
gdb_print_host_address_1 ((const void *) ADDR, STREAM)
|
2012-07-19 07:37:58 +08:00
|
|
|
|
|
|
|
|
|
/* Convert CORE_ADDR to string in platform-specific manner.
|
|
|
|
|
This is usually formatted similar to 0x%lx. */
|
|
|
|
|
extern const char *paddress (struct gdbarch *gdbarch, CORE_ADDR addr);
|
|
|
|
|
|
|
|
|
|
/* Return a string representation in hexadecimal notation of ADDRESS,
|
|
|
|
|
which is suitable for printing. */
|
|
|
|
|
|
|
|
|
|
extern const char *print_core_address (struct gdbarch *gdbarch,
|
|
|
|
|
CORE_ADDR address);
|
|
|
|
|
|
|
|
|
|
/* Callback hash_f and eq_f for htab_create_alloc or htab_create_alloc_ex. */
|
|
|
|
|
extern hashval_t core_addr_hash (const void *ap);
|
|
|
|
|
extern int core_addr_eq (const void *ap, const void *bp);
|
|
|
|
|
|
|
|
|
|
extern CORE_ADDR string_to_core_addr (const char *my_string);
|
|
|
|
|
|
|
|
|
|
extern void fprintf_symbol_filtered (struct ui_file *, const char *,
|
|
|
|
|
enum language, int);
|
|
|
|
|
|
2013-03-23 04:39:29 +08:00
|
|
|
|
extern void throw_perror_with_name (enum errors errcode, const char *string)
|
|
|
|
|
ATTRIBUTE_NORETURN;
|
2012-07-19 07:37:58 +08:00
|
|
|
|
|
2013-10-11 16:23:11 +08:00
|
|
|
|
extern void perror_warning_with_name (const char *string);
|
|
|
|
|
|
2012-07-19 07:37:58 +08:00
|
|
|
|
extern void print_sys_errmsg (const char *, int);
|
|
|
|
|
|
|
|
|
|
/* Warnings and error messages. */
|
|
|
|
|
|
|
|
|
|
extern void (*deprecated_error_begin_hook) (void);
|
|
|
|
|
|
|
|
|
|
/* Message to be printed before the warning message, when a warning occurs. */
|
|
|
|
|
|
|
|
|
|
extern char *warning_pre_print;
|
|
|
|
|
|
|
|
|
|
extern void error_stream (struct ui_file *) ATTRIBUTE_NORETURN;
|
|
|
|
|
|
2014-06-19 16:10:44 +08:00
|
|
|
|
extern void demangler_vwarning (const char *file, int line,
|
|
|
|
|
const char *, va_list ap)
|
|
|
|
|
ATTRIBUTE_PRINTF (3, 0);
|
|
|
|
|
|
|
|
|
|
extern void demangler_warning (const char *file, int line,
|
|
|
|
|
const char *, ...) ATTRIBUTE_PRINTF (3, 4);
|
|
|
|
|
|
2012-07-19 07:37:58 +08:00
|
|
|
|
|
|
|
|
|
/* Misc. utilities. */
|
|
|
|
|
|
|
|
|
|
/* Allocation and deallocation functions for the libiberty hash table
|
|
|
|
|
which use obstacks. */
|
|
|
|
|
void *hashtab_obstack_allocate (void *data, size_t size, size_t count);
|
|
|
|
|
void dummy_obstack_deallocate (void *object, void *data);
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_WAITPID
|
|
|
|
|
extern pid_t wait_to_die_with_timeout (pid_t pid, int *status, int timeout);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
extern int producer_is_gcc_ge_4 (const char *producer);
|
Remove use of stdbool.h in GDB sources.
Using type bool from stdbool unfortunately causes problems trying
to build GDB on AiX and Solaris:
In file included from ../../src/gdb/utils.h:24:0,
from ../../src/gdb/defs.h:707,
from ../../src/gdb/utils.c:20:
/[...]/curses.h:96:14: error: two or more data types in declaration
specifiers
typedef char bool;
^
make[2]: *** [utils.o] Error 1
In theory, the problem is in curses.h which, in both cases, do
something similar. On Solaris:
#if !defined(__cplusplus) && !defined(_BOOL)
typedef char bool;
#endif /* !defined(__cplusplus) && !defined(_BOOL) */
On AiX:
#if !defined(__cplusplus) || (defined(__IBMCPP__) &&(__IBMCPP__<400))
#ifndef _BOOL
#define _BOOL
typedef int bool;
#endif
#endif
You can reproduce the same problem by trying to compile:
% cat toto.c
#include <stdbool.h>
#include <curses.h>
% gcc -c toto.c
In file included from toto.c:1:0:
/[...]/curses.h:159:13: error: two or more data types in declaration
specifiers
typedef int bool;
^
This specific issue wouldn't occur if we included curses.h before
including stdbool.h, and I looked at that just to be complete.
Here is a small schematic representation of the include logic:
* utils.c:
-> defs.h -> utils.h -> stdbool.h
-> gdb_curses.h -> curses.h
Because defs.h should always be first on the list, it means that
stdbool.h will always necessarily be included ahead of curses.h.
But, thinking beyond this very specific issue, it shows that using
stdbool.h is going to cause problems on these systems until either
GCC fixes those includes in a way that makes them work; or we switch
to C++.
In the meantime, I think the path of least resistance is to revert
the use of stdbool.h, and use integers, the way we've done up until
now. The benefits of using type "bool" are modest, IMO, so not
a great loss, and a temporary one.
gdb/ChangeLog:
* utils.h: Remove <stdbool.h> #include.
(producer_is_gcc): Change return type to "int".
* utils.c (producer_is_gcc): Change return type to int.
Return 1 instead of true, and 0 instead of false.
Adjust function documentation accordingly.
2015-03-02 22:01:23 +08:00
|
|
|
|
extern int producer_is_gcc (const char *producer, int *major, int *minor);
|
2012-07-19 07:37:58 +08:00
|
|
|
|
|
|
|
|
|
extern int myread (int, char *, int);
|
|
|
|
|
|
|
|
|
|
/* Ensure that V is aligned to an N byte boundary (B's assumed to be a
|
|
|
|
|
power of 2). Round up/down when necessary. Examples of correct
|
|
|
|
|
use include:
|
|
|
|
|
|
|
|
|
|
addr = align_up (addr, 8); -- VALUE needs 8 byte alignment
|
|
|
|
|
write_memory (addr, value, len);
|
|
|
|
|
addr += len;
|
|
|
|
|
|
|
|
|
|
and:
|
|
|
|
|
|
|
|
|
|
sp = align_down (sp - len, 16); -- Keep SP 16 byte aligned
|
|
|
|
|
write_memory (sp, value, len);
|
|
|
|
|
|
|
|
|
|
Note that uses such as:
|
|
|
|
|
|
|
|
|
|
write_memory (addr, value, len);
|
|
|
|
|
addr += align_up (len, 8);
|
|
|
|
|
|
|
|
|
|
and:
|
|
|
|
|
|
|
|
|
|
sp -= align_up (len, 8);
|
|
|
|
|
write_memory (sp, value, len);
|
|
|
|
|
|
|
|
|
|
are typically not correct as they don't ensure that the address (SP
|
|
|
|
|
or ADDR) is correctly aligned (relying on previous alignment to
|
|
|
|
|
keep things right). This is also why the methods are called
|
|
|
|
|
"align_..." instead of "round_..." as the latter reads better with
|
|
|
|
|
this incorrect coding style. */
|
|
|
|
|
|
|
|
|
|
extern ULONGEST align_up (ULONGEST v, int n);
|
|
|
|
|
extern ULONGEST align_down (ULONGEST v, int n);
|
|
|
|
|
|
2014-06-19 16:12:26 +08:00
|
|
|
|
/* Resource limits used by getrlimit and setrlimit. */
|
|
|
|
|
|
|
|
|
|
enum resource_limit_kind
|
|
|
|
|
{
|
|
|
|
|
LIMIT_CUR,
|
|
|
|
|
LIMIT_MAX
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Check whether GDB will be able to dump core using the dump_core
|
|
|
|
|
function. Returns zero if GDB cannot or should not dump core.
|
|
|
|
|
If LIMIT_KIND is LIMIT_CUR the user's soft limit will be respected.
|
|
|
|
|
If LIMIT_KIND is LIMIT_MAX only the hard limit will be respected. */
|
|
|
|
|
|
|
|
|
|
extern int can_dump_core (enum resource_limit_kind limit_kind);
|
|
|
|
|
|
|
|
|
|
/* Print a warning that we cannot dump core. */
|
|
|
|
|
|
|
|
|
|
extern void warn_cant_dump_core (const char *reason);
|
|
|
|
|
|
|
|
|
|
/* Dump core trying to increase the core soft limit to hard limit
|
|
|
|
|
first. */
|
|
|
|
|
|
|
|
|
|
extern void dump_core (void);
|
|
|
|
|
|
2014-12-05 03:32:24 +08:00
|
|
|
|
/* Return the hex string form of LENGTH bytes of DATA.
|
|
|
|
|
Space for the result is malloc'd, caller must free. */
|
|
|
|
|
|
|
|
|
|
extern char *make_hex_string (const gdb_byte *data, size_t length);
|
|
|
|
|
|
2012-07-19 07:37:58 +08:00
|
|
|
|
#endif /* UTILS_H */
|