static enum arm_abi_kind arm_abi_global = ARM_ABI_AUTO;
static const char *arm_abi_string = "auto";
-/* The execution mode to assume. */
-static const char *arm_mode_strings[] =
- {
- "auto",
- "arm",
- "thumb"
- };
-
-static const char *arm_fallback_mode_string = "auto";
-static const char *arm_force_mode_string = "auto";
-
/* Number of different reg name sets (options). */
static int num_disassembly_options;
if (IS_THUMB_ADDR (memaddr))
return 1;
- /* If the user wants to override the symbol table, let him. */
- if (strcmp (arm_force_mode_string, "arm") == 0)
- return 0;
- if (strcmp (arm_force_mode_string, "thumb") == 0)
- return 1;
-
/* Thumb functions have a "special" bit set in minimal symbols. */
sym = lookup_minimal_symbol_by_pc (memaddr);
if (sym)
- return (MSYMBOL_IS_SPECIAL (sym));
-
- /* If the user wants to override the fallback mode, let them. */
- if (strcmp (arm_fallback_mode_string, "arm") == 0)
- return 0;
- if (strcmp (arm_fallback_mode_string, "thumb") == 0)
- return 1;
-
- /* If we couldn't find any symbol, but we're talking to a running
- target, then trust the current value of $cpsr. */
- if (target_has_registers)
- return (read_register (ARM_PS_REGNUM) & 0x20) != 0;
-
- /* Otherwise we're out of luck; we assume ARM. */
- return 0;
+ {
+ return (MSYMBOL_IS_SPECIAL (sym));
+ }
+ else
+ {
+ return 0;
+ }
#else
/* ARMV7M processors are always in Thumb mode. */
return 1;
arm_abi_string);
}
-static void
-arm_show_fallback_mode (struct ui_file *file, int from_tty,
- struct cmd_list_element *c, const char *value)
-{
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
-
- fprintf_filtered (file, _("\
-The current execution mode assumed (when symbols are unavailable) is \"%s\".\n"),
- arm_fallback_mode_string);
-}
-
-static void
-arm_show_force_mode (struct ui_file *file, int from_tty,
- struct cmd_list_element *c, const char *value)
-{
- struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch);
-
- fprintf_filtered (file, _("\
-The current execution mode assumed (even when symbols are available) is \"%s\".\n"),
- arm_force_mode_string);
-}
-
/* If the user changes the register disassembly style used for info
register and other commands, we have to also switch the style used
in opcodes for disassembly output. This function is run in the "set
NULL, arm_set_abi, arm_show_abi,
&setarmcmdlist, &showarmcmdlist);
- /* Add two commands to allow the user to force the assumed
- execution mode. */
- add_setshow_enum_cmd ("fallback-mode", class_support,
- arm_mode_strings, &arm_fallback_mode_string,
- _("Set the mode assumed when symbols are unavailable."),
- _("Show the mode assumed when symbols are unavailable."),
- NULL, NULL, arm_show_fallback_mode,
- &setarmcmdlist, &showarmcmdlist);
- add_setshow_enum_cmd ("force-mode", class_support,
- arm_mode_strings, &arm_force_mode_string,
- _("Set the mode assumed even when symbols are available."),
- _("Show the mode assumed even when symbols are available."),
- NULL, NULL, arm_show_force_mode,
- &setarmcmdlist, &showarmcmdlist);
-
/* Debugging flag. */
add_setshow_boolean_cmd ("arm", class_maintenance, &arm_debug,
_("Set ARM debugging."),
@item show arm abi
Show the currently used ABI.
-@item set arm fallback-mode
-This command sets the mode (ARM versus Thumb) which @value{GDBN} will
-assume for code without a symbol table. The default is @samp{auto},
-which causes @value{GDBN} to use the mode associated with the current
-CPSR.
-
-@item show arm fallback-mode
-Show the current fallback execution mode.
-
-@item set arm force-mode
-This command sets the mode (ARM versus Thumb) which @value{GDBN} will
-assume for all code, even when a symbol table is present. The default
-is @samp{auto}, which causes @value{GDBN} to use the symbol table
-and fall back to the value of @samp{set arm fallback-mode}.
-
-@item show arm force-mode
-Show the currently forced execution mode.
-
@item set debug arm
Toggle whether to display ARM-specific debugging messages from the ARM
target support subsystem.
/* Make sure it died. The loop is most likely unnecessary. */
wstat = linux_wait_for_event (thread);
} while (WIFSTOPPED (wstat));
-
- clear_inferiors ();
- free (all_processes.head);
- all_processes.head = all_processes.tail = NULL;
}
static void
return;
err:
- write_enn (own_buf);
+ /* No other way to report an error... */
+ strcpy (own_buf, "");
free (resume_info);
return;
}
"HOST:PORT to listen for a TCP connection.\n");
}
-/* FIXME declare here, give sensible name, give values? */
-extern int debug_threads;
-
int
main (int argc, char *argv[])
{
exit (1);
}
- if (argc >= 2 && strcmp (argv[1], "--debug") == 0)
- {
- argc--;
- argv++;
- debug_threads = 1;
- }
-
bad_attach = 0;
pid = 0;
attached = 0;
unsigned long gdb_id, thread_id;
gdb_id = strtoul (&own_buf[2], NULL, 16);
- if (gdb_id == 0 || gdb_id == -1)
- thread_id = gdb_id;
- else
+ thread_id = gdb_id_to_thread_id (gdb_id);
+ if (thread_id == 0)
{
- thread_id = gdb_id_to_thread_id (gdb_id);
- if (thread_id == 0)
- {
- write_enn (own_buf);
- break;
- }
+ write_enn (own_buf);
+ break;
}
if (own_buf[1] == 'g')
}
\f
-/* Mark OPS as a running target. This should restore the target to its
- original state, undoing any effects of remote_mark_killed. */
-
-static void
-remote_mark_running (struct target_ops *ops)
-{
- ops->to_has_execution = 1;
- ops->to_has_all_memory = 1;
- ops->to_has_memory = 1;
- ops->to_has_stack = 1;
- ops->to_has_registers = 1;
-
- update_current_target ();
-}
-
-/* Mark OPS as a dead target, undoing any effects of remote_mark_running.
- The target is still on the stack, and GDB is still connected to it,
- but the process we were debugging has exited. */
-
-static void
-remote_mark_killed (struct target_ops *ops)
-{
- ops->to_has_execution = 0;
- ops->to_has_all_memory = 0;
- ops->to_has_memory = 0;
- ops->to_has_stack = 0;
- ops->to_has_registers = 0;
-
- update_current_target ();
-}
-
/* Restart the remote side; this is an extended protocol operation. */
static void
struct remote_state *rs = get_remote_state ();
char *buf = rs->buf;
char *ptr;
- int lose, seen_text_seg = 0;
+ int lose;
CORE_ADDR text_addr, data_addr, bss_addr;
struct section_offsets *offs;
/* Don't use strtol, could lose on big values. */
while (*ptr && *ptr != ';')
text_addr = (text_addr << 4) + fromhex (*ptr++);
-
- if (strncmp (ptr, ";Data=", 6) == 0)
- {
- ptr += 6;
- while (*ptr && *ptr != ';')
- data_addr = (data_addr << 4) + fromhex (*ptr++);
- }
- else
- lose = 1;
-
- if (!lose && strncmp (ptr, ";Bss=", 5) == 0)
- {
- ptr += 5;
- while (*ptr && *ptr != ';')
- bss_addr = (bss_addr << 4) + fromhex (*ptr++);
- }
- else
- lose = 1;
}
- else if (strncmp (ptr, "TextSeg=", 8) == 0)
+ else
+ lose = 1;
+
+ if (!lose && strncmp (ptr, ";Data=", 6) == 0)
{
- ptr += 8;
- /* Don't use strtol, could lose on big values. */
+ ptr += 6;
while (*ptr && *ptr != ';')
- text_addr = (text_addr << 4) + fromhex (*ptr++);
- seen_text_seg = 1;
+ data_addr = (data_addr << 4) + fromhex (*ptr++);
+ }
+ else
+ lose = 1;
- if (strncmp (ptr, ";DataSeg=", 9) == 0)
- {
- ptr += 9;
- while (*ptr && *ptr != ';')
- data_addr = (data_addr << 4) + fromhex (*ptr++);
- }
- else
- lose = 1;
+ if (!lose && strncmp (ptr, ";Bss=", 5) == 0)
+ {
+ ptr += 5;
+ while (*ptr && *ptr != ';')
+ bss_addr = (bss_addr << 4) + fromhex (*ptr++);
}
else
lose = 1;
memcpy (offs, symfile_objfile->section_offsets,
SIZEOF_N_SECTION_OFFSETS (symfile_objfile->num_sections));
- if (seen_text_seg)
- {
- if (! symfile_map_offsets_to_segments (symfile_objfile, offs,
- text_addr, data_addr))
- error (_("Can not handle qOffsets TextSeg response with this symbol file"));
- }
- else
- {
- offs->offsets[SECT_OFF_TEXT (symfile_objfile)] = text_addr;
+ offs->offsets[SECT_OFF_TEXT (symfile_objfile)] = text_addr;
- /* This is a temporary kludge to force data and bss to use the same offsets
- because that's what nlmconv does now. The real solution requires changes
- to the stub and remote.c that I don't have time to do right now. */
+ /* This is a temporary kludge to force data and bss to use the same offsets
+ because that's what nlmconv does now. The real solution requires changes
+ to the stub and remote.c that I don't have time to do right now. */
- offs->offsets[SECT_OFF_DATA (symfile_objfile)] = data_addr;
- offs->offsets[SECT_OFF_BSS (symfile_objfile)] = data_addr;
- }
+ offs->offsets[SECT_OFF_DATA (symfile_objfile)] = data_addr;
+ offs->offsets[SECT_OFF_BSS (symfile_objfile)] = data_addr;
objfile_relocate (symfile_objfile, offs);
}
unpush_target (target);
- /* We're about to connect; assume that the target will be running
- when we do so. */
- remote_mark_running (target);
-
remote_desc = remote_serial_open (name);
if (!remote_desc)
perror_with_name (name);
/* Same as remote_detach, but don't send the "D" packet; just disconnect. */
static void
-remote_disconnect (struct target_ops *target, char *args, int from_tty)
+remote_disconnect (char *args, int from_tty)
{
if (args)
- error (_("Argument given to \"disconnect\" when remotely debugging."));
+ error (_("Argument given to \"detach\" when remotely debugging."));
/* Unregister the file descriptor from the event loop. */
if (target_is_async_p ())
serial_async (remote_desc, NULL, 0);
- /* Make sure we unpush even the extended remote targets; mourn
- won't do it. So call remote_mourn_1 directly instead of
- target_mourn_inferior. */
- remote_mourn_1 (target);
-
+ target_mourn_inferior ();
if (from_tty)
puts_filtered ("Ending remote debugging.\n");
}
static void
extended_remote_mourn (void)
{
- /* We do not want to unpush the target; then the next time the
- user says "run", we won't be connected. Just mark ourselves
- as not executing. */
+ /* We do _not_ want to mourn the target like this; this will
+ remove the extended remote target from the target stack,
+ and the next time the user says "run" it'll fail.
- generic_mourn_inferior ();
- remote_mark_killed (&extended_remote_ops);
-}
-
-static void
-extended_async_remote_mourn (void)
-{
- /* We do not want to unpush the target; then the next time the
- user says "run", we won't be connected. Just mark ourselves
- as not executing. */
-
- generic_mourn_inferior ();
- remote_mark_killed (&extended_async_remote_ops);
+ FIXME: What is the right thing to do here? */
+#if 0
+ remote_mourn_1 (&extended_remote_ops);
+#endif
}
/* Worker function for remote_mourn. */
/* Clean up from the last time we were running. */
clear_proceed_status ();
-
- remote_mark_running (&extended_remote_ops);
}
/* Async version of extended_remote_create_inferior. */
/* Clean up from the last time we were running. */
clear_proceed_status ();
-
- remote_mark_running (&extended_async_remote_ops);
}
\f
static int
remote_stopped_by_watchpoint (void)
{
- return remote_stopped_by_watchpoint_p;
+ return remote_stopped_by_watchpoint_p;
}
extern int stepped_after_stopped_by_watchpoint;
/* Table used by the crc32 function to calcuate the checksum. */
static unsigned long crc32_table[256] =
- {0, 0};
+{0, 0};
static unsigned long
crc32 (unsigned char *buf, int len, unsigned int crc)
/* compare-sections command
-With no arguments, compares each loadable section in the exec bfd
-with the same memory range on the target, and reports mismatches.
-Useful for verifying the image on the target against the exec file.
-Depends on the target understanding the new "qCRC:" request. */
+ With no arguments, compares each loadable section in the exec bfd
+ with the same memory range on the target, and reports mismatches.
+ Useful for verifying the image on the target against the exec file.
+ Depends on the target understanding the new "qCRC:" request. */
/* FIXME: cagney/1999-10-26: This command should be broken down into a
target method (target verify memory) and generic version of the
/* Target async and target extended-async.
-This are temporary targets, until it is all tested. Eventually
-async support will be incorporated int the usual 'remote'
-target. */
+ This are temporary targets, until it is all tested. Eventually
+ async support will be incorporated int the usual 'remote'
+ target. */
static void
init_remote_async_ops (void)
Specify the serial device it is connected to (e.g. /dev/ttya).",
extended_async_remote_ops.to_open = extended_remote_async_open;
extended_async_remote_ops.to_create_inferior = extended_remote_async_create_inferior;
- extended_async_remote_ops.to_mourn_inferior = extended_async_remote_mourn;
+ extended_async_remote_ops.to_mourn_inferior = extended_remote_mourn;
}
static void
return bfd_simple_get_relocated_section_contents (abfd, sectp, buf, NULL);
}
-/* FIXME: This should probably go through the symfile ops vector. */
-
-#include "elf/internal.h"
-#include "elf/common.h"
-
-int
-symfile_map_offsets_to_segments (struct objfile *objfile,
- struct section_offsets *offsets,
- CORE_ADDR text_addr, CORE_ADDR data_addr)
-{
- Elf_Internal_Phdr *phdrs, *segments[2];
- int num_phdrs, i, num_segments;
- long phdrs_size;
- bfd *abfd = objfile->obfd;
- asection *sect;
- CORE_ADDR text_offset, data_offset;
-
- phdrs_size = bfd_get_elf_phdr_upper_bound (objfile->obfd);
- if (phdrs_size == -1)
- return 0;
-
- phdrs = alloca (phdrs_size);
- num_phdrs = bfd_get_elf_phdrs (objfile->obfd, phdrs);
- if (num_phdrs == -1)
- return 0;
-
- num_segments = 0;
- for (i = 0; i < num_phdrs; i++)
- if (phdrs[i].p_type == PT_LOAD)
- {
- if (num_segments == 2)
- return 0;
- segments[num_segments++] = &phdrs[i];
- }
-
- if (num_segments == 0)
- return 0;
-
- if (num_segments == 1)
- {
- if ((segments[0]->p_flags & PF_W) && !(segments[0]->p_flags & PF_X))
- {
- segments[1] = segments[0];
- segments[0] = NULL;
- }
- else
- segments[1] = NULL;
- }
- else
- {
- if ((segments[0]->p_flags & PF_X) && !(segments[1]->p_flags & PF_X))
- /* OK */;
- else if ((segments[1]->p_flags & PF_X) && !(segments[0]->p_flags & PF_X))
- {
- Elf_Internal_Phdr *tmp = segments[0];
- segments[0] = segments[1];
- segments[1] = tmp;
- }
- else if ((segments[1]->p_flags & PF_W) && !(segments[0]->p_flags & PF_W))
- /* OK */;
- else if ((segments[0]->p_flags & PF_W) && !(segments[1]->p_flags & PF_W))
- {
- Elf_Internal_Phdr *tmp = segments[0];
- segments[0] = segments[1];
- segments[1] = tmp;
- }
- else
- return 0;
- }
-
- text_offset = text_addr - segments[0]->p_vaddr;
- data_offset = data_addr - segments[1]->p_vaddr;
-
- for (i = 0, sect = abfd->sections; sect != NULL; i++, sect = sect->next)
- {
- CORE_ADDR vma;
-
- if ((bfd_get_section_flags (abfd, sect) & SEC_LOAD) == 0)
- continue;
-
- vma = bfd_get_section_vma (abfd, sect);
-
- if (segments[0]
- && vma >= segments[0]->p_vaddr
- && vma < segments[0]->p_vaddr + segments[0]->p_memsz)
- offsets->offsets[i] = text_offset;
-
- else if (segments[1]
- && vma >= segments[1]->p_vaddr
- && vma < segments[1]->p_vaddr + segments[1]->p_memsz)
- offsets->offsets[i] = data_offset;
-
- else
- warning (_("Loadable segment \"%s\" outside of ELF segments"),
- bfd_section_name (abfd, sect));
- }
-
- return 1;
-}
-
void
_initialize_symfile (void)
{
extern bfd_byte *symfile_relocate_debug_section (bfd *abfd, asection *sectp,
bfd_byte * buf);
-extern int symfile_map_offsets_to_segments (struct objfile *,
- struct section_offsets *,
- CORE_ADDR, CORE_ADDR);
-
/* From dwarfread.c */
extern void dwarf_build_psymtabs (struct objfile *, int, file_ptr,
static void debug_to_detach (char *, int);
+static void debug_to_disconnect (char *, int);
+
static void debug_to_resume (ptid_t, int, enum target_signal);
static ptid_t debug_to_wait (ptid_t, struct target_waitstatus *);
locally search the target stack for the target that can handle the
request. */
-void
+static void
update_current_target (void)
{
struct target_ops *t;
INHERIT (to_attach, t);
INHERIT (to_post_attach, t);
INHERIT (to_detach, t);
- /* Do not inherit to_disconnect. */
+ INHERIT (to_disconnect, t);
INHERIT (to_resume, t);
INHERIT (to_wait, t);
INHERIT (to_fetch_registers, t);
de_fault (to_detach,
(void (*) (char *, int))
target_ignore);
+ de_fault (to_disconnect,
+ (void (*) (char *, int))
+ tcomplain);
de_fault (to_resume,
(void (*) (ptid_t, int, enum target_signal))
noprocess);
void
target_disconnect (char *args, int from_tty)
{
- struct target_ops *t;
-
- for (t = current_target.beneath; t != NULL; t = t->beneath)
- if (t->to_disconnect != NULL)
- {
- if (targetdebug)
- fprintf_unfiltered (gdb_stdlog, "target_disconnect (%s, %d)\n",
- args, from_tty);
- t->to_disconnect (t, args, from_tty);
- return;
- }
-
- tcomplain ();
+ (current_target.to_disconnect) (args, from_tty);
}
int
fprintf_unfiltered (gdb_stdlog, "target_detach (%s, %d)\n", args, from_tty);
}
+static void
+debug_to_disconnect (char *args, int from_tty)
+{
+ debug_target.to_disconnect (args, from_tty);
+
+ fprintf_unfiltered (gdb_stdlog, "target_disconnect (%s, %d)\n",
+ args, from_tty);
+}
+
static void
debug_to_resume (ptid_t ptid, int step, enum target_signal siggnal)
{
current_target.to_attach = debug_to_attach;
current_target.to_post_attach = debug_to_post_attach;
current_target.to_detach = debug_to_detach;
+ current_target.to_disconnect = debug_to_disconnect;
current_target.to_resume = debug_to_resume;
current_target.to_wait = debug_to_wait;
current_target.to_fetch_registers = debug_to_fetch_registers;
current_target.to_enable_exception_callback = debug_to_enable_exception_callback;
current_target.to_get_current_exception_event = debug_to_get_current_exception_event;
current_target.to_pid_to_exec_file = debug_to_pid_to_exec_file;
+
}
\f
void (*to_attach) (char *, int);
void (*to_post_attach) (int);
void (*to_detach) (char *, int);
- void (*to_disconnect) (struct target_ops *, char *, int);
+ void (*to_disconnect) (char *, int);
void (*to_resume) (ptid_t, int, enum target_signal);
ptid_t (*to_wait) (ptid_t, struct target_waitstatus *);
void (*to_fetch_registers) (int);
(current_target.to_has_registers)
/* Does the target have execution? Can we make it jump (through
- hoops), or pop its stack a few times? This used to mean the target
- was capable of execution; now it means that a program is actually
- running. */
+ hoops), or pop its stack a few times? FIXME: If this is to work that
+ way, it needs to check whether an inferior actually exists.
+ remote-udi.c and probably other targets can be the current target
+ when the inferior doesn't actually exist at the moment. Right now
+ this just tells us whether this target is *capable* of execution. */
#define target_has_execution \
(current_target.to_has_execution)
extern void pop_target (void);
-/* Update current_target after some target on the current stack has
- changed state. */
-
-extern void update_current_target (void);
-
/* Struct section_table maps address ranges to file sections. It is
mostly used with BFD files, but can be used without (e.g. for handling
raw disks, or files not in formats handled by BFD). */
{ ISFUNC, rl_insert }, /* Latin capital letter Y with acute */
{ ISFUNC, rl_insert }, /* Latin capital letter thorn (Icelandic) */
{ ISFUNC, rl_insert }, /* Latin small letter sharp s (German) */
-#ifndef __MINGW32__
{ ISFUNC, rl_insert }, /* Latin small letter a with grave */
-#else
- { ISFUNC, 0 }, /* Must leave this unbound for the arrow keys to work. */
-#endif
{ ISFUNC, rl_insert }, /* Latin small letter a with acute */
{ ISFUNC, rl_insert }, /* Latin small letter a with circumflex */
{ ISFUNC, rl_insert }, /* Latin small letter a with tilde */
#endif
#ifdef __MINGW32__
- _rl_bind_if_unbound ("\340H", rl_get_previous_history);
- _rl_bind_if_unbound ("\340P", rl_get_next_history);
- _rl_bind_if_unbound ("\340M", rl_forward_char);
- _rl_bind_if_unbound ("\340K", rl_backward_char);
+ /* Under Windows, when an extend key (like an arrow key) is
+ pressed, getch() will return 340 (octal) followed by a code for
+ the extended key. We use macros to transform those into the
+ normal ANSI terminal sequences for these keys. */
+
+ /* Up arrow. */
+ rl_macro_bind ("\340H", "\033[A", map);
+ /* Left arrow. */
+ rl_macro_bind ("\340K", "\033[D", map);
+ /* Right arrow. */
+ rl_macro_bind ("\340M", "\033[C", map);
+ /* Down arrow. */
+ rl_macro_bind ("\340P", "\033[B", map);
#endif
_rl_bind_if_unbound ("\033[A", rl_get_previous_history);