diff options
author | Jim Kingdon <jkingdon@engr.sgi.com> | 1991-04-19 01:36:57 +0000 |
---|---|---|
committer | Jim Kingdon <jkingdon@engr.sgi.com> | 1991-04-19 01:36:57 +0000 |
commit | f2fc6e7a5c33740b298b2a6d24d89d4bd3a8607b (patch) | |
tree | f773467c87389748760e3ec0127f0ee9300ff236 /gdb | |
parent | 70dcc196e1548122d4959b1e9e4b22c41c27a179 (diff) | |
download | gdb-f2fc6e7a5c33740b298b2a6d24d89d4bd3a8607b.zip gdb-f2fc6e7a5c33740b298b2a6d24d89d4bd3a8607b.tar.gz gdb-f2fc6e7a5c33740b298b2a6d24d89d4bd3a8607b.tar.bz2 |
* target.h: Add to_doc and target_preopen.
target.c: Add target_preopen and target_command.
Remove target_info.
(add_target): Call add_cmd and mess with targetlist->doc.
core.c, exec.c, remote-eb.c, remote-nindy.c, remote-vx.c,
remote-vx.68.c, inftarg.c, remote.c: Add doc field to target struct.
Call target_preopen from open routine.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/core.c | 2 | ||||
-rw-r--r-- | gdb/exec.c | 49 | ||||
-rw-r--r-- | gdb/remote-eb.c | 7 | ||||
-rw-r--r-- | gdb/remote-nindy.c | 7 | ||||
-rw-r--r-- | gdb/remote.c | 4 | ||||
-rw-r--r-- | gdb/target.c | 108 |
6 files changed, 101 insertions, 76 deletions
@@ -81,6 +81,7 @@ core_open (filename, from_tty) bfd *temp_bfd; int ontop; + target_preopen (from_tty); if (!filename) { error (core_bfd? @@ -421,6 +422,7 @@ get_core_registers (regno) struct target_ops core_ops = { "core", "Local core dump file", + "Use a core file as a target. Specify the filename of the core file.", core_open, core_close, child_attach, core_detach, 0, 0, /* resume, wait */ get_core_registers, @@ -73,6 +73,7 @@ exec_file_command (filename, from_tty) char *filename; int from_tty; { + target_preopen (from_tty); /* Remove any previous exec file. */ unpush_target (&exec_ops); @@ -312,8 +313,49 @@ exec_files_info () bfd_section_name (exec_bfd, p->sec_ptr)); } +static void +set_section_command (args, from_tty) + char *args; + int from_tty; +{ + struct section_table *p; + char *secname; + unsigned seclen; + unsigned long secaddr; + char secprint[100]; + long offset; + + if (args == 0) + error ("Must specify section name and its virtual address"); + + /* Parse out section name */ + for (secname = args; !isspace(*args); args++) ; + seclen = args - secname; + + /* Parse out new virtual address */ + secaddr = parse_and_eval_address (args); + + for (p = exec_sections; p < exec_sections_end; p++) { + if (!strncmp (secname, bfd_section_name (exec_bfd, p->sec_ptr), seclen) + && bfd_section_name (exec_bfd, p->sec_ptr)[seclen] == '\0') { + offset = secaddr - p->addr; + p->addr += offset; + p->endaddr += offset; + exec_files_info(); + return; + } + } + if (seclen >= sizeof (secprint)) + seclen = sizeof (secprint) - 1; + strncpy (secprint, secname, seclen); + secprint[seclen] = '\0'; + error ("Section %s not found", secprint); +} + struct target_ops exec_ops = { "exec", "Local exec file", + "Use an executable file as a target.\n\ +Specify the filename of the executable file.", exec_file_command, exec_close, /* open, close */ child_attach, 0, 0, 0, /* attach, detach, resume, wait, */ 0, 0, /* fetch_registers, store_registers, */ @@ -349,5 +391,12 @@ If FILE cannot be found as specified, your execution directory path\n\ is searched for a command of that name.\n\ No arg means have no executable file."); + add_com ("section", class_files, set_section_command, + "Change the base address of section SECTION of the exec file to ADDR.\n\ +This can be used if the exec file does not contain section addresses,\n\ +(such as in the a.out format), or when the addresses specified in the\n\ +file itself are wrong. Each section must be changed separately. The\n\ +``info files'' command lists all the sections and their addresses."); + add_target (&exec_ops); } diff --git a/gdb/remote-eb.c b/gdb/remote-eb.c index a140905..9f8cc5e 100644 --- a/gdb/remote-eb.c +++ b/gdb/remote-eb.c @@ -312,6 +312,8 @@ eb_open (name, from_tty) char *p; + target_preopen (from_tty); + /* Find the first whitespace character, it separates dev_name from prog_name. */ if (name == 0) @@ -907,6 +909,11 @@ eb_read_inferior_memory(memaddr, myaddr, len) struct target_ops eb_ops = { "amd-eb", "Remote serial AMD EBMON target", + "Use a remote computer running EBMON connected by a serial line.\n\ +Arguments are the name of the device for the serial line,\n\ +the speed to connect at in bits per second, and the filename of the\n\ +executable as it exists on the remote computer. For example,\n\ + target amd-eb /dev/ttya 9600 demo", eb_open, eb_close, 0, eb_detach, eb_resume, eb_wait, eb_fetch_register, eb_store_register, diff --git a/gdb/remote-nindy.c b/gdb/remote-nindy.c index af19fd4..08cc9de 100644 --- a/gdb/remote-nindy.c +++ b/gdb/remote-nindy.c @@ -220,6 +220,8 @@ nindy_open (name, from_tty) if (!name) error_no_arg ("serial port device name"); + target_preopen (from_tty); + nindy_close (0); have_regs = regs_changed = 0; @@ -932,6 +934,11 @@ nindy_before_main_loop () struct target_ops nindy_ops = { "nindy", "Remote serial target in i960 NINDY-specific protocol", + "Use a remote i960 system running NINDY connected by a serial line.\n\ +Specify the name of the device the serial line is connected to.\n\ +The speed (baud rate), whether to use the old NINDY protocol,\n\ +and whether to send a break on startup, are controlled by options\n\ +specified when you started GDB.", nindy_open, nindy_close, 0, nindy_detach, nindy_resume, nindy_wait, nindy_fetch_registers, nindy_store_registers, diff --git a/gdb/remote.c b/gdb/remote.c index 9ff5650..3e0acd3 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -162,6 +162,8 @@ remote_open (name, from_tty) "To open a remote debug connection, you need to specify what serial\n\ device is attached to the remote system (e.g. /dev/ttya)."); + target_preopen (from_tty); + remote_close (0); #if 0 @@ -805,6 +807,8 @@ dcache_init () struct target_ops remote_ops = { "remote", "Remote serial target in gdb-specific protocol", + "Use a remote computer via a serial line, using a gdb-specific protocol.\n\ +Specify the serial device it is connected to (e.g. /dev/ttya).", remote_open, remote_close, 0, remote_detach, remote_resume, remote_wait, /* attach */ remote_fetch_registers, remote_store_registers, diff --git a/gdb/target.c b/gdb/target.c index 6118293..53e9de1 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -47,7 +47,7 @@ unsigned target_struct_allocsize; /* The initial current target, so that there is always a semi-valid current target. */ -struct target_ops dummy_target = {"None", "None", +struct target_ops dummy_target = {"None", "None", "", 0, 0, 0, 0, /* open, close, attach, detach */ 0, 0, /* resume, wait */ 0, 0, 0, 0, 0, /* registers */ @@ -72,6 +72,23 @@ struct target_ops *current_target; struct target_ops **current_target_stack; +/* Command list for target. */ + +static struct cmd_list_element *targetlist = NULL; + +/* Docstring for target (as in "help target"). */ + +static char *target_doc = NULL; + +/* The user just typed 'target' without the name of a target. */ + +static void +target_command (arg, from_tty) + char *arg; + int from_tty; +{ + fputs_filtered ("Argument required (target name).", stdout); +} /* Add a possible target architecture to the list. */ @@ -100,6 +117,16 @@ add_target (t) } target_structs[target_struct_size++] = t; cleanup_target (t); + + if (targetlist == NULL) + add_prefix_cmd ("target", class_run, target_command, + "Connect to a target machine or process.\n\ +The first argument is the type or protocol of the target machine.\n\ +Remaining arguments are interpreted by the target protocol. For more\n\ +information on the arguments for a particular protocol, type\n\ +`help target ' followed by the protocol name.", + &targetlist, "target ", 0, &cmdlist); + add_cmd (t->to_shortname, no_class, t->to_open, t->to_doc, &targetlist); } /* Stub functions */ @@ -363,20 +390,6 @@ pop_target () push_target (&dummy_target); } -/* Print things about the whole set of targets and about the - current target stack. */ -static void -targets_info () -{ - int i; - - printf("Possible targets:\n\n"); - for (i = 0; i < target_struct_size; i++) - printf ("%-15s %s\n", - target_structs[i]->to_shortname, - target_structs[i]->to_longname); -} - /* Move memory to or from the targets. Iterate until all of it has been moved, if necessary. The top target gets priority; anything it doesn't want, is offered to the next one down, etc. Note the @@ -484,25 +497,15 @@ target_info (args, from_tty) } } -/* The target command selects a target and calls its open routine. - The open routine takes the rest of the parameters from the command, - and (if successful) pushes a new target onto the stack. */ +/* This is to be called by the open routine before it does + anything. */ -static void -target_command (args, from_tty) - char *args; +void +target_preopen (from_tty) int from_tty; { - int i, possible; - char *rest; - char *argend; - dont_repeat(); - if (!args) - error ( - "Argument required (target name). `info targets' lists possible targets"); - if (target_has_execution) { if (query ("A program is being debugged already. Kill it? ")) @@ -510,39 +513,6 @@ target_command (args, from_tty) else error ("Program not killed."); } - - /* Skip to first space, or end of args */ - for (rest = args; *rest && !isspace(*rest); rest++) ; - argend = rest; - if (*rest == '\0') - rest = 0; /* Only one word in args */ - else - { - for (rest++; isspace (*rest); rest++) ; - if (*rest == '\0') /* Only one word w/trailing blanks */ - rest = 0; - } - - /* Search target list for a match */ - - possible = -1; - for (i = 0; i < target_struct_size; i++) - { - if (!strncmp (args, target_structs[i]->to_shortname, argend - args)) { - /* If we have an exact match, it's time to quit. */ - if (target_structs[i]->to_shortname[args-argend] == '\0') { - possible = i; - break; - } - if (possible > 0) - error ("Ambiguous target. `info targets' will list all targets"); - possible = i; - } - } - if (possible < 0) - error ("No such target. `info targets' will list all targets"); - - (*target_structs[possible]->to_open) (rest, from_tty); } static char targ_desc[] = @@ -556,20 +526,6 @@ _initialize_targets () current_target = &dummy_target; cleanup_target (current_target); - add_info ("targets", targets_info, - "Names of all possible targets.\n\ -A target is typically a protocol for talking to debugging facilities;\n\ -for example, `child' for Unix child processes, or `vxworks' for a\n\ -TCP/IP link to a VxWorks system."); - add_info ("target", target_info, targ_desc); add_info ("files", target_info, targ_desc); - - add_com ("target", class_run, target_command, -"Connect to a target machine or process.\n\ -The first argument is the type or protocol of the target machine. Remaining\n\ -arguments are interpreted by the target protocol, but typically include\n\ -things like device names or host names to connect with, process numbers,\n\ -baud rates, etc. You can list all possible targets with the `info targets'\n\ -command."); } |