GDB (API)
|
00001 /* Dump-to-file commands, for GDB, the GNU debugger. 00002 00003 Copyright (C) 2002-2013 Free Software Foundation, Inc. 00004 00005 Contributed by Red Hat. 00006 00007 This file is part of GDB. 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00021 00022 #include "defs.h" 00023 #include "gdb_string.h" 00024 #include "cli/cli-decode.h" 00025 #include "cli/cli-cmds.h" 00026 #include "value.h" 00027 #include "completer.h" 00028 #include "gdb_assert.h" 00029 #include <ctype.h> 00030 #include "target.h" 00031 #include "readline/readline.h" 00032 #include "gdbcore.h" 00033 #include "cli/cli-utils.h" 00034 #include "gdb_bfd.h" 00035 #include "filestuff.h" 00036 00037 00038 static char * 00039 scan_expression_with_cleanup (char **cmd, const char *def) 00040 { 00041 if ((*cmd) == NULL || (**cmd) == '\0') 00042 { 00043 char *exp = xstrdup (def); 00044 00045 make_cleanup (xfree, exp); 00046 return exp; 00047 } 00048 else 00049 { 00050 char *exp; 00051 char *end; 00052 00053 end = (*cmd) + strcspn (*cmd, " \t"); 00054 exp = savestring ((*cmd), end - (*cmd)); 00055 make_cleanup (xfree, exp); 00056 (*cmd) = skip_spaces (end); 00057 return exp; 00058 } 00059 } 00060 00061 00062 static char * 00063 scan_filename_with_cleanup (char **cmd, const char *defname) 00064 { 00065 char *filename; 00066 char *fullname; 00067 00068 /* FIXME: Need to get the ``/a(ppend)'' flag from somewhere. */ 00069 00070 /* File. */ 00071 if ((*cmd) == NULL) 00072 { 00073 if (defname == NULL) 00074 error (_("Missing filename.")); 00075 filename = xstrdup (defname); 00076 make_cleanup (xfree, filename); 00077 } 00078 else 00079 { 00080 /* FIXME: should parse a possibly quoted string. */ 00081 char *end; 00082 00083 (*cmd) = skip_spaces (*cmd); 00084 end = *cmd + strcspn (*cmd, " \t"); 00085 filename = savestring ((*cmd), end - (*cmd)); 00086 make_cleanup (xfree, filename); 00087 (*cmd) = skip_spaces (end); 00088 } 00089 gdb_assert (filename != NULL); 00090 00091 fullname = tilde_expand (filename); 00092 make_cleanup (xfree, fullname); 00093 00094 return fullname; 00095 } 00096 00097 static FILE * 00098 fopen_with_cleanup (const char *filename, const char *mode) 00099 { 00100 FILE *file = gdb_fopen_cloexec (filename, mode); 00101 00102 if (file == NULL) 00103 perror_with_name (filename); 00104 make_cleanup_fclose (file); 00105 return file; 00106 } 00107 00108 static bfd * 00109 bfd_openr_with_cleanup (const char *filename, const char *target) 00110 { 00111 bfd *ibfd; 00112 00113 ibfd = gdb_bfd_openr (filename, target); 00114 if (ibfd == NULL) 00115 error (_("Failed to open %s: %s."), filename, 00116 bfd_errmsg (bfd_get_error ())); 00117 00118 make_cleanup_bfd_unref (ibfd); 00119 if (!bfd_check_format (ibfd, bfd_object)) 00120 error (_("'%s' is not a recognized file format."), filename); 00121 00122 return ibfd; 00123 } 00124 00125 static bfd * 00126 bfd_openw_with_cleanup (const char *filename, const char *target, 00127 const char *mode) 00128 { 00129 bfd *obfd; 00130 00131 if (*mode == 'w') /* Write: create new file */ 00132 { 00133 obfd = gdb_bfd_openw (filename, target); 00134 if (obfd == NULL) 00135 error (_("Failed to open %s: %s."), filename, 00136 bfd_errmsg (bfd_get_error ())); 00137 make_cleanup_bfd_unref (obfd); 00138 if (!bfd_set_format (obfd, bfd_object)) 00139 error (_("bfd_openw_with_cleanup: %s."), bfd_errmsg (bfd_get_error ())); 00140 } 00141 else if (*mode == 'a') /* Append to existing file. */ 00142 { /* FIXME -- doesn't work... */ 00143 error (_("bfd_openw does not work with append.")); 00144 } 00145 else 00146 error (_("bfd_openw_with_cleanup: unknown mode %s."), mode); 00147 00148 return obfd; 00149 } 00150 00151 static struct cmd_list_element *dump_cmdlist; 00152 static struct cmd_list_element *append_cmdlist; 00153 static struct cmd_list_element *srec_cmdlist; 00154 static struct cmd_list_element *ihex_cmdlist; 00155 static struct cmd_list_element *tekhex_cmdlist; 00156 static struct cmd_list_element *binary_dump_cmdlist; 00157 static struct cmd_list_element *binary_append_cmdlist; 00158 00159 static void 00160 dump_command (char *cmd, int from_tty) 00161 { 00162 printf_unfiltered (_("\"dump\" must be followed by a subcommand.\n\n")); 00163 help_list (dump_cmdlist, "dump ", -1, gdb_stdout); 00164 } 00165 00166 static void 00167 append_command (char *cmd, int from_tty) 00168 { 00169 printf_unfiltered (_("\"append\" must be followed by a subcommand.\n\n")); 00170 help_list (dump_cmdlist, "append ", -1, gdb_stdout); 00171 } 00172 00173 static void 00174 dump_binary_file (const char *filename, const char *mode, 00175 const bfd_byte *buf, ULONGEST len) 00176 { 00177 FILE *file; 00178 int status; 00179 00180 file = fopen_with_cleanup (filename, mode); 00181 status = fwrite (buf, len, 1, file); 00182 if (status != 1) 00183 perror_with_name (filename); 00184 } 00185 00186 static void 00187 dump_bfd_file (const char *filename, const char *mode, 00188 const char *target, CORE_ADDR vaddr, 00189 const bfd_byte *buf, ULONGEST len) 00190 { 00191 bfd *obfd; 00192 asection *osection; 00193 00194 obfd = bfd_openw_with_cleanup (filename, target, mode); 00195 osection = bfd_make_section_anyway (obfd, ".newsec"); 00196 bfd_set_section_size (obfd, osection, len); 00197 bfd_set_section_vma (obfd, osection, vaddr); 00198 bfd_set_section_alignment (obfd, osection, 0); 00199 bfd_set_section_flags (obfd, osection, (SEC_HAS_CONTENTS 00200 | SEC_ALLOC 00201 | SEC_LOAD)); 00202 osection->entsize = 0; 00203 if (!bfd_set_section_contents (obfd, osection, buf, 0, len)) 00204 warning (_("writing dump file '%s' (%s)"), filename, 00205 bfd_errmsg (bfd_get_error ())); 00206 } 00207 00208 static void 00209 dump_memory_to_file (char *cmd, char *mode, char *file_format) 00210 { 00211 struct cleanup *old_cleanups = make_cleanup (null_cleanup, NULL); 00212 CORE_ADDR lo; 00213 CORE_ADDR hi; 00214 ULONGEST count; 00215 char *filename; 00216 void *buf; 00217 char *lo_exp; 00218 char *hi_exp; 00219 00220 /* Open the file. */ 00221 filename = scan_filename_with_cleanup (&cmd, NULL); 00222 00223 /* Find the low address. */ 00224 if (cmd == NULL || *cmd == '\0') 00225 error (_("Missing start address.")); 00226 lo_exp = scan_expression_with_cleanup (&cmd, NULL); 00227 00228 /* Find the second address - rest of line. */ 00229 if (cmd == NULL || *cmd == '\0') 00230 error (_("Missing stop address.")); 00231 hi_exp = cmd; 00232 00233 lo = parse_and_eval_address (lo_exp); 00234 hi = parse_and_eval_address (hi_exp); 00235 if (hi <= lo) 00236 error (_("Invalid memory address range (start >= end).")); 00237 count = hi - lo; 00238 00239 /* FIXME: Should use read_memory_partial() and a magic blocking 00240 value. */ 00241 buf = xmalloc (count); 00242 make_cleanup (xfree, buf); 00243 read_memory (lo, buf, count); 00244 00245 /* Have everything. Open/write the data. */ 00246 if (file_format == NULL || strcmp (file_format, "binary") == 0) 00247 { 00248 dump_binary_file (filename, mode, buf, count); 00249 } 00250 else 00251 { 00252 dump_bfd_file (filename, mode, file_format, lo, buf, count); 00253 } 00254 00255 do_cleanups (old_cleanups); 00256 } 00257 00258 static void 00259 dump_memory_command (char *cmd, char *mode) 00260 { 00261 dump_memory_to_file (cmd, mode, "binary"); 00262 } 00263 00264 static void 00265 dump_value_to_file (char *cmd, char *mode, char *file_format) 00266 { 00267 struct cleanup *old_cleanups = make_cleanup (null_cleanup, NULL); 00268 struct value *val; 00269 char *filename; 00270 00271 /* Open the file. */ 00272 filename = scan_filename_with_cleanup (&cmd, NULL); 00273 00274 /* Find the value. */ 00275 if (cmd == NULL || *cmd == '\0') 00276 error (_("No value to %s."), *mode == 'a' ? "append" : "dump"); 00277 val = parse_and_eval (cmd); 00278 if (val == NULL) 00279 error (_("Invalid expression.")); 00280 00281 /* Have everything. Open/write the data. */ 00282 if (file_format == NULL || strcmp (file_format, "binary") == 0) 00283 { 00284 dump_binary_file (filename, mode, value_contents (val), 00285 TYPE_LENGTH (value_type (val))); 00286 } 00287 else 00288 { 00289 CORE_ADDR vaddr; 00290 00291 if (VALUE_LVAL (val)) 00292 { 00293 vaddr = value_address (val); 00294 } 00295 else 00296 { 00297 vaddr = 0; 00298 warning (_("value is not an lval: address assumed to be zero")); 00299 } 00300 00301 dump_bfd_file (filename, mode, file_format, vaddr, 00302 value_contents (val), 00303 TYPE_LENGTH (value_type (val))); 00304 } 00305 00306 do_cleanups (old_cleanups); 00307 } 00308 00309 static void 00310 dump_value_command (char *cmd, char *mode) 00311 { 00312 dump_value_to_file (cmd, mode, "binary"); 00313 } 00314 00315 static void 00316 dump_srec_memory (char *args, int from_tty) 00317 { 00318 dump_memory_to_file (args, FOPEN_WB, "srec"); 00319 } 00320 00321 static void 00322 dump_srec_value (char *args, int from_tty) 00323 { 00324 dump_value_to_file (args, FOPEN_WB, "srec"); 00325 } 00326 00327 static void 00328 dump_ihex_memory (char *args, int from_tty) 00329 { 00330 dump_memory_to_file (args, FOPEN_WB, "ihex"); 00331 } 00332 00333 static void 00334 dump_ihex_value (char *args, int from_tty) 00335 { 00336 dump_value_to_file (args, FOPEN_WB, "ihex"); 00337 } 00338 00339 static void 00340 dump_tekhex_memory (char *args, int from_tty) 00341 { 00342 dump_memory_to_file (args, FOPEN_WB, "tekhex"); 00343 } 00344 00345 static void 00346 dump_tekhex_value (char *args, int from_tty) 00347 { 00348 dump_value_to_file (args, FOPEN_WB, "tekhex"); 00349 } 00350 00351 static void 00352 dump_binary_memory (char *args, int from_tty) 00353 { 00354 dump_memory_to_file (args, FOPEN_WB, "binary"); 00355 } 00356 00357 static void 00358 dump_binary_value (char *args, int from_tty) 00359 { 00360 dump_value_to_file (args, FOPEN_WB, "binary"); 00361 } 00362 00363 static void 00364 append_binary_memory (char *args, int from_tty) 00365 { 00366 dump_memory_to_file (args, FOPEN_AB, "binary"); 00367 } 00368 00369 static void 00370 append_binary_value (char *args, int from_tty) 00371 { 00372 dump_value_to_file (args, FOPEN_AB, "binary"); 00373 } 00374 00375 struct dump_context 00376 { 00377 void (*func) (char *cmd, char *mode); 00378 char *mode; 00379 }; 00380 00381 static void 00382 call_dump_func (struct cmd_list_element *c, char *args, int from_tty) 00383 { 00384 struct dump_context *d = get_cmd_context (c); 00385 00386 d->func (args, d->mode); 00387 } 00388 00389 static void 00390 add_dump_command (char *name, void (*func) (char *args, char *mode), 00391 char *descr) 00392 00393 { 00394 struct cmd_list_element *c; 00395 struct dump_context *d; 00396 00397 c = add_cmd (name, all_commands, NULL, descr, &dump_cmdlist); 00398 c->completer = filename_completer; 00399 d = XMALLOC (struct dump_context); 00400 d->func = func; 00401 d->mode = FOPEN_WB; 00402 set_cmd_context (c, d); 00403 c->func = call_dump_func; 00404 00405 c = add_cmd (name, all_commands, NULL, descr, &append_cmdlist); 00406 c->completer = filename_completer; 00407 d = XMALLOC (struct dump_context); 00408 d->func = func; 00409 d->mode = FOPEN_AB; 00410 set_cmd_context (c, d); 00411 c->func = call_dump_func; 00412 00413 /* Replace "Dump " at start of docstring with "Append " (borrowed 00414 from [deleted] deprecated_add_show_from_set). */ 00415 if ( c->doc[0] == 'W' 00416 && c->doc[1] == 'r' 00417 && c->doc[2] == 'i' 00418 && c->doc[3] == 't' 00419 && c->doc[4] == 'e' 00420 && c->doc[5] == ' ') 00421 c->doc = concat ("Append ", c->doc + 6, (char *)NULL); 00422 } 00423 00424 /* Opaque data for restore_section_callback. */ 00425 struct callback_data { 00426 CORE_ADDR load_offset; 00427 CORE_ADDR load_start; 00428 CORE_ADDR load_end; 00429 }; 00430 00431 /* Function: restore_section_callback. 00432 00433 Callback function for bfd_map_over_sections. 00434 Selectively loads the sections into memory. */ 00435 00436 static void 00437 restore_section_callback (bfd *ibfd, asection *isec, void *args) 00438 { 00439 struct callback_data *data = args; 00440 bfd_vma sec_start = bfd_section_vma (ibfd, isec); 00441 bfd_size_type size = bfd_section_size (ibfd, isec); 00442 bfd_vma sec_end = sec_start + size; 00443 bfd_size_type sec_offset = 0; 00444 bfd_size_type sec_load_count = size; 00445 struct cleanup *old_chain; 00446 gdb_byte *buf; 00447 int ret; 00448 00449 /* Ignore non-loadable sections, eg. from elf files. */ 00450 if (!(bfd_get_section_flags (ibfd, isec) & SEC_LOAD)) 00451 return; 00452 00453 /* Does the section overlap with the desired restore range? */ 00454 if (sec_end <= data->load_start 00455 || (data->load_end > 0 && sec_start >= data->load_end)) 00456 { 00457 /* No, no useable data in this section. */ 00458 printf_filtered (_("skipping section %s...\n"), 00459 bfd_section_name (ibfd, isec)); 00460 return; 00461 } 00462 00463 /* Compare section address range with user-requested 00464 address range (if any). Compute where the actual 00465 transfer should start and end. */ 00466 if (sec_start < data->load_start) 00467 sec_offset = data->load_start - sec_start; 00468 /* Size of a partial transfer. */ 00469 sec_load_count -= sec_offset; 00470 if (data->load_end > 0 && sec_end > data->load_end) 00471 sec_load_count -= sec_end - data->load_end; 00472 00473 /* Get the data. */ 00474 buf = xmalloc (size); 00475 old_chain = make_cleanup (xfree, buf); 00476 if (!bfd_get_section_contents (ibfd, isec, buf, 0, size)) 00477 error (_("Failed to read bfd file %s: '%s'."), bfd_get_filename (ibfd), 00478 bfd_errmsg (bfd_get_error ())); 00479 00480 printf_filtered ("Restoring section %s (0x%lx to 0x%lx)", 00481 bfd_section_name (ibfd, isec), 00482 (unsigned long) sec_start, 00483 (unsigned long) sec_end); 00484 00485 if (data->load_offset != 0 || data->load_start != 0 || data->load_end != 0) 00486 printf_filtered (" into memory (%s to %s)\n", 00487 paddress (target_gdbarch (), 00488 (unsigned long) sec_start 00489 + sec_offset + data->load_offset), 00490 paddress (target_gdbarch (), 00491 (unsigned long) sec_start + sec_offset 00492 + data->load_offset + sec_load_count)); 00493 else 00494 puts_filtered ("\n"); 00495 00496 /* Write the data. */ 00497 ret = target_write_memory (sec_start + sec_offset + data->load_offset, 00498 buf + sec_offset, sec_load_count); 00499 if (ret != 0) 00500 warning (_("restore: memory write failed (%s)."), safe_strerror (ret)); 00501 do_cleanups (old_chain); 00502 return; 00503 } 00504 00505 static void 00506 restore_binary_file (char *filename, struct callback_data *data) 00507 { 00508 struct cleanup *cleanup = make_cleanup (null_cleanup, NULL); 00509 FILE *file = fopen_with_cleanup (filename, FOPEN_RB); 00510 gdb_byte *buf; 00511 long len; 00512 00513 /* Get the file size for reading. */ 00514 if (fseek (file, 0, SEEK_END) == 0) 00515 { 00516 len = ftell (file); 00517 if (len < 0) 00518 perror_with_name (filename); 00519 } 00520 else 00521 perror_with_name (filename); 00522 00523 if (len <= data->load_start) 00524 error (_("Start address is greater than length of binary file %s."), 00525 filename); 00526 00527 /* Chop off "len" if it exceeds the requested load_end addr. */ 00528 if (data->load_end != 0 && data->load_end < len) 00529 len = data->load_end; 00530 /* Chop off "len" if the requested load_start addr skips some bytes. */ 00531 if (data->load_start > 0) 00532 len -= data->load_start; 00533 00534 printf_filtered 00535 ("Restoring binary file %s into memory (0x%lx to 0x%lx)\n", 00536 filename, 00537 (unsigned long) (data->load_start + data->load_offset), 00538 (unsigned long) (data->load_start + data->load_offset + len)); 00539 00540 /* Now set the file pos to the requested load start pos. */ 00541 if (fseek (file, data->load_start, SEEK_SET) != 0) 00542 perror_with_name (filename); 00543 00544 /* Now allocate a buffer and read the file contents. */ 00545 buf = xmalloc (len); 00546 make_cleanup (xfree, buf); 00547 if (fread (buf, 1, len, file) != len) 00548 perror_with_name (filename); 00549 00550 /* Now write the buffer into target memory. */ 00551 len = target_write_memory (data->load_start + data->load_offset, buf, len); 00552 if (len != 0) 00553 warning (_("restore: memory write failed (%s)."), safe_strerror (len)); 00554 do_cleanups (cleanup); 00555 } 00556 00557 static void 00558 restore_command (char *args, int from_tty) 00559 { 00560 char *filename; 00561 struct callback_data data; 00562 bfd *ibfd; 00563 int binary_flag = 0; 00564 00565 if (!target_has_execution) 00566 noprocess (); 00567 00568 data.load_offset = 0; 00569 data.load_start = 0; 00570 data.load_end = 0; 00571 00572 /* Parse the input arguments. First is filename (required). */ 00573 filename = scan_filename_with_cleanup (&args, NULL); 00574 if (args != NULL && *args != '\0') 00575 { 00576 char *binary_string = "binary"; 00577 00578 /* Look for optional "binary" flag. */ 00579 if (strncmp (args, binary_string, strlen (binary_string)) == 0) 00580 { 00581 binary_flag = 1; 00582 args += strlen (binary_string); 00583 args = skip_spaces (args); 00584 } 00585 /* Parse offset (optional). */ 00586 if (args != NULL && *args != '\0') 00587 data.load_offset = 00588 parse_and_eval_address (scan_expression_with_cleanup (&args, NULL)); 00589 if (args != NULL && *args != '\0') 00590 { 00591 /* Parse start address (optional). */ 00592 data.load_start = 00593 parse_and_eval_long (scan_expression_with_cleanup (&args, NULL)); 00594 if (args != NULL && *args != '\0') 00595 { 00596 /* Parse end address (optional). */ 00597 data.load_end = parse_and_eval_long (args); 00598 if (data.load_end <= data.load_start) 00599 error (_("Start must be less than end.")); 00600 } 00601 } 00602 } 00603 00604 if (info_verbose) 00605 printf_filtered ("Restore file %s offset 0x%lx start 0x%lx end 0x%lx\n", 00606 filename, (unsigned long) data.load_offset, 00607 (unsigned long) data.load_start, 00608 (unsigned long) data.load_end); 00609 00610 if (binary_flag) 00611 { 00612 restore_binary_file (filename, &data); 00613 } 00614 else 00615 { 00616 /* Open the file for loading. */ 00617 ibfd = bfd_openr_with_cleanup (filename, NULL); 00618 00619 /* Process the sections. */ 00620 bfd_map_over_sections (ibfd, restore_section_callback, &data); 00621 } 00622 return; 00623 } 00624 00625 static void 00626 srec_dump_command (char *cmd, int from_tty) 00627 { 00628 printf_unfiltered ("\"dump srec\" must be followed by a subcommand.\n"); 00629 help_list (srec_cmdlist, "dump srec ", -1, gdb_stdout); 00630 } 00631 00632 static void 00633 ihex_dump_command (char *cmd, int from_tty) 00634 { 00635 printf_unfiltered ("\"dump ihex\" must be followed by a subcommand.\n"); 00636 help_list (ihex_cmdlist, "dump ihex ", -1, gdb_stdout); 00637 } 00638 00639 static void 00640 tekhex_dump_command (char *cmd, int from_tty) 00641 { 00642 printf_unfiltered ("\"dump tekhex\" must be followed by a subcommand.\n"); 00643 help_list (tekhex_cmdlist, "dump tekhex ", -1, gdb_stdout); 00644 } 00645 00646 static void 00647 binary_dump_command (char *cmd, int from_tty) 00648 { 00649 printf_unfiltered ("\"dump binary\" must be followed by a subcommand.\n"); 00650 help_list (binary_dump_cmdlist, "dump binary ", -1, gdb_stdout); 00651 } 00652 00653 static void 00654 binary_append_command (char *cmd, int from_tty) 00655 { 00656 printf_unfiltered ("\"append binary\" must be followed by a subcommand.\n"); 00657 help_list (binary_append_cmdlist, "append binary ", -1, gdb_stdout); 00658 } 00659 00660 extern initialize_file_ftype _initialize_cli_dump; /* -Wmissing-prototypes */ 00661 00662 void 00663 _initialize_cli_dump (void) 00664 { 00665 struct cmd_list_element *c; 00666 00667 add_prefix_cmd ("dump", class_vars, dump_command, 00668 _("Dump target code/data to a local file."), 00669 &dump_cmdlist, "dump ", 00670 0/*allow-unknown*/, 00671 &cmdlist); 00672 add_prefix_cmd ("append", class_vars, append_command, 00673 _("Append target code/data to a local file."), 00674 &append_cmdlist, "append ", 00675 0/*allow-unknown*/, 00676 &cmdlist); 00677 00678 add_dump_command ("memory", dump_memory_command, "\ 00679 Write contents of memory to a raw binary file.\n\ 00680 Arguments are FILE START STOP. Writes the contents of memory within the\n\ 00681 range [START .. STOP) to the specified FILE in raw target ordered bytes."); 00682 00683 add_dump_command ("value", dump_value_command, "\ 00684 Write the value of an expression to a raw binary file.\n\ 00685 Arguments are FILE EXPRESSION. Writes the value of EXPRESSION to\n\ 00686 the specified FILE in raw target ordered bytes."); 00687 00688 add_prefix_cmd ("srec", all_commands, srec_dump_command, 00689 _("Write target code/data to an srec file."), 00690 &srec_cmdlist, "dump srec ", 00691 0 /*allow-unknown*/, 00692 &dump_cmdlist); 00693 00694 add_prefix_cmd ("ihex", all_commands, ihex_dump_command, 00695 _("Write target code/data to an intel hex file."), 00696 &ihex_cmdlist, "dump ihex ", 00697 0 /*allow-unknown*/, 00698 &dump_cmdlist); 00699 00700 add_prefix_cmd ("tekhex", all_commands, tekhex_dump_command, 00701 _("Write target code/data to a tekhex file."), 00702 &tekhex_cmdlist, "dump tekhex ", 00703 0 /*allow-unknown*/, 00704 &dump_cmdlist); 00705 00706 add_prefix_cmd ("binary", all_commands, binary_dump_command, 00707 _("Write target code/data to a raw binary file."), 00708 &binary_dump_cmdlist, "dump binary ", 00709 0 /*allow-unknown*/, 00710 &dump_cmdlist); 00711 00712 add_prefix_cmd ("binary", all_commands, binary_append_command, 00713 _("Append target code/data to a raw binary file."), 00714 &binary_append_cmdlist, "append binary ", 00715 0 /*allow-unknown*/, 00716 &append_cmdlist); 00717 00718 add_cmd ("memory", all_commands, dump_srec_memory, _("\ 00719 Write contents of memory to an srec file.\n\ 00720 Arguments are FILE START STOP. Writes the contents of memory\n\ 00721 within the range [START .. STOP) to the specified FILE in srec format."), 00722 &srec_cmdlist); 00723 00724 add_cmd ("value", all_commands, dump_srec_value, _("\ 00725 Write the value of an expression to an srec file.\n\ 00726 Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ 00727 to the specified FILE in srec format."), 00728 &srec_cmdlist); 00729 00730 add_cmd ("memory", all_commands, dump_ihex_memory, _("\ 00731 Write contents of memory to an ihex file.\n\ 00732 Arguments are FILE START STOP. Writes the contents of memory within\n\ 00733 the range [START .. STOP) to the specified FILE in intel hex format."), 00734 &ihex_cmdlist); 00735 00736 add_cmd ("value", all_commands, dump_ihex_value, _("\ 00737 Write the value of an expression to an ihex file.\n\ 00738 Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ 00739 to the specified FILE in intel hex format."), 00740 &ihex_cmdlist); 00741 00742 add_cmd ("memory", all_commands, dump_tekhex_memory, _("\ 00743 Write contents of memory to a tekhex file.\n\ 00744 Arguments are FILE START STOP. Writes the contents of memory\n\ 00745 within the range [START .. STOP) to the specified FILE in tekhex format."), 00746 &tekhex_cmdlist); 00747 00748 add_cmd ("value", all_commands, dump_tekhex_value, _("\ 00749 Write the value of an expression to a tekhex file.\n\ 00750 Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ 00751 to the specified FILE in tekhex format."), 00752 &tekhex_cmdlist); 00753 00754 add_cmd ("memory", all_commands, dump_binary_memory, _("\ 00755 Write contents of memory to a raw binary file.\n\ 00756 Arguments are FILE START STOP. Writes the contents of memory\n\ 00757 within the range [START .. STOP) to the specified FILE in binary format."), 00758 &binary_dump_cmdlist); 00759 00760 add_cmd ("value", all_commands, dump_binary_value, _("\ 00761 Write the value of an expression to a raw binary file.\n\ 00762 Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ 00763 to the specified FILE in raw target ordered bytes."), 00764 &binary_dump_cmdlist); 00765 00766 add_cmd ("memory", all_commands, append_binary_memory, _("\ 00767 Append contents of memory to a raw binary file.\n\ 00768 Arguments are FILE START STOP. Writes the contents of memory within the\n\ 00769 range [START .. STOP) to the specified FILE in raw target ordered bytes."), 00770 &binary_append_cmdlist); 00771 00772 add_cmd ("value", all_commands, append_binary_value, _("\ 00773 Append the value of an expression to a raw binary file.\n\ 00774 Arguments are FILE EXPRESSION. Writes the value of EXPRESSION\n\ 00775 to the specified FILE in raw target ordered bytes."), 00776 &binary_append_cmdlist); 00777 00778 c = add_com ("restore", class_vars, restore_command, _("\ 00779 Restore the contents of FILE to target memory.\n\ 00780 Arguments are FILE OFFSET START END where all except FILE are optional.\n\ 00781 OFFSET will be added to the base address of the file (default zero).\n\ 00782 If START and END are given, only the file contents within that range\n\ 00783 (file relative) will be restored to target memory.")); 00784 c->completer = filename_completer; 00785 /* FIXME: completers for other commands. */ 00786 }