binutils-gdb/sim/common/hw-tree.h
Simon Marchi f08708cbf5 sim: add ATTRIBUTE_PRINTF / ATTRIBUTE_NULL_PRINTF where necessary
I finally got the all-targets sim building with Clang, these are all the
instances where an ATTRIBUTE_PRINTF or ATTRIBUTE_NULL_PRINTF attribute
needed to be added to avoid errors like:

    /home/simark/src/binutils-gdb/sim/aarch64/../common/sim-profile.c:464:19: error: format string is not a string literal [-Werror,-Wformat-nonliteral]
        vfprintf (fp, fmt, ap);
                      ^~~
There are more fixes needed to get everything building, but adding these
attributes is trivial enough, so I send them all in a single patch.

Adding the format attributes introduces some format string errors when
building with GCC (because now format strings are checked), so
corresponding changes are needed to avoid breaking the build.  Other
than simple format string specified changes, there is this one:

    /home/simark/src/binutils-gdb/sim/aarch64/../common/hw-events.c: In function 'hw_event_queue_schedule':
    /home/simark/src/binutils-gdb/sim/aarch64/../common/hw-events.c:95:15: error: too many arguments for format [-Werror=format-extra-args]
       95 |         NULL, dummy);
          |               ^~~~~

We can fix it and avoid using a dummy variable by simply calling
hw_event_queue_schedule_tracef instead of
hw_event_queue_schedule_vtracef.

sim/arm/ChangeLog:

	* armdefs.h (ARMul_ConsolePrint): Use format attribute.
	* wrapper.c (op_printf): Likewise.

sim/bfin/ChangeLog:

	* interp.c (sim_open): Adjust format string specifier.

sim/common/ChangeLog:

	* hw-events.h (hw_event_queue_schedule_tracef): Use format attribute.
	(hw_event_queue_schedule_vtracef): Likewise.
	* hw-tree.h (hw_tree_vparse): Likewise.
	* sim-profile.c (profile_vprintf): Likewise.
	* sim-trace.c (dis_printf): Likewise.
	* sim-trace.h (trace_printf): Likewise.
	(trace_vprintf): Likewise.
	* sim-utils.h (sim_do_commandf): Likewise.
	* hw-events.c (hw_event_queue_schedule): Use
	hw_event_queue_schedule_tracef.

sim/rx/ChangeLog:

	* trace.c (op_printf): Likewise.

sim/v850/ChangeLog:

	* interp.c (sim_open): Adjust format string specifier.

Change-Id: I1445115ce57db15bb8e35dca93014555e7555794
2021-05-03 10:55:25 -04:00

121 lines
2.6 KiB
C

/* The common simulator framework for GDB, the GNU Debugger.
Copyright 2002-2021 Free Software Foundation, Inc.
Contributed by Andrew Cagney and Red Hat.
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 HW_TREE
#define HW_TREE
struct hw *hw_tree_create
(SIM_DESC sd,
const char *device);
void hw_tree_delete
(struct hw *root);
struct hw *hw_tree_parse
(struct hw *root,
const char *fmt,
...) ATTRIBUTE_PRINTF (2, 3);
struct hw *hw_tree_vparse
(struct hw *root,
const char *fmt,
va_list ap) ATTRIBUTE_PRINTF (2, 0);
void hw_tree_finish
(struct hw *root);
typedef void (hw_tree_print_callback)
(void *,
const char *fmt,
...);
void hw_tree_print
(struct hw *root,
hw_tree_print_callback *print,
void *file);
/* Tree traversal::
The entire device tree can be traversed using the
<<device_tree_traverse()>> function. The traversal can be in
either prefix or postfix order.
*/
typedef void (hw_tree_traverse_function)
(struct hw *device,
void *data);
void hw_tree_traverse
(struct hw *root,
hw_tree_traverse_function *prefix,
hw_tree_traverse_function *postfix,
void *data);
/* Tree lookup::
The function <<hw_tree_find_device()>> will attempt to locate the
specified device within the tree. If the device is not found a
NULL device is returned.
*/
struct hw * hw_tree_find_device
(struct hw *root,
const char *path);
const struct hw_property *hw_tree_find_property
(struct hw *root,
const char *path_to_property);
int hw_tree_find_boolean_property
(struct hw *root,
const char *path_to_property);
signed_cell hw_tree_find_integer_property
(struct hw *root,
const char *path_to_property);
#if NOT_YET
device_instance *hw_tree_find_ihandle_property
(struct hw *root,
const char *path_to_property);
#endif
const char *hw_tree_find_string_property
(struct hw *root,
const char *path_to_property);
/* Perform a soft reset on the created tree. */
void hw_tree_reset
(struct hw *root);
#endif