/* If the timestamp of the exec file has changed, reopen it. */
filename = xstrdup (bfd_get_filename (exec_bfd));
make_cleanup (xfree, filename);
- mtime = bfd_get_mtime (exec_bfd);
res = stat (filename, &st);
- if (mtime && mtime != st.st_mtime)
+ if (exec_bfd_mtime && exec_bfd_mtime != st.st_mtime)
exec_file_attach (filename, 0);
+ else
+ /* If we accessed the file since last opening it, close it now;
+ this stops GDB from holding the executable open after it
+ exits. */
+ bfd_cache_close_all ();
#endif
}
\f
write_memory (CORE_ADDR memaddr, const bfd_byte *myaddr, int len)
{
int status;
- gdb_byte *bytes = alloca (len);
-
- memcpy (bytes, myaddr, len);
- status = target_write_memory (memaddr, bytes, len);
+ status = target_write_memory (memaddr, myaddr, len);
if (status != 0)
memory_error (status, memaddr);
}
add_setshow_string_noescape_cmd ("gnutarget", class_files,
- &gnutarget_string, _("(\
+ &gnutarget_string, _("\
Set the current BFD target."), _("\
Show the current BFD target."), _("\
Use `set gnutarget auto' to specify automatic detection."),