]> Git Repo - binutils.git/blob - gdb/cli/cli-dump.c
Update copyright year range in all GDB files.
[binutils.git] / gdb / cli / cli-dump.c
1 /* Dump-to-file commands, for GDB, the GNU debugger.
2
3    Copyright (C) 2002-2020 Free Software Foundation, Inc.
4
5    Contributed by Red Hat.
6
7    This file is part of GDB.
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
21
22 #include "defs.h"
23 #include "cli/cli-decode.h"
24 #include "cli/cli-cmds.h"
25 #include "value.h"
26 #include "completer.h"
27 #include <ctype.h>
28 #include "target.h"
29 #include "readline/tilde.h"
30 #include "gdbcore.h"
31 #include "cli/cli-utils.h"
32 #include "gdb_bfd.h"
33 #include "gdbsupport/filestuff.h"
34 #include "gdbsupport/byte-vector.h"
35 #include "gdbarch.h"
36
37 static gdb::unique_xmalloc_ptr<char>
38 scan_expression (const char **cmd, const char *def)
39 {
40   if ((*cmd) == NULL || (**cmd) == '\0')
41     return make_unique_xstrdup (def);
42   else
43     {
44       char *exp;
45       const char *end;
46
47       end = (*cmd) + strcspn (*cmd, " \t");
48       exp = savestring ((*cmd), end - (*cmd));
49       (*cmd) = skip_spaces (end);
50       return gdb::unique_xmalloc_ptr<char> (exp);
51     }
52 }
53
54
55 static gdb::unique_xmalloc_ptr<char>
56 scan_filename (const char **cmd, const char *defname)
57 {
58   gdb::unique_xmalloc_ptr<char> filename;
59
60   /* FIXME: Need to get the ``/a(ppend)'' flag from somewhere.  */
61
62   /* File.  */
63   if ((*cmd) == NULL)
64     {
65       if (defname == NULL)
66         error (_("Missing filename."));
67       filename.reset (xstrdup (defname));
68     }
69   else
70     {
71       /* FIXME: should parse a possibly quoted string.  */
72       const char *end;
73
74       (*cmd) = skip_spaces (*cmd);
75       end = *cmd + strcspn (*cmd, " \t");
76       filename.reset (savestring ((*cmd), end - (*cmd)));
77       (*cmd) = skip_spaces (end);
78     }
79   gdb_assert (filename != NULL);
80
81   return gdb::unique_xmalloc_ptr<char> (tilde_expand (filename.get ()));
82 }
83
84 static gdb_bfd_ref_ptr
85 bfd_openr_or_error (const char *filename, const char *target)
86 {
87   gdb_bfd_ref_ptr ibfd (gdb_bfd_openr (filename, target));
88   if (ibfd == NULL)
89     error (_("Failed to open %s: %s."), filename,
90            bfd_errmsg (bfd_get_error ()));
91
92   if (!bfd_check_format (ibfd.get (), bfd_object))
93     error (_("'%s' is not a recognized file format."), filename);
94
95   return ibfd;
96 }
97
98 static gdb_bfd_ref_ptr
99 bfd_openw_or_error (const char *filename, const char *target, const char *mode)
100 {
101   gdb_bfd_ref_ptr obfd;
102
103   if (*mode == 'w')     /* Write: create new file */
104     {
105       obfd = gdb_bfd_openw (filename, target);
106       if (obfd == NULL)
107         error (_("Failed to open %s: %s."), filename,
108                bfd_errmsg (bfd_get_error ()));
109       if (!bfd_set_format (obfd.get (), bfd_object))
110         error (_("bfd_openw_or_error: %s."), bfd_errmsg (bfd_get_error ()));
111     }
112   else if (*mode == 'a')        /* Append to existing file.  */
113     {   /* FIXME -- doesn't work...  */
114       error (_("bfd_openw does not work with append."));
115     }
116   else
117     error (_("bfd_openw_or_error: unknown mode %s."), mode);
118
119   return obfd;
120 }
121
122 static struct cmd_list_element *dump_cmdlist;
123 static struct cmd_list_element *append_cmdlist;
124 static struct cmd_list_element *srec_cmdlist;
125 static struct cmd_list_element *ihex_cmdlist;
126 static struct cmd_list_element *verilog_cmdlist;
127 static struct cmd_list_element *tekhex_cmdlist;
128 static struct cmd_list_element *binary_dump_cmdlist;
129 static struct cmd_list_element *binary_append_cmdlist;
130
131 static void
132 dump_command (const char *cmd, int from_tty)
133 {
134   printf_unfiltered (_("\"dump\" must be followed by a subcommand.\n\n"));
135   help_list (dump_cmdlist, "dump ", all_commands, gdb_stdout);
136 }
137
138 static void
139 append_command (const char *cmd, int from_tty)
140 {
141   printf_unfiltered (_("\"append\" must be followed by a subcommand.\n\n"));
142   help_list (dump_cmdlist, "append ", all_commands, gdb_stdout);
143 }
144
145 static void
146 dump_binary_file (const char *filename, const char *mode, 
147                   const bfd_byte *buf, ULONGEST len)
148 {
149   int status;
150
151   gdb_file_up file = gdb_fopen_cloexec (filename, mode);
152   status = fwrite (buf, len, 1, file.get ());
153   if (status != 1)
154     perror_with_name (filename);
155 }
156
157 static void
158 dump_bfd_file (const char *filename, const char *mode, 
159                const char *target, CORE_ADDR vaddr, 
160                const bfd_byte *buf, ULONGEST len)
161 {
162   asection *osection;
163
164   gdb_bfd_ref_ptr obfd (bfd_openw_or_error (filename, target, mode));
165   osection = bfd_make_section_anyway (obfd.get (), ".newsec");
166   bfd_set_section_size (osection, len);
167   bfd_set_section_vma (osection, vaddr);
168   bfd_set_section_alignment (osection, 0);
169   bfd_set_section_flags (osection, (SEC_HAS_CONTENTS | SEC_ALLOC | SEC_LOAD));
170   osection->entsize = 0;
171   if (!bfd_set_section_contents (obfd.get (), osection, buf, 0, len))
172     warning (_("writing dump file '%s' (%s)"), filename,
173              bfd_errmsg (bfd_get_error ()));
174 }
175
176 static void
177 dump_memory_to_file (const char *cmd, const char *mode, const char *file_format)
178 {
179   CORE_ADDR lo;
180   CORE_ADDR hi;
181   ULONGEST count;
182   const char *hi_exp;
183
184   /* Open the file.  */
185   gdb::unique_xmalloc_ptr<char> filename = scan_filename (&cmd, NULL);
186
187   /* Find the low address.  */
188   if (cmd == NULL || *cmd == '\0')
189     error (_("Missing start address."));
190   gdb::unique_xmalloc_ptr<char> lo_exp = scan_expression (&cmd, NULL);
191
192   /* Find the second address - rest of line.  */
193   if (cmd == NULL || *cmd == '\0')
194     error (_("Missing stop address."));
195   hi_exp = cmd;
196
197   lo = parse_and_eval_address (lo_exp.get ());
198   hi = parse_and_eval_address (hi_exp);
199   if (hi <= lo)
200     error (_("Invalid memory address range (start >= end)."));
201   count = hi - lo;
202
203   /* FIXME: Should use read_memory_partial() and a magic blocking
204      value.  */
205   gdb::byte_vector buf (count);
206   read_memory (lo, buf.data (), count);
207   
208   /* Have everything.  Open/write the data.  */
209   if (file_format == NULL || strcmp (file_format, "binary") == 0)
210     dump_binary_file (filename.get (), mode, buf.data (), count);
211   else
212     dump_bfd_file (filename.get (), mode, file_format, lo, buf.data (), count);
213 }
214
215 static void
216 dump_memory_command (const char *cmd, const char *mode)
217 {
218   dump_memory_to_file (cmd, mode, "binary");
219 }
220
221 static void
222 dump_value_to_file (const char *cmd, const char *mode, const char *file_format)
223 {
224   struct value *val;
225
226   /* Open the file.  */
227   gdb::unique_xmalloc_ptr<char> filename = scan_filename (&cmd, NULL);
228
229   /* Find the value.  */
230   if (cmd == NULL || *cmd == '\0')
231     error (_("No value to %s."), *mode == 'a' ? "append" : "dump");
232   val = parse_and_eval (cmd);
233   if (val == NULL)
234     error (_("Invalid expression."));
235
236   /* Have everything.  Open/write the data.  */
237   if (file_format == NULL || strcmp (file_format, "binary") == 0)
238     dump_binary_file (filename.get (), mode, value_contents (val),
239                       TYPE_LENGTH (value_type (val)));
240   else
241     {
242       CORE_ADDR vaddr;
243
244       if (VALUE_LVAL (val))
245         {
246           vaddr = value_address (val);
247         }
248       else
249         {
250           vaddr = 0;
251           warning (_("value is not an lval: address assumed to be zero"));
252         }
253
254       dump_bfd_file (filename.get (), mode, file_format, vaddr,
255                      value_contents (val), 
256                      TYPE_LENGTH (value_type (val)));
257     }
258 }
259
260 static void
261 dump_value_command (const char *cmd, const char *mode)
262 {
263   dump_value_to_file (cmd, mode, "binary");
264 }
265
266 static void
267 dump_srec_memory (const char *args, int from_tty)
268 {
269   dump_memory_to_file (args, FOPEN_WB, "srec");
270 }
271
272 static void
273 dump_srec_value (const char *args, int from_tty)
274 {
275   dump_value_to_file (args, FOPEN_WB, "srec");
276 }
277
278 static void
279 dump_ihex_memory (const char *args, int from_tty)
280 {
281   dump_memory_to_file (args, FOPEN_WB, "ihex");
282 }
283
284 static void
285 dump_ihex_value (const char *args, int from_tty)
286 {
287   dump_value_to_file (args, FOPEN_WB, "ihex");
288 }
289
290 static void
291 dump_verilog_memory (const char *args, int from_tty)
292 {
293   dump_memory_to_file (args, FOPEN_WB, "verilog");
294 }
295
296 static void
297 dump_verilog_value (const char *args, int from_tty)
298 {
299   dump_value_to_file (args, FOPEN_WB, "verilog");
300 }
301
302 static void
303 dump_tekhex_memory (const char *args, int from_tty)
304 {
305   dump_memory_to_file (args, FOPEN_WB, "tekhex");
306 }
307
308 static void
309 dump_tekhex_value (const char *args, int from_tty)
310 {
311   dump_value_to_file (args, FOPEN_WB, "tekhex");
312 }
313
314 static void
315 dump_binary_memory (const char *args, int from_tty)
316 {
317   dump_memory_to_file (args, FOPEN_WB, "binary");
318 }
319
320 static void
321 dump_binary_value (const char *args, int from_tty)
322 {
323   dump_value_to_file (args, FOPEN_WB, "binary");
324 }
325
326 static void
327 append_binary_memory (const char *args, int from_tty)
328 {
329   dump_memory_to_file (args, FOPEN_AB, "binary");
330 }
331
332 static void
333 append_binary_value (const char *args, int from_tty)
334 {
335   dump_value_to_file (args, FOPEN_AB, "binary");
336 }
337
338 struct dump_context
339 {
340   void (*func) (const char *cmd, const char *mode);
341   const char *mode;
342 };
343
344 static void
345 call_dump_func (struct cmd_list_element *c, const char *args, int from_tty)
346 {
347   struct dump_context *d = (struct dump_context *) get_cmd_context (c);
348
349   d->func (args, d->mode);
350 }
351
352 static void
353 add_dump_command (const char *name,
354                   void (*func) (const char *args, const char *mode),
355                   const char *descr)
356
357 {
358   struct cmd_list_element *c;
359   struct dump_context *d;
360
361   c = add_cmd (name, all_commands, descr, &dump_cmdlist);
362   c->completer =  filename_completer;
363   d = XNEW (struct dump_context);
364   d->func = func;
365   d->mode = FOPEN_WB;
366   set_cmd_context (c, d);
367   c->func = call_dump_func;
368
369   c = add_cmd (name, all_commands, descr, &append_cmdlist);
370   c->completer =  filename_completer;
371   d = XNEW (struct dump_context);
372   d->func = func;
373   d->mode = FOPEN_AB;
374   set_cmd_context (c, d);
375   c->func = call_dump_func;
376
377   /* Replace "Dump " at start of docstring with "Append " (borrowed
378      from [deleted] deprecated_add_show_from_set).  */
379   if (   c->doc[0] == 'W' 
380       && c->doc[1] == 'r' 
381       && c->doc[2] == 'i'
382       && c->doc[3] == 't' 
383       && c->doc[4] == 'e'
384       && c->doc[5] == ' ')
385     c->doc = concat ("Append ", c->doc + 6, (char *)NULL);
386 }
387
388 /* Opaque data for restore_section_callback.  */
389 struct callback_data {
390   CORE_ADDR load_offset;
391   CORE_ADDR load_start;
392   CORE_ADDR load_end;
393 };
394
395 /* Function: restore_section_callback.
396
397    Callback function for bfd_map_over_sections.
398    Selectively loads the sections into memory.  */
399
400 static void
401 restore_section_callback (bfd *ibfd, asection *isec, void *args)
402 {
403   struct callback_data *data = (struct callback_data *) args;
404   bfd_vma sec_start  = bfd_section_vma (isec);
405   bfd_size_type size = bfd_section_size (isec);
406   bfd_vma sec_end    = sec_start + size;
407   bfd_size_type sec_offset = 0;
408   bfd_size_type sec_load_count = size;
409   int ret;
410
411   /* Ignore non-loadable sections, eg. from elf files.  */
412   if (!(bfd_section_flags (isec) & SEC_LOAD))
413     return;
414
415   /* Does the section overlap with the desired restore range? */
416   if (sec_end <= data->load_start 
417       || (data->load_end > 0 && sec_start >= data->load_end))
418     {
419       /* No, no useable data in this section.  */
420       printf_filtered (_("skipping section %s...\n"), 
421                        bfd_section_name (isec));
422       return;
423     }
424
425   /* Compare section address range with user-requested
426      address range (if any).  Compute where the actual
427      transfer should start and end.  */
428   if (sec_start < data->load_start)
429     sec_offset = data->load_start - sec_start;
430   /* Size of a partial transfer.  */
431   sec_load_count -= sec_offset;
432   if (data->load_end > 0 && sec_end > data->load_end)
433     sec_load_count -= sec_end - data->load_end;
434
435   /* Get the data.  */
436   gdb::byte_vector buf (size);
437   if (!bfd_get_section_contents (ibfd, isec, buf.data (), 0, size))
438     error (_("Failed to read bfd file %s: '%s'."), bfd_get_filename (ibfd), 
439            bfd_errmsg (bfd_get_error ()));
440
441   printf_filtered ("Restoring section %s (0x%lx to 0x%lx)",
442                    bfd_section_name (isec), 
443                    (unsigned long) sec_start, 
444                    (unsigned long) sec_end);
445
446   if (data->load_offset != 0 || data->load_start != 0 || data->load_end != 0)
447     printf_filtered (" into memory (%s to %s)\n",
448                      paddress (target_gdbarch (),
449                                (unsigned long) sec_start
450                                + sec_offset + data->load_offset), 
451                      paddress (target_gdbarch (),
452                                (unsigned long) sec_start + sec_offset
453                                 + data->load_offset + sec_load_count));
454   else
455     puts_filtered ("\n");
456
457   /* Write the data.  */
458   ret = target_write_memory (sec_start + sec_offset + data->load_offset, 
459                              &buf[sec_offset], sec_load_count);
460   if (ret != 0)
461     warning (_("restore: memory write failed (%s)."), safe_strerror (ret));
462 }
463
464 static void
465 restore_binary_file (const char *filename, struct callback_data *data)
466 {
467   gdb_file_up file = gdb_fopen_cloexec (filename, FOPEN_RB);
468   long len;
469
470   if (file == NULL)
471     error (_("Failed to open %s: %s"), filename, safe_strerror (errno));
472
473   /* Get the file size for reading.  */
474   if (fseek (file.get (), 0, SEEK_END) == 0)
475     {
476       len = ftell (file.get ());
477       if (len < 0)
478         perror_with_name (filename);
479     }
480   else
481     perror_with_name (filename);
482
483   if (len <= data->load_start)
484     error (_("Start address is greater than length of binary file %s."), 
485            filename);
486
487   /* Chop off "len" if it exceeds the requested load_end addr.  */
488   if (data->load_end != 0 && data->load_end < len)
489     len = data->load_end;
490   /* Chop off "len" if the requested load_start addr skips some bytes.  */
491   if (data->load_start > 0)
492     len -= data->load_start;
493
494   printf_filtered 
495     ("Restoring binary file %s into memory (0x%lx to 0x%lx)\n", 
496      filename, 
497      (unsigned long) (data->load_start + data->load_offset),
498      (unsigned long) (data->load_start + data->load_offset + len));
499
500   /* Now set the file pos to the requested load start pos.  */
501   if (fseek (file.get (), data->load_start, SEEK_SET) != 0)
502     perror_with_name (filename);
503
504   /* Now allocate a buffer and read the file contents.  */
505   gdb::byte_vector buf (len);
506   if (fread (buf.data (), 1, len, file.get ()) != len)
507     perror_with_name (filename);
508
509   /* Now write the buffer into target memory.  */
510   len = target_write_memory (data->load_start + data->load_offset,
511                              buf.data (), len);
512   if (len != 0)
513     warning (_("restore: memory write failed (%s)."), safe_strerror (len));
514 }
515
516 static void
517 restore_command (const char *args, int from_tty)
518 {
519   struct callback_data data;
520   int binary_flag = 0;
521
522   if (!target_has_execution)
523     noprocess ();
524
525   data.load_offset = 0;
526   data.load_start  = 0;
527   data.load_end    = 0;
528
529   /* Parse the input arguments.  First is filename (required).  */
530   gdb::unique_xmalloc_ptr<char> filename = scan_filename (&args, NULL);
531   if (args != NULL && *args != '\0')
532     {
533       static const char binary_string[] = "binary";
534
535       /* Look for optional "binary" flag.  */
536       if (startswith (args, binary_string))
537         {
538           binary_flag = 1;
539           args += strlen (binary_string);
540           args = skip_spaces (args);
541         }
542       /* Parse offset (optional).  */
543       if (args != NULL && *args != '\0')
544         data.load_offset = binary_flag ?
545           parse_and_eval_address (scan_expression (&args, NULL).get ()) :
546           parse_and_eval_long (scan_expression (&args, NULL).get ());
547       if (args != NULL && *args != '\0')
548         {
549           /* Parse start address (optional).  */
550           data.load_start = 
551             parse_and_eval_long (scan_expression (&args, NULL).get ());
552           if (args != NULL && *args != '\0')
553             {
554               /* Parse end address (optional).  */
555               data.load_end = parse_and_eval_long (args);
556               if (data.load_end <= data.load_start)
557                 error (_("Start must be less than end."));
558             }
559         }
560     }
561
562   if (info_verbose)
563     printf_filtered ("Restore file %s offset 0x%lx start 0x%lx end 0x%lx\n",
564                      filename.get (), (unsigned long) data.load_offset,
565                      (unsigned long) data.load_start, 
566                      (unsigned long) data.load_end);
567
568   if (binary_flag)
569     {
570       restore_binary_file (filename.get (), &data);
571     }
572   else
573     {
574       /* Open the file for loading.  */
575       gdb_bfd_ref_ptr ibfd (bfd_openr_or_error (filename.get (), NULL));
576
577       /* Process the sections.  */
578       bfd_map_over_sections (ibfd.get (), restore_section_callback, &data);
579     }
580 }
581
582 static void
583 srec_dump_command (const char *cmd, int from_tty)
584 {
585   printf_unfiltered (_("\"dump srec\" must be followed by a subcommand.\n"));
586   help_list (srec_cmdlist, "dump srec ", all_commands, gdb_stdout);
587 }
588
589 static void
590 ihex_dump_command (const char *cmd, int from_tty)
591 {
592   printf_unfiltered (_("\"dump ihex\" must be followed by a subcommand.\n"));
593   help_list (ihex_cmdlist, "dump ihex ", all_commands, gdb_stdout);
594 }
595
596 static void
597 verilog_dump_command (const char *cmd, int from_tty)
598 {
599   printf_unfiltered (_("\"dump verilog\" must be followed by a subcommand.\n"));
600   help_list (verilog_cmdlist, "dump verilog ", all_commands, gdb_stdout);
601 }
602
603 static void
604 tekhex_dump_command (const char *cmd, int from_tty)
605 {
606   printf_unfiltered (_("\"dump tekhex\" must be followed by a subcommand.\n"));
607   help_list (tekhex_cmdlist, "dump tekhex ", all_commands, gdb_stdout);
608 }
609
610 static void
611 binary_dump_command (const char *cmd, int from_tty)
612 {
613   printf_unfiltered (_("\"dump binary\" must be followed by a subcommand.\n"));
614   help_list (binary_dump_cmdlist, "dump binary ", all_commands, gdb_stdout);
615 }
616
617 static void
618 binary_append_command (const char *cmd, int from_tty)
619 {
620   printf_unfiltered (_("\"append binary\" must be followed by a subcommand.\n"));
621   help_list (binary_append_cmdlist, "append binary ", all_commands,
622              gdb_stdout);
623 }
624
625 void
626 _initialize_cli_dump (void)
627 {
628   struct cmd_list_element *c;
629
630   add_prefix_cmd ("dump", class_vars, dump_command,
631                   _("Dump target code/data to a local file."),
632                   &dump_cmdlist, "dump ",
633                   0/*allow-unknown*/,
634                   &cmdlist);
635   add_prefix_cmd ("append", class_vars, append_command,
636                   _("Append target code/data to a local file."),
637                   &append_cmdlist, "append ",
638                   0/*allow-unknown*/,
639                   &cmdlist);
640
641   add_dump_command ("memory", dump_memory_command, "\
642 Write contents of memory to a raw binary file.\n\
643 Arguments are FILE START STOP.  Writes the contents of memory within the\n\
644 range [START .. STOP) to the specified FILE in raw target ordered bytes.");
645
646   add_dump_command ("value", dump_value_command, "\
647 Write the value of an expression to a raw binary file.\n\
648 Arguments are FILE EXPRESSION.  Writes the value of EXPRESSION to\n\
649 the specified FILE in raw target ordered bytes.");
650
651   add_prefix_cmd ("srec", all_commands, srec_dump_command,
652                   _("Write target code/data to an srec file."),
653                   &srec_cmdlist, "dump srec ", 
654                   0 /*allow-unknown*/, 
655                   &dump_cmdlist);
656
657   add_prefix_cmd ("ihex", all_commands, ihex_dump_command,
658                   _("Write target code/data to an intel hex file."),
659                   &ihex_cmdlist, "dump ihex ", 
660                   0 /*allow-unknown*/, 
661                   &dump_cmdlist);
662
663   add_prefix_cmd ("verilog", all_commands, verilog_dump_command,
664                   _("Write target code/data to a verilog hex file."),
665                   &verilog_cmdlist, "dump verilog ",
666                   0 /*allow-unknown*/,
667                   &dump_cmdlist);
668
669   add_prefix_cmd ("tekhex", all_commands, tekhex_dump_command,
670                   _("Write target code/data to a tekhex file."),
671                   &tekhex_cmdlist, "dump tekhex ", 
672                   0 /*allow-unknown*/, 
673                   &dump_cmdlist);
674
675   add_prefix_cmd ("binary", all_commands, binary_dump_command,
676                   _("Write target code/data to a raw binary file."),
677                   &binary_dump_cmdlist, "dump binary ", 
678                   0 /*allow-unknown*/, 
679                   &dump_cmdlist);
680
681   add_prefix_cmd ("binary", all_commands, binary_append_command,
682                   _("Append target code/data to a raw binary file."),
683                   &binary_append_cmdlist, "append binary ", 
684                   0 /*allow-unknown*/, 
685                   &append_cmdlist);
686
687   add_cmd ("memory", all_commands, dump_srec_memory, _("\
688 Write contents of memory to an srec file.\n\
689 Arguments are FILE START STOP.  Writes the contents of memory\n\
690 within the range [START .. STOP) to the specified FILE in srec format."),
691            &srec_cmdlist);
692
693   add_cmd ("value", all_commands, dump_srec_value, _("\
694 Write the value of an expression to an srec file.\n\
695 Arguments are FILE EXPRESSION.  Writes the value of EXPRESSION\n\
696 to the specified FILE in srec format."),
697            &srec_cmdlist);
698
699   add_cmd ("memory", all_commands, dump_ihex_memory, _("\
700 Write contents of memory to an ihex file.\n\
701 Arguments are FILE START STOP.  Writes the contents of memory within\n\
702 the range [START .. STOP) to the specified FILE in intel hex format."),
703            &ihex_cmdlist);
704
705   add_cmd ("value", all_commands, dump_ihex_value, _("\
706 Write the value of an expression to an ihex file.\n\
707 Arguments are FILE EXPRESSION.  Writes the value of EXPRESSION\n\
708 to the specified FILE in intel hex format."),
709            &ihex_cmdlist);
710
711   add_cmd ("memory", all_commands, dump_verilog_memory, _("\
712 Write contents of memory to a verilog hex file.\n\
713 Arguments are FILE START STOP.  Writes the contents of memory within\n\
714 the range [START .. STOP) to the specified FILE in verilog hex format."),
715            &verilog_cmdlist);
716
717   add_cmd ("value", all_commands, dump_verilog_value, _("\
718 Write the value of an expression to a verilog hex file.\n\
719 Arguments are FILE EXPRESSION.  Writes the value of EXPRESSION\n\
720 to the specified FILE in verilog hex format."),
721            &verilog_cmdlist);
722
723   add_cmd ("memory", all_commands, dump_tekhex_memory, _("\
724 Write contents of memory to a tekhex file.\n\
725 Arguments are FILE START STOP.  Writes the contents of memory\n\
726 within the range [START .. STOP) to the specified FILE in tekhex format."),
727            &tekhex_cmdlist);
728
729   add_cmd ("value", all_commands, dump_tekhex_value, _("\
730 Write the value of an expression to a tekhex file.\n\
731 Arguments are FILE EXPRESSION.  Writes the value of EXPRESSION\n\
732 to the specified FILE in tekhex format."),
733            &tekhex_cmdlist);
734
735   add_cmd ("memory", all_commands, dump_binary_memory, _("\
736 Write contents of memory to a raw binary file.\n\
737 Arguments are FILE START STOP.  Writes the contents of memory\n\
738 within the range [START .. STOP) to the specified FILE in binary format."),
739            &binary_dump_cmdlist);
740
741   add_cmd ("value", all_commands, dump_binary_value, _("\
742 Write the value of an expression to a raw binary file.\n\
743 Arguments are FILE EXPRESSION.  Writes the value of EXPRESSION\n\
744 to the specified FILE in raw target ordered bytes."),
745            &binary_dump_cmdlist);
746
747   add_cmd ("memory", all_commands, append_binary_memory, _("\
748 Append contents of memory to a raw binary file.\n\
749 Arguments are FILE START STOP.  Writes the contents of memory within the\n\
750 range [START .. STOP) to the specified FILE in raw target ordered bytes."),
751            &binary_append_cmdlist);
752
753   add_cmd ("value", all_commands, append_binary_value, _("\
754 Append the value of an expression to a raw binary file.\n\
755 Arguments are FILE EXPRESSION.  Writes the value of EXPRESSION\n\
756 to the specified FILE in raw target ordered bytes."),
757            &binary_append_cmdlist);
758
759   c = add_com ("restore", class_vars, restore_command, _("\
760 Restore the contents of FILE to target memory.\n\
761 Arguments are FILE OFFSET START END where all except FILE are optional.\n\
762 OFFSET will be added to the base address of the file (default zero).\n\
763 If START and END are given, only the file contents within that range\n\
764 (file relative) will be restored to target memory."));
765   c->completer = filename_completer;
766   /* FIXME: completers for other commands.  */
767 }
This page took 0.06832 seconds and 4 git commands to generate.