Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/4850

Change subject: misc: Make the m5 utilities writefile command accept a host path.
......................................................................

misc: Make the m5 utilities writefile command accept a host path.

When the writefile command is given one command line argument, it's treated
as the name of the file in the simulation and on the host. When there are two arguments, the first is the filename in the simulation, and the second is the
name on the host.

Change-Id: I402925a9ff89665bee9910fb18b7f8b06b8f7d35
---
M util/m5/m5.c
1 file changed, 6 insertions(+), 5 deletions(-)



diff --git a/util/m5/m5.c b/util/m5/m5.c
index 82ef73b..38da9dc 100644
--- a/util/m5/m5.c
+++ b/util/m5/m5.c
@@ -140,7 +140,7 @@
 }

 void
-write_file(const char *filename)
+write_file(const char *filename, const char *host_filename)
 {
     fprintf(stderr, "opening %s\n", filename);
     int src_fid = open(filename, O_RDONLY);
@@ -158,7 +158,7 @@
     memset(buf, 0, sizeof(buf));

     while ((len = read(src_fid, buf, sizeof(buf))) > 0) {
-        bytes += m5_write_file(buf, len, offset, filename);
+        bytes += m5_write_file(buf, len, offset, host_filename);
         offset += len;
     }
     fprintf(stderr, "written %d bytes\n", bytes);
@@ -224,12 +224,13 @@
 void
 do_write_file(int argc, char *argv[])
 {
-    if (argc != 1)
+    if (argc != 1 && argc != 2)
         usage();

     const char *filename = argv[0];
+    const char *host_filename = (argc == 2) ? argv[1] : argv[0];

-    write_file(filename);
+    write_file(filename, host_filename);
 }

 void
@@ -344,7 +345,7 @@
     { "dumpstats",      do_dump_stats,       "[delay [period]]" },
     { "dumpresetstats", do_dump_reset_stats, "[delay [period]]" },
     { "readfile",       do_read_file,        "" },
-    { "writefile",      do_write_file,       "<filename>" },
+ { "writefile", do_write_file, "<filename> [host filename]" },
     { "execfile",       do_exec_file,        "" },
     { "checkpoint",     do_checkpoint,       "[delay [period]]" },
     { "addsymbol",      do_addsymbol,        "<address> <symbol>" },

--
To view, visit https://gem5-review.googlesource.com/4850
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I402925a9ff89665bee9910fb18b7f8b06b8f7d35
Gerrit-Change-Number: 4850
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to