+
+
+
+/* do_command but with printf style formatting of the arguments */
+void
+sim_do_commandf (SIM_DESC sd,
+ const char *fmt,
+ ...)
+{
+ va_list ap;
+ char *buf;
+ int ret;
+
+ va_start (ap, fmt);
+ ret = vasprintf (&buf, fmt, ap);
+ va_end (ap);
+
+ if (ret < 0)
+ {
+ sim_io_eprintf (sd, "%s: asprintf failed for `%s'\n",
+ STATE_MY_NAME (sd), fmt);
+ return;
+ }
+
+ sim_do_command (sd, buf);
+ free (buf);
+}
+
+
+/* sim-basics.h defines a number of enumerations, convert each of them
+ to a string representation */
+const char *
+map_to_str (unsigned map)
+{
+ switch (map)
+ {
+ case read_map: return "read";
+ case write_map: return "write";
+ case exec_map: return "exec";
+ case io_map: return "io";
+ default:
+ {
+ static char str[16];
+ snprintf (str, sizeof(str), "(%ld)", (long) map);
+ return str;
+ }
+ }
+}
+
+const char *
+access_to_str (unsigned access)
+{
+ switch (access)
+ {
+ case access_invalid: return "invalid";
+ case access_read: return "read";
+ case access_write: return "write";
+ case access_exec: return "exec";
+ case access_io: return "io";
+ case access_read_write: return "read_write";
+ case access_read_exec: return "read_exec";
+ case access_write_exec: return "write_exec";
+ case access_read_write_exec: return "read_write_exec";
+ case access_read_io: return "read_io";
+ case access_write_io: return "write_io";
+ case access_read_write_io: return "read_write_io";
+ case access_exec_io: return "exec_io";
+ case access_read_exec_io: return "read_exec_io";
+ case access_write_exec_io: return "write_exec_io";
+ case access_read_write_exec_io: return "read_write_exec_io";
+ default:
+ {
+ static char str[16];
+ snprintf (str, sizeof(str), "(%ld)", (long) access);
+ return str;
+ }
+ }
+}
+
+const char *
+transfer_to_str (unsigned transfer)
+{
+ switch (transfer)
+ {
+ case read_transfer: return "read";
+ case write_transfer: return "write";
+ default: return "(error)";
+ }
+}