aboutsummaryrefslogtreecommitdiff
path: root/gdb/exec.c
diff options
context:
space:
mode:
authorJim Kingdon <jkingdon@engr.sgi.com>1993-12-26 23:33:14 +0000
committerJim Kingdon <jkingdon@engr.sgi.com>1993-12-26 23:33:14 +0000
commitb02fd8caa2a3353799c4312e8f06a9f533569f5c (patch)
treeacd7940b919d69ab2a4ce66f976ea78f6ee58215 /gdb/exec.c
parentb2f03c3027a5a7412a447a2f8e117c0c5ad65790 (diff)
downloadfsf-binutils-gdb-b02fd8caa2a3353799c4312e8f06a9f533569f5c.zip
fsf-binutils-gdb-b02fd8caa2a3353799c4312e8f06a9f533569f5c.tar.gz
fsf-binutils-gdb-b02fd8caa2a3353799c4312e8f06a9f533569f5c.tar.bz2
* exec.c (exec_file_command): If error occurs after we have opened
exec_bfd but before we call push_target, make sure to close exec_bfd.
Diffstat (limited to 'gdb/exec.c')
-rw-r--r--gdb/exec.c54
1 files changed, 38 insertions, 16 deletions
diff --git a/gdb/exec.c b/gdb/exec.c
index 444c89e..356f07b 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -22,6 +22,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "inferior.h"
#include "target.h"
#include "gdbcmd.h"
+#include "language.h"
#ifdef USG
#include <sys/types.h>
@@ -150,25 +151,46 @@ exec_file_command (args, from_tty)
error ("Could not open `%s' as an executable file: %s",
scratch_pathname, bfd_errmsg (bfd_error));
if (!bfd_check_format (exec_bfd, bfd_object))
- error ("\"%s\": not in executable format: %s.",
- scratch_pathname, bfd_errmsg (bfd_error));
+ {
+ /* Make sure to close exec_bfd, or else "run" might try to use
+ it. */
+ exec_close (0);
+ error ("\"%s\": not in executable format: %s.",
+ scratch_pathname, bfd_errmsg (bfd_error));
+ }
if (build_section_table (exec_bfd, &exec_ops.to_sections,
&exec_ops.to_sections_end))
- error ("Can't find the file sections in `%s': %s",
- exec_bfd->filename, bfd_errmsg (bfd_error));
+ {
+ /* Make sure to close exec_bfd, or else "run" might try to use
+ it. */
+ exec_close (0);
+ error ("Can't find the file sections in `%s': %s",
+ exec_bfd->filename, bfd_errmsg (bfd_error));
+ }
#ifdef NEED_TEXT_START_END
- /* This is a KLUDGE (FIXME) because a few places in a few ports
- (29K springs to mind) need this info for now. */
+
+ /* text_end is sometimes used for where to put call dummies. A
+ few ports use these for other purposes too. */
+
{
struct section_table *p;
+
+ /* Set text_start to the lowest address of the start of any
+ readonly code section and set text_end to the highest
+ address of the end of any readonly code section. */
+
+ text_start = ~(CORE_ADDR)0;
+ text_end = (CORE_ADDR)0;
for (p = exec_ops.to_sections; p < exec_ops.to_sections_end; p++)
- if (STREQ (".text", bfd_section_name (p->bfd, p->sec_ptr)))
+ if (bfd_get_section_flags (p->bfd, p->sec_ptr)
+ & (SEC_CODE | SEC_READONLY))
{
- text_start = p->addr;
- text_end = p->endaddr;
- break;
+ if (text_start > p->addr)
+ text_start = p->addr;
+ if (text_end < p->endaddr)
+ text_end = p->endaddr;
}
}
#endif
@@ -182,7 +204,7 @@ exec_file_command (args, from_tty)
(*exec_file_display_hook) (filename);
}
else if (from_tty)
- printf ("No exec file now.\n");
+ printf_unfiltered ("No exec file now.\n");
}
/* Set both the exec file and the symbol file, in one command.
@@ -344,13 +366,13 @@ print_section_info (t, abfd)
wrap_here (" ");
printf_filtered ("file type %s.\n", bfd_get_target(abfd));
printf_filtered ("\tEntry point: %s\n",
- local_hex_string (bfd_get_start_address (exec_bfd)));
+ local_hex_string ((unsigned long) bfd_get_start_address (exec_bfd)));
for (p = t->to_sections; p < t->to_sections_end; p++) {
- printf_filtered ("\t%s", local_hex_string_custom (p->addr, "08"));
- printf_filtered (" - %s", local_hex_string_custom (p->endaddr, "08"));
+ printf_filtered ("\t%s", local_hex_string_custom ((unsigned long) p->addr, "08l"));
+ printf_filtered (" - %s", local_hex_string_custom ((unsigned long) p->endaddr, "08l"));
if (info_verbose)
printf_filtered (" @ %s",
- local_hex_string_custom (p->sec_ptr->filepos, "08"));
+ local_hex_string_custom ((unsigned long) p->sec_ptr->filepos, "08l"));
printf_filtered (" is %s", bfd_section_name (p->bfd, p->sec_ptr));
if (p->bfd != abfd) {
printf_filtered (" in %s", bfd_get_filename (p->bfd));
@@ -407,7 +429,7 @@ set_section_command (args, from_tty)
}
/* If mourn is being called in all the right places, this could be say
- `gdb internal error' (since generic_mourn calls mark_breakpoints_out). */
+ `gdb internal error' (since generic_mourn calls breakpoint_init_inferior). */
static int
ignore (addr, contents)