home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / GDB / GDB-4.13 / GDB-4 / gdb-4.13 / gdb / target.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-07-13  |  32.9 KB  |  1,313 lines

  1. /* Select target systems and architectures at runtime for GDB.
  2.    Copyright 1990, 1992, 1993, 1994 Free Software Foundation, Inc.
  3.    Contributed by Cygnus Support.
  4.  
  5. This file is part of GDB.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #include "defs.h"
  22. #include <errno.h>
  23. #include <ctype.h>
  24. #include "target.h"
  25. #include "gdbcmd.h"
  26. #include "symtab.h"
  27. #include "inferior.h"
  28. #include "bfd.h"
  29. #include "symfile.h"
  30. #include "objfiles.h"
  31. #include "wait.h"
  32. #include <signal.h>
  33.  
  34. extern int errno;
  35.  
  36. static void
  37. target_info PARAMS ((char *, int));
  38.  
  39. static void
  40. cleanup_target PARAMS ((struct target_ops *));
  41.  
  42. static void
  43. maybe_kill_then_create_inferior PARAMS ((char *, char *, char **));
  44.  
  45. static void
  46. maybe_kill_then_attach PARAMS ((char *, int));
  47.  
  48. static void
  49. kill_or_be_killed PARAMS ((int));
  50.  
  51. static void
  52. default_terminal_info PARAMS ((char *, int));
  53.  
  54. static int
  55. nosymbol PARAMS ((char *, CORE_ADDR *));
  56.  
  57. static void
  58. tcomplain PARAMS ((void));
  59.  
  60. static int
  61. nomemory PARAMS ((CORE_ADDR, char *, int, int));
  62.  
  63. static int
  64. return_zero PARAMS ((void));
  65.  
  66. static void
  67. ignore PARAMS ((void));
  68.  
  69. static void
  70. target_command PARAMS ((char *, int));
  71.  
  72. static struct target_ops *
  73. find_default_run_target PARAMS ((char *));
  74.  
  75. /* Pointer to array of target architecture structures; the size of the
  76.    array; the current index into the array; the allocated size of the 
  77.    array.  */
  78. struct target_ops **target_structs;
  79. unsigned target_struct_size;
  80. unsigned target_struct_index;
  81. unsigned target_struct_allocsize;
  82. #define    DEFAULT_ALLOCSIZE    10
  83.  
  84. /* The initial current target, so that there is always a semi-valid
  85.    current target.  */
  86.  
  87. struct target_ops dummy_target = {"None", "None", "",
  88.     0, 0,         /* open, close */
  89.     find_default_attach, 0,  /* attach, detach */
  90.     0, 0,        /* resume, wait */
  91.     0, 0, 0,        /* registers */
  92.     0, 0,         /* memory */
  93.     0, 0,         /* bkpts */
  94.     0, 0, 0, 0, 0,     /* terminal */
  95.     0, 0,         /* kill, load */
  96.     0,             /* lookup_symbol */
  97.     find_default_create_inferior, /* create_inferior */
  98.     0,            /* mourn_inferior */
  99.     0,            /* can_run */
  100.     0,            /* notice_signals */
  101.     dummy_stratum, 0,    /* stratum, next */
  102.     0, 0, 0, 0, 0,    /* all mem, mem, stack, regs, exec */
  103.     0, 0,        /* section pointers */
  104.     OPS_MAGIC,
  105. };
  106.  
  107. /* The target structure we are currently using to talk to a process
  108.    or file or whatever "inferior" we have.  */
  109.  
  110. struct target_ops *current_target;
  111.  
  112. /* The stack of target structures that have been pushed.  */
  113.  
  114. struct target_ops **current_target_stack;
  115.  
  116. /* Command list for target.  */
  117.  
  118. static struct cmd_list_element *targetlist = NULL;
  119.  
  120. /* Nonzero if we are debugging an attached outside process
  121.    rather than an inferior.  */
  122.  
  123. int attach_flag;
  124.  
  125. /* The user just typed 'target' without the name of a target.  */
  126.  
  127. /* ARGSUSED */
  128. static void
  129. target_command (arg, from_tty)
  130.      char *arg;
  131.      int from_tty;
  132. {
  133.   fputs_filtered ("Argument required (target name).  Try `help target'\n",
  134.           gdb_stdout);
  135. }
  136.  
  137. /* Add a possible target architecture to the list.  */
  138.  
  139. void
  140. add_target (t)
  141.      struct target_ops *t;
  142. {
  143.   if (t->to_magic != OPS_MAGIC)
  144.     {
  145.       fprintf_unfiltered(gdb_stderr, "Magic number of %s target struct wrong\n", 
  146.     t->to_shortname);
  147.       abort();
  148.     }
  149.  
  150.   if (!target_structs)
  151.     {
  152.       target_struct_allocsize = DEFAULT_ALLOCSIZE;
  153.       target_structs = (struct target_ops **) xmalloc
  154.     (target_struct_allocsize * sizeof (*target_structs));
  155.     }
  156.   if (target_struct_size >= target_struct_allocsize)
  157.     {
  158.       target_struct_allocsize *= 2;
  159.       target_structs = (struct target_ops **)
  160.       xrealloc ((char *) target_structs, 
  161.             target_struct_allocsize * sizeof (*target_structs));
  162.     }
  163.   target_structs[target_struct_size++] = t;
  164.   cleanup_target (t);
  165.  
  166.   if (targetlist == NULL)
  167.     add_prefix_cmd ("target", class_run, target_command,
  168.             "Connect to a target machine or process.\n\
  169. The first argument is the type or protocol of the target machine.\n\
  170. Remaining arguments are interpreted by the target protocol.  For more\n\
  171. information on the arguments for a particular protocol, type\n\
  172. `help target ' followed by the protocol name.",
  173.             &targetlist, "target ", 0, &cmdlist);
  174.   add_cmd (t->to_shortname, no_class, t->to_open, t->to_doc, &targetlist);
  175. }
  176.  
  177. /* Stub functions */
  178.  
  179. static void
  180. ignore ()
  181. {
  182. }
  183.  
  184. /* ARGSUSED */
  185. static int
  186. nomemory (memaddr, myaddr, len, write)
  187.      CORE_ADDR memaddr;
  188.      char *myaddr;
  189.      int len;
  190.      int write;
  191. {
  192.   errno = EIO;        /* Can't read/write this location */
  193.   return 0;        /* No bytes handled */
  194. }
  195.  
  196. static void
  197. tcomplain ()
  198. {
  199.   error ("You can't do that when your target is `%s'",
  200.      current_target->to_shortname);
  201. }
  202.  
  203. void
  204. noprocess ()
  205. {
  206.   error ("You can't do that without a process to debug");
  207. }
  208.  
  209. /* ARGSUSED */
  210. static int
  211. nosymbol (name, addrp)
  212.      char *name;
  213.      CORE_ADDR *addrp;
  214. {
  215.   return 1;        /* Symbol does not exist in target env */
  216. }
  217.  
  218. /* ARGSUSED */
  219. static void
  220. default_terminal_info (args, from_tty)
  221.      char *args;
  222.      int from_tty;
  223. {
  224.   printf_unfiltered("No saved terminal information.\n");
  225. }
  226.  
  227. #if 0
  228. /* With strata, this function is no longer needed.  FIXME.  */
  229. /* This is the default target_create_inferior function.  It looks up
  230.    the stack for some target that cares to create inferiors, then
  231.    calls it -- or complains if not found.  */
  232.  
  233. static void
  234. upstack_create_inferior (exec, args, env)
  235.      char *exec;
  236.      char *args;
  237.      char **env;
  238. {
  239.   struct target_ops *t;
  240.  
  241.   for (t = current_target;
  242.        t;
  243.        t = t->to_next)
  244.     {
  245.       if (t->to_create_inferior != upstack_create_inferior)
  246.     {
  247.           t->to_create_inferior (exec, args, env);
  248.       return;
  249.     }
  250.  
  251.     }
  252.   tcomplain();
  253. }
  254. #endif
  255.  
  256. /* This is the default target_create_inferior and target_attach function.
  257.    If the current target is executing, it asks whether to kill it off.
  258.    If this function returns without calling error(), it has killed off
  259.    the target, and the operation should be attempted.  */
  260.  
  261. static void
  262. kill_or_be_killed (from_tty)
  263.      int from_tty;
  264. {
  265.   if (target_has_execution)
  266.     {
  267.       printf_unfiltered ("You are already running a program:\n");
  268.       target_files_info ();
  269.       if (query ("Kill it? ")) {
  270.     target_kill ();
  271.     if (target_has_execution)
  272.       error ("Killing the program did not help.");
  273.     return;
  274.       } else {
  275.     error ("Program not killed.");
  276.       }
  277.     }
  278.   tcomplain();
  279. }
  280.  
  281. static void
  282. maybe_kill_then_attach (args, from_tty)
  283.      char *args;
  284.      int from_tty;
  285. {
  286.   kill_or_be_killed (from_tty);
  287.   target_attach (args, from_tty);
  288. }
  289.  
  290. static void
  291. maybe_kill_then_create_inferior (exec, args, env)
  292.      char *exec;
  293.      char *args;
  294.      char **env;
  295. {
  296.   kill_or_be_killed (0);
  297.   target_create_inferior (exec, args, env);
  298. }
  299.  
  300. /* Clean up a target struct so it no longer has any zero pointers in it.
  301.    We default entries, at least to stubs that print error messages.  */
  302.  
  303. static void
  304. cleanup_target (t)
  305.      struct target_ops *t;
  306. {
  307.  
  308.   /* Check magic number.  If wrong, it probably means someone changed
  309.      the struct definition, but not all the places that initialize one.  */
  310.   if (t->to_magic != OPS_MAGIC)
  311.     {
  312.       fprintf_unfiltered(gdb_stderr, "Magic number of %s target struct wrong\n", 
  313.     t->to_shortname);
  314.       abort();
  315.     }
  316.  
  317. #define de_fault(field, value) \
  318.   if (!t->field)    t->field = value
  319.  
  320.   /*        FIELD            DEFAULT VALUE        */
  321.  
  322.   de_fault (to_open,             (void (*)())tcomplain);
  323.   de_fault (to_close,             (void (*)())ignore);
  324.   de_fault (to_attach,             maybe_kill_then_attach);
  325.   de_fault (to_detach,             (void (*)())ignore);
  326.   de_fault (to_resume,             (void (*)())noprocess);
  327.   de_fault (to_wait,             (int (*)())noprocess);
  328.   de_fault (to_fetch_registers,     (void (*)())ignore);
  329.   de_fault (to_store_registers,        (void (*)())noprocess);
  330.   de_fault (to_prepare_to_store,    (void (*)())noprocess);
  331.   de_fault (to_xfer_memory,        (int (*)())nomemory);
  332.   de_fault (to_files_info,        (void (*)())ignore);
  333.   de_fault (to_insert_breakpoint,    memory_insert_breakpoint);
  334.   de_fault (to_remove_breakpoint,    memory_remove_breakpoint);
  335.   de_fault (to_terminal_init,        ignore);
  336.   de_fault (to_terminal_inferior,    ignore);
  337.   de_fault (to_terminal_ours_for_output,ignore);
  338.   de_fault (to_terminal_ours,        ignore);
  339.   de_fault (to_terminal_info,        default_terminal_info);
  340.   de_fault (to_kill,            (void (*)())noprocess);
  341.   de_fault (to_load,            (void (*)())tcomplain);
  342.   de_fault (to_lookup_symbol,        nosymbol);
  343.   de_fault (to_create_inferior,        maybe_kill_then_create_inferior);
  344.   de_fault (to_mourn_inferior,        (void (*)())noprocess);
  345.   de_fault (to_can_run,            return_zero);
  346.   de_fault (to_notice_signals,        (void (*)())ignore);
  347.   de_fault (to_next,            0);
  348.   de_fault (to_has_all_memory,        0);
  349.   de_fault (to_has_memory,        0);
  350.   de_fault (to_has_stack,        0);
  351.   de_fault (to_has_registers,        0);
  352.   de_fault (to_has_execution,        0);
  353.  
  354. #undef de_fault
  355. }
  356.  
  357. /* Push a new target type into the stack of the existing target accessors,
  358.    possibly superseding some of the existing accessors.
  359.  
  360.    Result is zero if the pushed target ended up on top of the stack,
  361.    nonzero if at least one target is on top of it.
  362.  
  363.    Rather than allow an empty stack, we always have the dummy target at
  364.    the bottom stratum, so we can call the function vectors without
  365.    checking them.  */
  366.  
  367. int
  368. push_target (t)
  369.      struct target_ops *t;
  370. {
  371.   struct target_ops *st, *prev;
  372.  
  373.   for (prev = 0, st = current_target;
  374.        st;
  375.        prev = st, st = st->to_next) {
  376.     if ((int)(t->to_stratum) >= (int)(st->to_stratum))
  377.       break;
  378.   }
  379.  
  380.   while (t->to_stratum == st->to_stratum) {
  381.     /* There's already something on this stratum.  Close it off.  */
  382.     (st->to_close) (0);
  383.     if (prev)
  384.       prev->to_next = st->to_next;    /* Unchain old target_ops */
  385.     else
  386.       current_target = st->to_next;    /* Unchain first on list */
  387.     st = st->to_next;
  388.   }
  389.  
  390.   /* We have removed all targets in our stratum, now add ourself.  */
  391.   t->to_next = st;
  392.   if (prev)
  393.     prev->to_next = t;
  394.   else
  395.     current_target = t;
  396.  
  397.   cleanup_target (current_target);
  398.   return prev != 0;
  399. }
  400.  
  401. /* Remove a target_ops vector from the stack, wherever it may be. 
  402.    Return how many times it was removed (0 or 1 unless bug).  */
  403.  
  404. int
  405. unpush_target (t)
  406.      struct target_ops *t;
  407. {
  408.   struct target_ops *u, *v;
  409.   int result = 0;
  410.  
  411.   for (u = current_target, v = 0;
  412.        u;
  413.        v = u, u = u->to_next)
  414.     if (u == t)
  415.       {
  416.     if (v == 0)
  417.       pop_target();            /* unchain top copy */
  418.     else {
  419.       (t->to_close)(0);        /* Let it clean up */
  420.       v->to_next = t->to_next;    /* unchain middle copy */
  421.     }
  422.     result++;
  423.       }
  424.   return result;
  425. }
  426.  
  427. void
  428. pop_target ()
  429. {
  430.   (current_target->to_close)(0);    /* Let it clean up */
  431.   current_target = current_target->to_next;
  432. #if 0
  433.   /* This will dump core if ever called--push_target expects current_target
  434.      to be non-NULL.  But I don't think it's needed; I don't see how the
  435.      dummy_target could ever be removed from the stack.  */
  436.   if (!current_target)        /* At bottom, push dummy.  */
  437.     push_target (&dummy_target);
  438. #endif
  439. }
  440.  
  441. #undef    MIN
  442. #define MIN(A, B) (((A) <= (B)) ? (A) : (B))
  443.  
  444. /* target_read_string -- read a null terminated string, up to LEN bytes,
  445.    from MEMADDR in target.  Set *ERRNOP to the errno code, or 0 if successful.
  446.    Set *STRING to a pointer to malloc'd memory containing the data; the caller
  447.    is responsible for freeing it.  Return the number of bytes successfully
  448.    read.  */
  449.  
  450. int
  451. target_read_string (memaddr, string, len, errnop)
  452.      CORE_ADDR memaddr;
  453.      char **string;
  454.      int len;
  455.      int *errnop;
  456. {
  457.   int tlen, origlen, offset, i;
  458.   char buf[4];
  459.   int errcode = 0;
  460.   char *buffer;
  461.   int buffer_allocated;
  462.   char *bufptr;
  463.   unsigned int nbytes_read = 0;
  464.  
  465.   /* Small for testing.  */
  466.   buffer_allocated = 4;
  467.   buffer = xmalloc (buffer_allocated);
  468.   bufptr = buffer;
  469.  
  470.   origlen = len;
  471.  
  472.   while (len > 0)
  473.     {
  474.       tlen = MIN (len, 4 - (memaddr & 3));
  475.       offset = memaddr & 3;
  476.  
  477.       errcode = target_xfer_memory (memaddr & ~3, buf, 4, 0);
  478.       if (errcode != 0)
  479.     goto done;
  480.  
  481.       if (bufptr - buffer + tlen > buffer_allocated)
  482.     {
  483.       unsigned int bytes;
  484.       bytes = bufptr - buffer;
  485.       buffer_allocated *= 2;
  486.       buffer = xrealloc (buffer, buffer_allocated);
  487.       bufptr = buffer + bytes;
  488.     }
  489.  
  490.       for (i = 0; i < tlen; i++)
  491.     {
  492.       *bufptr++ = buf[i + offset];
  493.       if (buf[i + offset] == '\000')
  494.         {
  495.           nbytes_read += i + 1;
  496.           goto done;
  497.         }
  498.     }
  499.  
  500.       memaddr += tlen;
  501.       len -= tlen;
  502.       nbytes_read += tlen;
  503.     }
  504.  done:
  505.   if (errnop != NULL)
  506.     *errnop = errcode;
  507.   if (string != NULL)
  508.     *string = buffer;
  509.   return nbytes_read;
  510. }
  511.  
  512. /* Read LEN bytes of target memory at address MEMADDR, placing the results in
  513.    GDB's memory at MYADDR.  Returns either 0 for success or an errno value
  514.    if any error occurs.
  515.  
  516.    If an error occurs, no guarantee is made about the contents of the data at
  517.    MYADDR.  In particular, the caller should not depend upon partial reads
  518.    filling the buffer with good data.  There is no way for the caller to know
  519.    how much good data might have been transfered anyway.  Callers that can
  520.    deal with partial reads should call target_read_memory_partial. */
  521.  
  522. int
  523. target_read_memory (memaddr, myaddr, len)
  524.      CORE_ADDR memaddr;
  525.      char *myaddr;
  526.      int len;
  527. {
  528.   return target_xfer_memory (memaddr, myaddr, len, 0);
  529. }
  530.  
  531. /* Read LEN bytes of target memory at address MEMADDR, placing the results
  532.    in GDB's memory at MYADDR.  Returns a count of the bytes actually read,
  533.    and optionally an errno value in the location pointed to by ERRNOPTR
  534.    if ERRNOPTR is non-null. */
  535.  
  536. int
  537. target_read_memory_partial (memaddr, myaddr, len, errnoptr)
  538.      CORE_ADDR memaddr;
  539.      char *myaddr;
  540.      int len;
  541.      int *errnoptr;
  542. {
  543.   int nread;    /* Number of bytes actually read. */
  544.   int errcode;    /* Error from last read. */
  545.  
  546.   /* First try a complete read. */
  547.   errcode = target_xfer_memory (memaddr, myaddr, len, 0);
  548.   if (errcode == 0)
  549.     {
  550.       /* Got it all. */
  551.       nread = len;
  552.     }
  553.   else
  554.     {
  555.       /* Loop, reading one byte at a time until we get as much as we can. */
  556.       for (errcode = 0, nread = 0; len > 0 && errcode == 0; nread++, len--)
  557.     {
  558.       errcode = target_xfer_memory (memaddr++, myaddr++, 1, 0);
  559.     }
  560.       /* If an error, the last read was unsuccessful, so adjust count. */
  561.       if (errcode != 0)
  562.     {
  563.       nread--;
  564.     }
  565.     }
  566.   if (errnoptr != NULL)
  567.     {
  568.       *errnoptr = errcode;
  569.     }
  570.   return (nread);
  571. }
  572.  
  573. int
  574. target_write_memory (memaddr, myaddr, len)
  575.      CORE_ADDR memaddr;
  576.      char *myaddr;
  577.      int len;
  578. {
  579.   return target_xfer_memory (memaddr, myaddr, len, 1);
  580. }
  581.  
  582. /* Move memory to or from the targets.  Iterate until all of it has
  583.    been moved, if necessary.  The top target gets priority; anything
  584.    it doesn't want, is offered to the next one down, etc.  Note the
  585.    business with curlen:  if an early target says "no, but I have a
  586.    boundary overlapping this xfer" then we shorten what we offer to
  587.    the subsequent targets so the early guy will get a chance at the
  588.    tail before the subsequent ones do. 
  589.  
  590.    Result is 0 or errno value.  */
  591.  
  592. int
  593. target_xfer_memory (memaddr, myaddr, len, write)
  594.      CORE_ADDR memaddr;
  595.      char *myaddr;
  596.      int len;
  597.      int write;
  598. {
  599.   int curlen;
  600.   int res;
  601.   struct target_ops *t;
  602.  
  603.   /* to_xfer_memory is not guaranteed to set errno, even when it returns
  604.      0.  */
  605.   errno = 0;
  606.  
  607.   /* The quick case is that the top target does it all.  */
  608.   res = current_target->to_xfer_memory
  609.             (memaddr, myaddr, len, write, current_target);
  610.   if (res == len)
  611.     return 0;
  612.  
  613.   if (res > 0)
  614.     goto bump;
  615.   /* If res <= 0 then we call it again in the loop.  Ah well.  */
  616.  
  617.   for (; len > 0;)
  618.     {
  619.       curlen = len;        /* Want to do it all */
  620.       for (t = current_target;
  621.        t;
  622.        t = t->to_has_all_memory? 0: t->to_next)
  623.     {
  624.       res = t->to_xfer_memory(memaddr, myaddr, curlen, write, t);
  625.       if (res > 0) break;    /* Handled all or part of xfer */
  626.       if (res == 0) continue;    /* Handled none */
  627.       curlen = -res;    /* Could handle once we get past res bytes */
  628.     }
  629.       if (res <= 0)
  630.     {
  631.       /* If this address is for nonexistent memory,
  632.          read zeros if reading, or do nothing if writing.  Return error. */
  633.       if (!write)
  634.         memset (myaddr, 0, len);
  635.       if (errno == 0)
  636.         return EIO;
  637.       else
  638.         return errno;
  639.     }
  640. bump:
  641.       memaddr += res;
  642.       myaddr  += res;
  643.       len     -= res;
  644.     }
  645.   return 0;            /* We managed to cover it all somehow. */
  646. }
  647.  
  648.  
  649. /* ARGSUSED */
  650. static void
  651. target_info (args, from_tty)
  652.      char *args;
  653.      int from_tty;
  654. {
  655.   struct target_ops *t;
  656.   int has_all_mem = 0;
  657.   
  658.   if (symfile_objfile != NULL)
  659.     printf_unfiltered ("Symbols from \"%s\".\n", symfile_objfile->name);
  660.  
  661. #ifdef FILES_INFO_HOOK
  662.   if (FILES_INFO_HOOK ())
  663.     return;
  664. #endif
  665.  
  666.   for (t = current_target;
  667.        t;
  668.        t = t->to_next)
  669.     {
  670.       if ((int)(t->to_stratum) <= (int)dummy_stratum)
  671.     continue;
  672.       if (has_all_mem)
  673.     printf_unfiltered("\tWhile running this, GDB does not access memory from...\n");
  674.       printf_unfiltered("%s:\n", t->to_longname);
  675.       (t->to_files_info)(t);
  676.       has_all_mem = t->to_has_all_memory;
  677.     }
  678. }
  679.  
  680. /* This is to be called by the open routine before it does
  681.    anything.  */
  682.  
  683. void
  684. target_preopen (from_tty)
  685.      int from_tty;
  686. {
  687.   dont_repeat();
  688.  
  689.   if (target_has_execution)
  690.     {   
  691.       if (query ("A program is being debugged already.  Kill it? "))
  692.         target_kill ();
  693.       else
  694.         error ("Program not killed.");
  695.     }
  696.  
  697.   /* Calling target_kill may remove the target from the stack.  But if
  698.      it doesn't (which seems like a win for UDI), remove it now.  */
  699.  
  700.   if (target_has_execution)
  701.     pop_target ();
  702. }
  703.  
  704. /* Detach a target after doing deferred register stores.  */
  705.  
  706. void
  707. target_detach (args, from_tty)
  708.      char *args;
  709.      int from_tty;
  710. {
  711.   /* Handle any optimized stores to the inferior.  */
  712. #ifdef DO_DEFERRED_STORES
  713.   DO_DEFERRED_STORES;
  714. #endif
  715.   (current_target->to_detach) (args, from_tty);
  716. }
  717.  
  718. void
  719. target_link (modname, t_reloc)
  720.      char *modname;
  721.      CORE_ADDR *t_reloc;
  722. {
  723.   if (STREQ(current_target->to_shortname, "rombug"))
  724.     {
  725.       (current_target->to_lookup_symbol) (modname, t_reloc);
  726.       if (*t_reloc == 0)
  727.       error("Unable to link to %s and get relocation in rombug", modname);
  728.     }
  729.   else
  730.     *t_reloc = (CORE_ADDR)-1;
  731. }
  732.  
  733. /* Look through the list of possible targets for a target that can
  734.    execute a run or attach command without any other data.  This is
  735.    used to locate the default process stratum.
  736.  
  737.    Result is always valid (error() is called for errors).  */
  738.  
  739. static struct target_ops *
  740. find_default_run_target (do_mesg)
  741.      char *do_mesg;
  742. {
  743.   struct target_ops **t;
  744.   struct target_ops *runable = NULL;
  745.   int count;
  746.  
  747.   count = 0;
  748.  
  749.   for (t = target_structs; t < target_structs + target_struct_size;
  750.        ++t)
  751.     {
  752.       if (target_can_run(*t))
  753.     {
  754.       runable = *t;
  755.       ++count;
  756.     }
  757.     }
  758.  
  759.   if (count != 1)
  760.     error ("Don't know how to %s.  Try \"help target\".", do_mesg);
  761.  
  762.   return runable;
  763. }
  764.  
  765. void
  766. find_default_attach (args, from_tty)
  767.      char *args;
  768.      int from_tty;
  769. {
  770.   struct target_ops *t;
  771.  
  772.   t = find_default_run_target("attach");
  773.   (t->to_attach) (args, from_tty);
  774.   return;
  775. }
  776.  
  777. void
  778. find_default_create_inferior (exec_file, allargs, env)
  779.      char *exec_file;
  780.      char *allargs;
  781.      char **env;
  782. {
  783.   struct target_ops *t;
  784.  
  785.   t = find_default_run_target("run");
  786.   (t->to_create_inferior) (exec_file, allargs, env);
  787.   return;
  788. }
  789.  
  790. static int
  791. return_zero ()
  792. {
  793.   return 0;
  794. }
  795.  
  796. struct target_ops *
  797. find_core_target ()
  798. {
  799.   struct target_ops **t;
  800.   struct target_ops *runable = NULL;
  801.   int count;
  802.   
  803.   count = 0;
  804.   
  805.   for (t = target_structs; t < target_structs + target_struct_size;
  806.        ++t)
  807.     {
  808.       if ((*t)->to_stratum == core_stratum)
  809.     {
  810.       runable = *t;
  811.       ++count;
  812.     }
  813.     }
  814.   
  815.   return(count == 1 ? runable : NULL);
  816. }
  817.  
  818. /* The inferior process has died.  Long live the inferior!  */
  819.  
  820. void
  821. generic_mourn_inferior ()
  822. {
  823.   extern int show_breakpoint_hit_counts;
  824.  
  825.   inferior_pid = 0;
  826.   attach_flag = 0;
  827.   breakpoint_init_inferior ();
  828.   registers_changed ();
  829.  
  830. #ifdef CLEAR_DEFERRED_STORES
  831.   /* Delete any pending stores to the inferior... */
  832.   CLEAR_DEFERRED_STORES;
  833. #endif
  834.  
  835.   reopen_exec_file ();
  836.   reinit_frame_cache ();
  837.  
  838.   /* It is confusing to the user for ignore counts to stick around
  839.      from previous runs of the inferior.  So clear them.  */
  840.   /* However, it is more confusing for the ignore counts to disappear when
  841.      using hit counts.  So don't clear them if we're counting hits.  */
  842.   if (!show_breakpoint_hit_counts)
  843.     breakpoint_clear_ignore_counts ();
  844. }
  845.  
  846. /* This table must match in order and size the signals in enum target_signal
  847.    in target.h.  */
  848. static struct {
  849.   char *name;
  850.   char *string;
  851.   } signals [] =
  852. {
  853.   {"0", "Signal 0"},
  854.   {"SIGHUP", "Hangup"},
  855.   {"SIGINT", "Interrupt"},
  856.   {"SIGQUIT", "Quit"},
  857.   {"SIGILL", "Illegal instruction"},
  858.   {"SIGTRAP", "Trace/breakpoint trap"},
  859.   {"SIGABRT", "Aborted"},
  860.   {"SIGEMT", "Emulation trap"},
  861.   {"SIGFPE", "Arithmetic exception"},
  862.   {"SIGKILL", "Killed"},
  863.   {"SIGBUS", "Bus error"},
  864.   {"SIGSEGV", "Segmentation fault"},
  865.   {"SIGSYS", "Bad system call"},
  866.   {"SIGPIPE", "Broken pipe"},
  867.   {"SIGALRM", "Alarm clock"},
  868.   {"SIGTERM", "Terminated"},
  869.   {"SIGURG", "Urgent I/O condition"},
  870.   {"SIGSTOP", "Stopped (signal)"},
  871.   {"SIGTSTP", "Stopped (user)"},
  872.   {"SIGCONT", "Continued"},
  873.   {"SIGCHLD", "Child status changed"},
  874.   {"SIGTTIN", "Stopped (tty input)"},
  875.   {"SIGTTOU", "Stopped (tty output)"},
  876.   {"SIGIO", "I/O possible"},
  877.   {"SIGXCPU", "CPU time limit exceeded"},
  878.   {"SIGXFSZ", "File size limit exceeded"},
  879.   {"SIGVTALRM", "Virtual timer expired"},
  880.   {"SIGPROF", "Profiling timer expired"},
  881.   {"SIGWINCH", "Window size changed"},
  882.   {"SIGLOST", "Resource lost"},
  883.   {"SIGUSR1", "User defined signal 1"},
  884.   {"SIGUSR2", "User defined signal 2"},
  885.   {"SIGPWR", "Power fail/restart"},
  886.   {"SIGPOLL", "Pollable event occurred"},
  887.   {"SIGWIND", "SIGWIND"},
  888.   {"SIGPHONE", "SIGPHONE"},
  889.   {"SIGWAITING", "Process's LWPs are blocked"},
  890.   {"SIGLWP", "Signal LWP"},
  891.   {"SIGDANGER", "Swap space dangerously low"},
  892.   {"SIGGRANT", "Monitor mode granted"},
  893.   {"SIGRETRACT", "Need to relinguish monitor mode"},
  894.   {"SIGMSG", "Monitor mode data available"},
  895.   {"SIGSOUND", "Sound completed"},
  896.   {"SIGSAK", "Secure attention"},
  897.   {NULL, "Unknown signal"},
  898.   {NULL, "Internal error: printing TARGET_SIGNAL_DEFAULT"},
  899.  
  900.   /* Last entry, used to check whether the table is the right size.  */
  901.   {NULL, "TARGET_SIGNAL_MAGIC"}
  902. };
  903.  
  904. /* Return the string for a signal.  */
  905. char *
  906. target_signal_to_string (sig)
  907.      enum target_signal sig;
  908. {
  909.   return signals[sig].string;
  910. }
  911.  
  912. /* Return the name for a signal.  */
  913. char *
  914. target_signal_to_name (sig)
  915.      enum target_signal sig;
  916. {
  917.   if (sig == TARGET_SIGNAL_UNKNOWN)
  918.     /* I think the code which prints this will always print it along with
  919.        the string, so no need to be verbose.  */
  920.     return "?";
  921.   return signals[sig].name;
  922. }
  923.  
  924. /* Given a name, return its signal.  */
  925. enum target_signal
  926. target_signal_from_name (name)
  927.      char *name;
  928. {
  929.   enum target_signal sig;
  930.  
  931.   /* It's possible we also should allow "SIGCLD" as well as "SIGCHLD"
  932.      for TARGET_SIGNAL_SIGCHLD.  SIGIOT, on the other hand, is more
  933.      questionable; seems like by now people should call it SIGABRT
  934.      instead.  */
  935.  
  936.   /* This ugly cast brought to you by the native VAX compiler.  */
  937.   for (sig = TARGET_SIGNAL_HUP;
  938.        signals[sig].name != NULL;
  939.        sig = (enum target_signal)((int)sig + 1))
  940.     if (STREQ (name, signals[sig].name))
  941.       return sig;
  942.   return TARGET_SIGNAL_UNKNOWN;
  943. }
  944.  
  945. /* The following functions are to help certain targets deal
  946.    with the signal/waitstatus stuff.  They could just as well be in
  947.    a file called native-utils.c or unixwaitstatus-utils.c or whatever.  */
  948.  
  949. /* Convert host signal to our signals.  */
  950. enum target_signal
  951. target_signal_from_host (hostsig)
  952.      int hostsig;
  953. {
  954.   /* A switch statement would make sense but would require special kludges
  955.      to deal with the cases where more than one signal has the same number.  */
  956.  
  957.   if (hostsig == 0) return TARGET_SIGNAL_0;
  958.  
  959. #if defined (SIGHUP)
  960.   if (hostsig == SIGHUP) return TARGET_SIGNAL_HUP;
  961. #endif
  962. #if defined (SIGINT)
  963.   if (hostsig == SIGINT) return TARGET_SIGNAL_INT;
  964. #endif
  965. #if defined (SIGQUIT)
  966.   if (hostsig == SIGQUIT) return TARGET_SIGNAL_QUIT;
  967. #endif
  968. #if defined (SIGILL)
  969.   if (hostsig == SIGILL) return TARGET_SIGNAL_ILL;
  970. #endif
  971. #if defined (SIGTRAP)
  972.   if (hostsig == SIGTRAP) return TARGET_SIGNAL_TRAP;
  973. #endif
  974. #if defined (SIGABRT)
  975.   if (hostsig == SIGABRT) return TARGET_SIGNAL_ABRT;
  976. #endif
  977. #if defined (SIGEMT)
  978.   if (hostsig == SIGEMT) return TARGET_SIGNAL_EMT;
  979. #endif
  980. #if defined (SIGFPE)
  981.   if (hostsig == SIGFPE) return TARGET_SIGNAL_FPE;
  982. #endif
  983. #if defined (SIGKILL)
  984.   if (hostsig == SIGKILL) return TARGET_SIGNAL_KILL;
  985. #endif
  986. #if defined (SIGBUS)
  987.   if (hostsig == SIGBUS) return TARGET_SIGNAL_BUS;
  988. #endif
  989. #if defined (SIGSEGV)
  990.   if (hostsig == SIGSEGV) return TARGET_SIGNAL_SEGV;
  991. #endif
  992. #if defined (SIGSYS)
  993.   if (hostsig == SIGSYS) return TARGET_SIGNAL_SYS;
  994. #endif
  995. #if defined (SIGPIPE)
  996.   if (hostsig == SIGPIPE) return TARGET_SIGNAL_PIPE;
  997. #endif
  998. #if defined (SIGALRM)
  999.   if (hostsig == SIGALRM) return TARGET_SIGNAL_ALRM;
  1000. #endif
  1001. #if defined (SIGTERM)
  1002.   if (hostsig == SIGTERM) return TARGET_SIGNAL_TERM;
  1003. #endif
  1004. #if defined (SIGUSR1)
  1005.   if (hostsig == SIGUSR1) return TARGET_SIGNAL_USR1;
  1006. #endif
  1007. #if defined (SIGUSR2)
  1008.   if (hostsig == SIGUSR2) return TARGET_SIGNAL_USR2;
  1009. #endif
  1010. #if defined (SIGCLD)
  1011.   if (hostsig == SIGCLD) return TARGET_SIGNAL_CHLD;
  1012. #endif
  1013. #if defined (SIGCHLD)
  1014.   if (hostsig == SIGCHLD) return TARGET_SIGNAL_CHLD;
  1015. #endif
  1016. #if defined (SIGPWR)
  1017.   if (hostsig == SIGPWR) return TARGET_SIGNAL_PWR;
  1018. #endif
  1019. #if defined (SIGWINCH)
  1020.   if (hostsig == SIGWINCH) return TARGET_SIGNAL_WINCH;
  1021. #endif
  1022. #if defined (SIGURG)
  1023.   if (hostsig == SIGURG) return TARGET_SIGNAL_URG;
  1024. #endif
  1025. #if defined (SIGIO)
  1026.   if (hostsig == SIGIO) return TARGET_SIGNAL_IO;
  1027. #endif
  1028. #if defined (SIGPOLL)
  1029.   if (hostsig == SIGPOLL) return TARGET_SIGNAL_POLL;
  1030. #endif
  1031. #if defined (SIGSTOP)
  1032.   if (hostsig == SIGSTOP) return TARGET_SIGNAL_STOP;
  1033. #endif
  1034. #if defined (SIGTSTP)
  1035.   if (hostsig == SIGTSTP) return TARGET_SIGNAL_TSTP;
  1036. #endif
  1037. #if defined (SIGCONT)
  1038.   if (hostsig == SIGCONT) return TARGET_SIGNAL_CONT;
  1039. #endif
  1040. #if defined (SIGTTIN)
  1041.   if (hostsig == SIGTTIN) return TARGET_SIGNAL_TTIN;
  1042. #endif
  1043. #if defined (SIGTTOU)
  1044.   if (hostsig == SIGTTOU) return TARGET_SIGNAL_TTOU;
  1045. #endif
  1046. #if defined (SIGVTALRM)
  1047.   if (hostsig == SIGVTALRM) return TARGET_SIGNAL_VTALRM;
  1048. #endif
  1049. #if defined (SIGPROF)
  1050.   if (hostsig == SIGPROF) return TARGET_SIGNAL_PROF;
  1051. #endif
  1052. #if defined (SIGXCPU)
  1053.   if (hostsig == SIGXCPU) return TARGET_SIGNAL_XCPU;
  1054. #endif
  1055. #if defined (SIGXFSZ)
  1056.   if (hostsig == SIGXFSZ) return TARGET_SIGNAL_XFSZ;
  1057. #endif
  1058. #if defined (SIGWIND)
  1059.   if (hostsig == SIGWIND) return TARGET_SIGNAL_WIND;
  1060. #endif
  1061. #if defined (SIGPHONE)
  1062.   if (hostsig == SIGPHONE) return TARGET_SIGNAL_PHONE;
  1063. #endif
  1064. #if defined (SIGLOST)
  1065.   if (hostsig == SIGLOST) return TARGET_SIGNAL_LOST;
  1066. #endif
  1067. #if defined (SIGWAITING)
  1068.   if (hostsig == SIGWAITING) return TARGET_SIGNAL_WAITING;
  1069. #endif
  1070. #if defined (SIGLWP)
  1071.   if (hostsig == SIGLWP) return TARGET_SIGNAL_LWP;
  1072. #endif
  1073. #if defined (SIGDANGER)
  1074.   if (hostsig == SIGDANGER) return TARGET_SIGNAL_DANGER;
  1075. #endif
  1076. #if defined (SIGGRANT)
  1077.   if (hostsig == SIGGRANT) return TARGET_SIGNAL_GRANT;
  1078. #endif
  1079. #if defined (SIGRETRACT)
  1080.   if (hostsig == SIGRETRACT) return TARGET_SIGNAL_RETRACT;
  1081. #endif
  1082. #if defined (SIGMSG)
  1083.   if (hostsig == SIGMSG) return TARGET_SIGNAL_MSG;
  1084. #endif
  1085. #if defined (SIGSOUND)
  1086.   if (hostsig == SIGSOUND) return TARGET_SIGNAL_SOUND;
  1087. #endif
  1088. #if defined (SIGSAK)
  1089.   if (hostsig == SIGSAK) return TARGET_SIGNAL_SAK;
  1090. #endif
  1091.   return TARGET_SIGNAL_UNKNOWN;
  1092. }
  1093.  
  1094. int
  1095. target_signal_to_host (oursig)
  1096.      enum target_signal oursig;
  1097. {
  1098.   switch (oursig)
  1099.     {
  1100.     case TARGET_SIGNAL_0: return 0;
  1101.  
  1102. #if defined (SIGHUP)
  1103.     case TARGET_SIGNAL_HUP: return SIGHUP;
  1104. #endif
  1105. #if defined (SIGINT)
  1106.     case TARGET_SIGNAL_INT: return SIGINT;
  1107. #endif
  1108. #if defined (SIGQUIT)
  1109.     case TARGET_SIGNAL_QUIT: return SIGQUIT;
  1110. #endif
  1111. #if defined (SIGILL)
  1112.     case TARGET_SIGNAL_ILL: return SIGILL;
  1113. #endif
  1114. #if defined (SIGTRAP)
  1115.     case TARGET_SIGNAL_TRAP: return SIGTRAP;
  1116. #endif
  1117. #if defined (SIGABRT)
  1118.     case TARGET_SIGNAL_ABRT: return SIGABRT;
  1119. #endif
  1120. #if defined (SIGEMT)
  1121.     case TARGET_SIGNAL_EMT: return SIGEMT;
  1122. #endif
  1123. #if defined (SIGFPE)
  1124.     case TARGET_SIGNAL_FPE: return SIGFPE;
  1125. #endif
  1126. #if defined (SIGKILL)
  1127.     case TARGET_SIGNAL_KILL: return SIGKILL;
  1128. #endif
  1129. #if defined (SIGBUS)
  1130.     case TARGET_SIGNAL_BUS: return SIGBUS;
  1131. #endif
  1132. #if defined (SIGSEGV)
  1133.     case TARGET_SIGNAL_SEGV: return SIGSEGV;
  1134. #endif
  1135. #if defined (SIGSYS)
  1136.     case TARGET_SIGNAL_SYS: return SIGSYS;
  1137. #endif
  1138. #if defined (SIGPIPE)
  1139.     case TARGET_SIGNAL_PIPE: return SIGPIPE;
  1140. #endif
  1141. #if defined (SIGALRM)
  1142.     case TARGET_SIGNAL_ALRM: return SIGALRM;
  1143. #endif
  1144. #if defined (SIGTERM)
  1145.     case TARGET_SIGNAL_TERM: return SIGTERM;
  1146. #endif
  1147. #if defined (SIGUSR1)
  1148.     case TARGET_SIGNAL_USR1: return SIGUSR1;
  1149. #endif
  1150. #if defined (SIGUSR2)
  1151.     case TARGET_SIGNAL_USR2: return SIGUSR2;
  1152. #endif
  1153. #if defined (SIGCHLD) || defined (SIGCLD)
  1154.     case TARGET_SIGNAL_CHLD: 
  1155. #if defined (SIGCHLD)
  1156.       return SIGCHLD;
  1157. #else
  1158.       return SIGCLD;
  1159. #endif
  1160. #endif /* SIGCLD or SIGCHLD */
  1161. #if defined (SIGPWR)
  1162.     case TARGET_SIGNAL_PWR: return SIGPWR;
  1163. #endif
  1164. #if defined (SIGWINCH)
  1165.     case TARGET_SIGNAL_WINCH: return SIGWINCH;
  1166. #endif
  1167. #if defined (SIGURG)
  1168.     case TARGET_SIGNAL_URG: return SIGURG;
  1169. #endif
  1170. #if defined (SIGIO)
  1171.     case TARGET_SIGNAL_IO: return SIGIO;
  1172. #endif
  1173. #if defined (SIGPOLL)
  1174.     case TARGET_SIGNAL_POLL: return SIGPOLL;
  1175. #endif
  1176. #if defined (SIGSTOP)
  1177.     case TARGET_SIGNAL_STOP: return SIGSTOP;
  1178. #endif
  1179. #if defined (SIGTSTP)
  1180.     case TARGET_SIGNAL_TSTP: return SIGTSTP;
  1181. #endif
  1182. #if defined (SIGCONT)
  1183.     case TARGET_SIGNAL_CONT: return SIGCONT;
  1184. #endif
  1185. #if defined (SIGTTIN)
  1186.     case TARGET_SIGNAL_TTIN: return SIGTTIN;
  1187. #endif
  1188. #if defined (SIGTTOU)
  1189.     case TARGET_SIGNAL_TTOU: return SIGTTOU;
  1190. #endif
  1191. #if defined (SIGVTALRM)
  1192.     case TARGET_SIGNAL_VTALRM: return SIGVTALRM;
  1193. #endif
  1194. #if defined (SIGPROF)
  1195.     case TARGET_SIGNAL_PROF: return SIGPROF;
  1196. #endif
  1197. #if defined (SIGXCPU)
  1198.     case TARGET_SIGNAL_XCPU: return SIGXCPU;
  1199. #endif
  1200. #if defined (SIGXFSZ)
  1201.     case TARGET_SIGNAL_XFSZ: return SIGXFSZ;
  1202. #endif
  1203. #if defined (SIGWIND)
  1204.     case TARGET_SIGNAL_WIND: return SIGWIND;
  1205. #endif
  1206. #if defined (SIGPHONE)
  1207.     case TARGET_SIGNAL_PHONE: return SIGPHONE;
  1208. #endif
  1209. #if defined (SIGLOST)
  1210.     case TARGET_SIGNAL_LOST: return SIGLOST;
  1211. #endif
  1212. #if defined (SIGWAITING)
  1213.     case TARGET_SIGNAL_WAITING: return SIGWAITING;
  1214. #endif
  1215. #if defined (SIGLWP)
  1216.     case TARGET_SIGNAL_LWP: return SIGLWP;
  1217. #endif
  1218. #if defined (SIGDANGER)
  1219.     case TARGET_SIGNAL_DANGER: return SIGDANGER;
  1220. #endif
  1221. #if defined (SIGGRANT)
  1222.     case TARGET_SIGNAL_GRANT: return SIGGRANT;
  1223. #endif
  1224. #if defined (SIGRETRACT)
  1225.     case TARGET_SIGNAL_RETRACT: return SIGRETRACT;
  1226. #endif
  1227. #if defined (SIGMSG)
  1228.     case TARGET_SIGNAL_MSG: return SIGMSG;
  1229. #endif
  1230. #if defined (SIGSOUND)
  1231.     case TARGET_SIGNAL_SOUND: return SIGSOUND;
  1232. #endif
  1233. #if defined (SIGSAK)
  1234.     case TARGET_SIGNAL_SAK: return SIGSAK;
  1235. #endif
  1236.     default:
  1237.       /* The user might be trying to do "signal SIGSAK" where this system
  1238.      doesn't have SIGSAK.  */
  1239.       warning ("Signal %s does not exist on this system.\n",
  1240.            target_signal_to_name (oursig));
  1241.       return 0;
  1242.     }
  1243. }
  1244.  
  1245. /* Helper function for child_wait and the Lynx derivatives of child_wait.
  1246.    HOSTSTATUS is the waitstatus from wait() or the equivalent; store our
  1247.    translation of that in OURSTATUS.  */
  1248. void
  1249. store_waitstatus (ourstatus, hoststatus)
  1250.      struct target_waitstatus *ourstatus;
  1251.      int hoststatus;
  1252. {
  1253. #ifdef CHILD_SPECIAL_WAITSTATUS
  1254.   /* CHILD_SPECIAL_WAITSTATUS should return nonzero and set *OURSTATUS
  1255.      if it wants to deal with hoststatus.  */
  1256.   if (CHILD_SPECIAL_WAITSTATUS (ourstatus, hoststatus))
  1257.     return;
  1258. #endif
  1259.  
  1260.   if (WIFEXITED (hoststatus))
  1261.     {
  1262.       ourstatus->kind = TARGET_WAITKIND_EXITED;
  1263.       ourstatus->value.integer = WEXITSTATUS (hoststatus);
  1264.     }
  1265.   else if (!WIFSTOPPED (hoststatus))
  1266.     {
  1267.       ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
  1268.       ourstatus->value.sig = target_signal_from_host (WTERMSIG (hoststatus));
  1269.     }
  1270.   else
  1271.     {
  1272.       ourstatus->kind = TARGET_WAITKIND_STOPPED;
  1273.       ourstatus->value.sig = target_signal_from_host (WSTOPSIG (hoststatus));
  1274.     }
  1275. }
  1276.  
  1277.  
  1278. /* Returns zero to leave the inferior alone, one to interrupt it.  */
  1279. int (*target_activity_function) PARAMS ((void));
  1280. int target_activity_fd;
  1281.  
  1282. /* Convert a normal process ID to a string.  Returns the string in a static
  1283.    buffer.  */
  1284.  
  1285. char *
  1286. normal_pid_to_str (pid)
  1287.      int pid;
  1288. {
  1289.   static char buf[30];
  1290.  
  1291.   sprintf (buf, "process %d", pid);
  1292.  
  1293.   return buf;
  1294. }
  1295.  
  1296. static char targ_desc[] = 
  1297.     "Names of targets and files being debugged.\n\
  1298. Shows the entire stack of targets currently in use (including the exec-file,\n\
  1299. core-file, and process, if any), as well as the symbol file name.";
  1300.  
  1301. void
  1302. _initialize_targets ()
  1303. {
  1304.   current_target = &dummy_target;
  1305.   cleanup_target (current_target);
  1306.  
  1307.   add_info ("target", target_info, targ_desc);
  1308.   add_info ("files", target_info, targ_desc);
  1309.  
  1310.   if (!STREQ (signals[TARGET_SIGNAL_LAST].string, "TARGET_SIGNAL_MAGIC"))
  1311.     abort ();
  1312. }
  1313.