* RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
@ 2006-02-20 22:03 Daniel Jacobowitz
2006-02-21 15:36 ` Richard Earnshaw
2006-02-25 11:12 ` Jim Blandy
0 siblings, 2 replies; 16+ messages in thread
From: Daniel Jacobowitz @ 2006-02-20 22:03 UTC (permalink / raw)
To: gdb-patches; +Cc: Richard Earnshaw, Shaun Jackman
I'm fishing for comments on this change. In arm_pc_is_thumb, if we can not
find a symbol covering the supplied PC, we assume ARM mode; it seems that it
would be strictly more useful to assume the current mode.
This patch _should not be used_ as is! Paul Brook cleverly noticed that
this will mess up breakpoint_from_pc when removing breakpoints, causing us
to insert 2-byte breakpoints and remove 4-byte ones across a mode switch.
I'm going to have to mess with the target_remove_breakpoint interface
to fix that, so I wanted to get opinions on this patch first before I dig
in.
This is still a somewhat creepy thing to do. You can find quotes of me in
the gdb@ list archives saying that this is "the way to madness". However,
I've been debugging some code which jumps to Thumb-mode routines in ROM
today, and my GDB doesn't yet have symbol information for the ROM code; so
I'm well down the way to madness without this patch, and it's somewhat
better with.
Maybe there should be a "set" option for the default when no symbol is
found, allowing the user to throttle this back to ARM-only if that works
better for them?
--
Daniel Jacobowitz
CodeSourcery
2006-02-20 Daniel Jacobowitz <dan@codesourcery.com>
* arm-tdep.c (arm_pc_is_thumb): Fall back to the CPSR.
NOTE: NOT FOR COMMIT
Index: src/gdb/arm-tdep.c
===================================================================
--- src.orig/gdb/arm-tdep.c 2006-02-02 15:38:35.000000000 -0500
+++ src/gdb/arm-tdep.c 2006-02-20 16:11:02.000000000 -0500
@@ -184,13 +184,15 @@ arm_pc_is_thumb (CORE_ADDR memaddr)
/* Thumb functions have a "special" bit set in minimal symbols. */
sym = lookup_minimal_symbol_by_pc (memaddr);
if (sym)
- {
- return (MSYMBOL_IS_SPECIAL (sym));
- }
- else
- {
- return 0;
- }
+ return (MSYMBOL_IS_SPECIAL (sym));
+
+ /* 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;
}
/* Remove useless bits from addresses in a running program. */
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2006-02-20 22:03 RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb Daniel Jacobowitz
@ 2006-02-21 15:36 ` Richard Earnshaw
2006-02-21 16:10 ` Daniel Jacobowitz
2006-02-25 11:12 ` Jim Blandy
1 sibling, 1 reply; 16+ messages in thread
From: Richard Earnshaw @ 2006-02-21 15:36 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches, Shaun Jackman
On Mon, 2006-02-20 at 21:49, Daniel Jacobowitz wrote:
> I'm fishing for comments on this change. In arm_pc_is_thumb, if we can not
> find a symbol covering the supplied PC, we assume ARM mode; it seems that it
> would be strictly more useful to assume the current mode.
>
> This patch _should not be used_ as is! Paul Brook cleverly noticed that
> this will mess up breakpoint_from_pc when removing breakpoints, causing us
> to insert 2-byte breakpoints and remove 4-byte ones across a mode switch.
> I'm going to have to mess with the target_remove_breakpoint interface
> to fix that, so I wanted to get opinions on this patch first before I dig
> in.
>
> This is still a somewhat creepy thing to do. You can find quotes of me in
> the gdb@ list archives saying that this is "the way to madness". However,
> I've been debugging some code which jumps to Thumb-mode routines in ROM
> today, and my GDB doesn't yet have symbol information for the ROM code; so
> I'm well down the way to madness without this patch, and it's somewhat
> better with.
>
I can sympathise... :-) Also note that for a lot of ARM users,
defaulting to ARM is exactly the wrong choice, since all their code is
Thumb (with the possible exception of some start-up code and other small
trampolines). I think that guessing based on the current CPSR is a
better guess than just ARM, if you can sort out the 'what we guessed
last time we looked at this address problem...'.
> Maybe there should be a "set" option for the default when no symbol is
> found, allowing the user to throttle this back to ARM-only if that works
> better for them?
I certainly think we need a set option, but it's more complex than that,
since I think it needs probably four states:
arm - force to ARM mode even if things look otherwise.
thumb - force to Thumb mode even if things look otherwise.
auto-arm - Try to work it out, but guess ARM if unknown
auto-thumb - Try to work it out, but guess Thumb if unknown
Another approach would be some augmentation to a memory-region type
command, something like
add code-region [arm|thumb|auto-arm|auto-thumb] <base> [+<extent>|<limit>]
R.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2006-02-21 15:36 ` Richard Earnshaw
@ 2006-02-21 16:10 ` Daniel Jacobowitz
2006-03-02 22:23 ` Daniel Jacobowitz
0 siblings, 1 reply; 16+ messages in thread
From: Daniel Jacobowitz @ 2006-02-21 16:10 UTC (permalink / raw)
To: Richard Earnshaw; +Cc: gdb-patches, Shaun Jackman
On Tue, Feb 21, 2006 at 11:05:13AM +0000, Richard Earnshaw wrote:
> I can sympathise... :-) Also note that for a lot of ARM users,
> defaulting to ARM is exactly the wrong choice, since all their code is
> Thumb (with the possible exception of some start-up code and other small
> trampolines). I think that guessing based on the current CPSR is a
> better guess than just ARM, if you can sort out the 'what we guessed
> last time we looked at this address problem...'.
OK, I will fix up the patch.
> > Maybe there should be a "set" option for the default when no symbol is
> > found, allowing the user to throttle this back to ARM-only if that works
> > better for them?
>
> I certainly think we need a set option, but it's more complex than that,
> since I think it needs probably four states:
>
> arm - force to ARM mode even if things look otherwise.
> thumb - force to Thumb mode even if things look otherwise.
> auto-arm - Try to work it out, but guess ARM if unknown
> auto-thumb - Try to work it out, but guess Thumb if unknown
>
> Another approach would be some augmentation to a memory-region type
> command, something like
>
> add code-region [arm|thumb|auto-arm|auto-thumb] <base> [+<extent>|<limit>]
What I had in mind for this was:
set arm fallback-mode [arm|thumb|auto]
That is, continue to honor symbol information, but change the fallback
when we don't have symbols to arm, thumb, or current cpsr.
And maybe augment that with:
set arm force-mode [arm|thumb|auto]
This would also override symbol information.
This is basically the same as your first option, but spread out over
two variables. How does that sound?
I'd rather avoid regions here; they're complicated, and not a very
useful way to describe arm/thumb mixing. Hmm, software single step
probably gets very confused over mode changes; not going to touch that
right now though.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2006-02-20 22:03 RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb Daniel Jacobowitz
2006-02-21 15:36 ` Richard Earnshaw
@ 2006-02-25 11:12 ` Jim Blandy
2006-02-26 13:10 ` Daniel Jacobowitz
1 sibling, 1 reply; 16+ messages in thread
From: Jim Blandy @ 2006-02-25 11:12 UTC (permalink / raw)
To: gdb-patches, Richard Earnshaw, Shaun Jackman
If you know which regions of the ROM are thumb and which are ARM, why
not fake up a .o file that just defines a bunch of symbols --- but
contains no data --- that map things out for GDB?
That is, GDB already has range information. You're just not supplying it.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2006-02-25 11:12 ` Jim Blandy
@ 2006-02-26 13:10 ` Daniel Jacobowitz
0 siblings, 0 replies; 16+ messages in thread
From: Daniel Jacobowitz @ 2006-02-26 13:10 UTC (permalink / raw)
To: Jim Blandy; +Cc: gdb-patches, Richard Earnshaw, Shaun Jackman
On Fri, Feb 24, 2006 at 11:29:23PM -0800, Jim Blandy wrote:
> If you know which regions of the ROM are thumb and which are ARM, why
> not fake up a .o file that just defines a bunch of symbols --- but
> contains no data --- that map things out for GDB?
>
> That is, GDB already has range information. You're just not supplying it.
Because I don't know which regions of the ROM are Thumb and which are
ARM except by executing it. It's provided by an OS vendor; I don't
even have symbols for it.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2006-02-21 16:10 ` Daniel Jacobowitz
@ 2006-03-02 22:23 ` Daniel Jacobowitz
2006-03-02 22:52 ` Mark Kettenis
2008-05-01 18:38 ` Daniel Jacobowitz
0 siblings, 2 replies; 16+ messages in thread
From: Daniel Jacobowitz @ 2006-03-02 22:23 UTC (permalink / raw)
To: Richard Earnshaw, gdb-patches, Shaun Jackman
On Tue, Feb 21, 2006 at 10:36:01AM -0500, Daniel Jacobowitz wrote:
> What I had in mind for this was:
>
> set arm fallback-mode [arm|thumb|auto]
>
> That is, continue to honor symbol information, but change the fallback
> when we don't have symbols to arm, thumb, or current cpsr.
>
> And maybe augment that with:
>
> set arm force-mode [arm|thumb|auto]
>
> This would also override symbol information.
>
> This is basically the same as your first option, but spread out over
> two variables. How does that sound?
Something like the attached; look OK?
For correctness this needs the massive remove_breakpoint patch
I'm posting next.
--
Daniel Jacobowitz
CodeSourcery
2006-03-02 Daniel Jacobowitz <dan@codesourcery.com>
* arm-tdep.c (arm_mode_strings, arm_fallback_mode_string)
(arm_force_mode_string, arm_show_fallback_mode)
(arm_show_force_mode): New.
(arm_pc_is_thumb): Honor fallback-mode and force-mode.
Fall back to the CPSR.
(_initialize_arm_tdep): Add "set arm fallback-mode"
and "set arm force-mode".
2006-03-02 Daniel Jacobowitz <dan@codesourcery.com>
* gdb.texinfo (ARM): Document set/show arm fallback-mode
and set/show arm force-mode.
Index: src/gdb/arm-tdep.c
===================================================================
--- src.orig/gdb/arm-tdep.c 2006-03-02 15:58:19.000000000 -0500
+++ src/gdb/arm-tdep.c 2006-03-02 17:13:17.000000000 -0500
@@ -99,6 +99,17 @@ static const char *arm_abi_strings[] =
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;
@@ -181,16 +192,30 @@ arm_pc_is_thumb (CORE_ADDR memaddr)
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));
- }
- else
- {
- return 0;
- }
+ 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;
}
/* Remove useless bits from addresses in a running program. */
@@ -2458,6 +2483,28 @@ The current ARM ABI is \"auto\" (current
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
@@ -2970,6 +3017,21 @@ vfp - VFP co-processor."),
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."),
Index: src/gdb/doc/gdb.texinfo
===================================================================
--- src.orig/gdb/doc/gdb.texinfo 2006-02-22 15:02:33.000000000 -0500
+++ src/gdb/doc/gdb.texinfo 2006-03-02 17:11:02.000000000 -0500
@@ -14010,6 +14010,24 @@ This command forces @value{GDBN} to use
@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.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2006-03-02 22:23 ` Daniel Jacobowitz
@ 2006-03-02 22:52 ` Mark Kettenis
2006-03-02 23:02 ` Daniel Jacobowitz
2008-05-01 18:38 ` Daniel Jacobowitz
1 sibling, 1 reply; 16+ messages in thread
From: Mark Kettenis @ 2006-03-02 22:52 UTC (permalink / raw)
To: drow; +Cc: rearnsha, gdb-patches, sjackman
> Date: Thu, 2 Mar 2006 17:14:46 -0500
> From: Daniel Jacobowitz <drow@false.org>
>
> On Tue, Feb 21, 2006 at 10:36:01AM -0500, Daniel Jacobowitz wrote:
> > What I had in mind for this was:
> >
> > set arm fallback-mode [arm|thumb|auto]
> >
> > That is, continue to honor symbol information, but change the fallback
> > when we don't have symbols to arm, thumb, or current cpsr.
> >
> > And maybe augment that with:
> >
> > set arm force-mode [arm|thumb|auto]
> >
> > This would also override symbol information.
> >
> > This is basically the same as your first option, but spread out over
> > two variables. How does that sound?
>
> Something like the attached; look OK?
>
> For correctness this needs the massive remove_breakpoint patch
> I'm posting next.
Hmm, this really should unwind CPSR from the frame I think. A bit
impractical to change that now, but something to keep in mind. Could
you add a FIXME that points this out if you agree?
> 2006-03-02 Daniel Jacobowitz <dan@codesourcery.com>
>
> * arm-tdep.c (arm_mode_strings, arm_fallback_mode_string)
> (arm_force_mode_string, arm_show_fallback_mode)
> (arm_show_force_mode): New.
> (arm_pc_is_thumb): Honor fallback-mode and force-mode.
> Fall back to the CPSR.
> (_initialize_arm_tdep): Add "set arm fallback-mode"
> and "set arm force-mode".
>
> 2006-03-02 Daniel Jacobowitz <dan@codesourcery.com>
>
> * gdb.texinfo (ARM): Document set/show arm fallback-mode
> and set/show arm force-mode.
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2006-03-02 22:52 ` Mark Kettenis
@ 2006-03-02 23:02 ` Daniel Jacobowitz
2006-03-02 23:10 ` Mark Kettenis
0 siblings, 1 reply; 16+ messages in thread
From: Daniel Jacobowitz @ 2006-03-02 23:02 UTC (permalink / raw)
To: Mark Kettenis; +Cc: rearnsha, gdb-patches, sjackman
On Thu, Mar 02, 2006 at 11:22:26PM +0100, Mark Kettenis wrote:
> Hmm, this really should unwind CPSR from the frame I think. A bit
> impractical to change that now, but something to keep in mind. Could
> you add a FIXME that points this out if you agree?
But... what frame? Is there a relevant frame? I don't believe that
there is. This is used for things like breakpoints and explicit "x/i".
Maybe you see something I don't, though?
Now, I could get it from get_current_frame() instead of read_register,
if you like.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2006-03-02 23:02 ` Daniel Jacobowitz
@ 2006-03-02 23:10 ` Mark Kettenis
2006-03-02 23:23 ` Daniel Jacobowitz
0 siblings, 1 reply; 16+ messages in thread
From: Mark Kettenis @ 2006-03-02 23:10 UTC (permalink / raw)
To: drow; +Cc: rearnsha, gdb-patches, sjackman
> Date: Thu, 2 Mar 2006 17:25:43 -0500
> From: Daniel Jacobowitz <drow@false.org>
>
> On Thu, Mar 02, 2006 at 11:22:26PM +0100, Mark Kettenis wrote:
> > Hmm, this really should unwind CPSR from the frame I think. A bit
> > impractical to change that now, but something to keep in mind. Could
> > you add a FIXME that points this out if you agree?
>
> But... what frame? Is there a relevant frame? I don't believe that
> there is. This is used for things like breakpoints and explicit "x/i".
> Maybe you see something I don't, though?
It is possible for thumb code and "normal" code to coexist in a single
address space isn't it?
The prologue analyzer seems to use this, so if we're doing a
backtrace, I think it should use the CPSR value for that frame,
instead of whatever the current value for that register is.
> Now, I could get it from get_current_frame() instead of read_register,
> if you like.
Well, that might be a good idea, because it is somewhat closer to what
would be really correct. But adding the FIXME is enough to make me
happy, since fixing things properly is clearly too much to ask for,
and this patch really seems to be an improvement.
Mark
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2006-03-02 23:10 ` Mark Kettenis
@ 2006-03-02 23:23 ` Daniel Jacobowitz
0 siblings, 0 replies; 16+ messages in thread
From: Daniel Jacobowitz @ 2006-03-02 23:23 UTC (permalink / raw)
To: Mark Kettenis; +Cc: rearnsha, gdb-patches, sjackman
On Thu, Mar 02, 2006 at 11:51:54PM +0100, Mark Kettenis wrote:
> > On Thu, Mar 02, 2006 at 11:22:26PM +0100, Mark Kettenis wrote:
> > > Hmm, this really should unwind CPSR from the frame I think. A bit
> > > impractical to change that now, but something to keep in mind. Could
> > > you add a FIXME that points this out if you agree?
> >
> > But... what frame? Is there a relevant frame? I don't believe that
> > there is. This is used for things like breakpoints and explicit "x/i".
> > Maybe you see something I don't, though?
>
> It is possible for thumb code and "normal" code to coexist in a single
> address space isn't it?
Certainly.
> The prologue analyzer seems to use this, so if we're doing a
> backtrace, I think it should use the CPSR value for that frame,
> instead of whatever the current value for that register is.
The CPSR is not saved and restored in the frame. We could pretend that
it was, and manually stitch together the T bit from the return address,
I suppose - the low bit will already be set in the PC for Thumb so this
won't trigger for that case, only for backtracing into an ARM function
via Thumb. But I see your point now. I will take another look at this
later, to see if I can get it righter.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2006-03-02 22:23 ` Daniel Jacobowitz
2006-03-02 22:52 ` Mark Kettenis
@ 2008-05-01 18:38 ` Daniel Jacobowitz
2008-05-02 10:17 ` Eli Zaretskii
1 sibling, 1 reply; 16+ messages in thread
From: Daniel Jacobowitz @ 2008-05-01 18:38 UTC (permalink / raw)
To: gdb-patches; +Cc: Eli Zaretskii
On Thu, Mar 02, 2006 at 05:14:46PM -0500, Daniel Jacobowitz wrote:
> On Tue, Feb 21, 2006 at 10:36:01AM -0500, Daniel Jacobowitz wrote:
> > What I had in mind for this was:
> >
> > set arm fallback-mode [arm|thumb|auto]
> >
> > That is, continue to honor symbol information, but change the fallback
> > when we don't have symbols to arm, thumb, or current cpsr.
> >
> > And maybe augment that with:
> >
> > set arm force-mode [arm|thumb|auto]
> >
> > This would also override symbol information.
> >
> > This is basically the same as your first option, but spread out over
> > two variables. How does that sound?
>
> Something like the attached; look OK?
Here's the final version of this old patch, now that it is frame based
as Mark Kettenis suggested.
Eli, do the documentation and NEWS changes look OK?
--
Daniel Jacobowitz
CodeSourcery
2008-05-01 Daniel Jacobowitz <dan@codesourcery.com>
* arm-tdep.c (arm_mode_strings, arm_fallback_mode_string)
(arm_force_mode_string, arm_show_fallback_mode)
(arm_show_force_mode): New.
(arm_pc_is_thumb): Honor fallback-mode and force-mode. Use
arm_frame_is_thumb.
(_initialize_arm_tdep): Add "set arm fallback-mode"
and "set arm force-mode".
* NEWS: Document new commands.
2008-05-01 Daniel Jacobowitz <dan@codesourcery.com>
* gdb.texinfo (ARM): Document set/show arm fallback-mode
and set/show arm force-mode.
---
gdb/NEWS | 9 +++++
gdb/arm-tdep.c | 85 +++++++++++++++++++++++++++++++++++++++++++++-------
gdb/doc/gdb.texinfo | 18 +++++++++++
3 files changed, 101 insertions(+), 11 deletions(-)
Index: src/gdb/arm-tdep.c
===================================================================
--- src.orig/gdb/arm-tdep.c 2008-05-01 13:56:01.000000000 -0400
+++ src/gdb/arm-tdep.c 2008-05-01 13:56:33.000000000 -0400
@@ -101,6 +101,17 @@ static const char *arm_abi_strings[] =
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;
@@ -240,16 +251,33 @@ arm_pc_is_thumb (CORE_ADDR memaddr)
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));
- }
- else
- {
- return 0;
- }
+ 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. This lets
+ "display/i $pc" always show the correct mode (though if there is
+ a symbol table we will not reach here, so it still may not be
+ displayed in the mode it will be executed). */
+ if (target_has_registers)
+ return arm_frame_is_thumb (get_current_frame ());
+
+ /* Otherwise we're out of luck; we assume ARM. */
+ return 0;
}
/* Remove useless bits from addresses in a running program. */
@@ -2663,6 +2689,28 @@ The current ARM ABI is \"auto\" (current
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
@@ -3286,6 +3334,21 @@ vfp - VFP co-processor."),
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."),
Index: src/gdb/doc/gdb.texinfo
===================================================================
--- src.orig/gdb/doc/gdb.texinfo 2008-05-01 13:55:45.000000000 -0400
+++ src/gdb/doc/gdb.texinfo 2008-05-01 13:56:33.000000000 -0400
@@ -14894,6 +14894,24 @@ This command forces @value{GDBN} to use
@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.
Index: src/gdb/NEWS
===================================================================
--- src.orig/gdb/NEWS 2008-05-01 13:57:29.000000000 -0400
+++ src/gdb/NEWS 2008-05-01 14:01:32.000000000 -0400
@@ -49,6 +49,15 @@ show breakpoint always-inserted
them when resuming the target, and removing them when the target stops.
This option can improve debugger performance on slow remote targets.
+set arm fallback-mode (arm|thumb|auto)
+show arm fallback-mode
+set arm force-mode (arm|thumb|auto)
+show arm force-mode
+ These variables control how ARM GDB determines whether instructions
+ are ARM or Thumb. The default for both settings is auto, which uses
+ the current CPSR value for instructions without symbols; previous
+ versions of GDB behaved as if "set arm fallback-mode arm".
+
*** Changes in GDB 6.8
* New native configurations
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2008-05-01 18:38 ` Daniel Jacobowitz
@ 2008-05-02 10:17 ` Eli Zaretskii
2008-05-02 14:06 ` Daniel Jacobowitz
0 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2008-05-02 10:17 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
> Date: Thu, 1 May 2008 14:38:05 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: Eli Zaretskii <eliz@gnu.org>
>
> Eli, do the documentation and NEWS changes look OK?
Yes, but I have a few comments:
> +@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.
Please explain (in parens or in a @footnote) what is CPSR. There's no
other instance in the manual where this acronym is used.
Also, I think we should list all possible values of this option
explicitly. As written, the text forces the user to gather the values
incrementally (first ARM and Thumb, then auto), and leaves me
wondering whether there are more possible values.
> +set arm fallback-mode (arm|thumb|auto)
> +show arm fallback-mode
> +set arm force-mode (arm|thumb|auto)
> +show arm force-mode
> + These variables control how ARM GDB determines whether instructions
^^^^^^^^^
"commands", not "variables", I think.
> + are ARM or Thumb. The default for both settings is auto, which uses
> + the current CPSR value for instructions without symbols; previous
> + versions of GDB behaved as if "set arm fallback-mode arm".
Btw, I find this description much better than the one in gdb.texinfo:
here you explicitly talk about instructions, whereas in the manual the
description is much more abstract and doesn't even mention
instructions. Can we make the manual closer to NEWS in this sense?
Thanks.
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2008-05-02 10:17 ` Eli Zaretskii
@ 2008-05-02 14:06 ` Daniel Jacobowitz
2008-05-02 15:47 ` Eli Zaretskii
0 siblings, 1 reply; 16+ messages in thread
From: Daniel Jacobowitz @ 2008-05-02 14:06 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
On Fri, May 02, 2008 at 01:17:06PM +0300, Eli Zaretskii wrote:
> > +@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.
>
> Please explain (in parens or in a @footnote) what is CPSR. There's no
> other instance in the manual where this acronym is used.
Is this better? I could expand the acronym (current program status
register), but I think mentioning it as a register is clear enough.
It's visible in GDB as $cpsr.
@item set arm fallback-mode (arm|thumb|auto)
@value{GDBN} uses the symbol table, when available, to determine
whether instructions are ARM or Thumb. This command controls
@value{GDBN}'s default behavior when the symbol table is not
available. The default is @samp{auto}, which causes @value{GDBN} to
use the current execution mode (from the T bit in the CPSR register).
@item set arm fallback-mode (arm|thumb|auto)
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 current execution mode (from the
T bit in the CPSR register).
@item show arm fallback-mode
Show the current fallback instruction mode.
@item set arm force-mode (arm|thumb|auto)
This command overrides use of the symbol table to determine whether
instructions are ARM or Thumb. The default is @samp{auto}, which
causes @value{GDBN} to use the symbol table and then the setting
of @samp{set arm fallback-mode}.
@item show arm force-mode
Show the current forced instruction mode.
> > +set arm fallback-mode (arm|thumb|auto)
> > +show arm fallback-mode
> > +set arm force-mode (arm|thumb|auto)
> > +show arm force-mode
> > + These variables control how ARM GDB determines whether instructions
> ^^^^^^^^^
> "commands", not "variables", I think.
I agree, changed. (There's a "variable" reference to a set command a
few lines above, though).
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2008-05-02 14:06 ` Daniel Jacobowitz
@ 2008-05-02 15:47 ` Eli Zaretskii
2008-05-02 16:03 ` Daniel Jacobowitz
0 siblings, 1 reply; 16+ messages in thread
From: Eli Zaretskii @ 2008-05-02 15:47 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
> Date: Fri, 2 May 2008 10:02:54 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: gdb-patches@sourceware.org
>
> Is this better?
Yes, except that I think "CPSR" should be in @code.
> > > + These variables control how ARM GDB determines whether instructions
> > ^^^^^^^^^
> > "commands", not "variables", I think.
>
> I agree, changed. (There's a "variable" reference to a set command a
> few lines above, though).
Nobody is perfect...
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2008-05-02 15:47 ` Eli Zaretskii
@ 2008-05-02 16:03 ` Daniel Jacobowitz
2008-05-02 20:34 ` Eli Zaretskii
0 siblings, 1 reply; 16+ messages in thread
From: Daniel Jacobowitz @ 2008-05-02 16:03 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches
On Fri, May 02, 2008 at 06:45:57PM +0300, Eli Zaretskii wrote:
> > Date: Fri, 2 May 2008 10:02:54 -0400
> > From: Daniel Jacobowitz <drow@false.org>
> > Cc: gdb-patches@sourceware.org
> >
> > Is this better?
>
> Yes, except that I think "CPSR" should be in @code.
Thanks. I used @code for @code{T} bit, too.
> Nobody is perfect...
Sorry, didn't intend to sound accusatory; that's just where I got
variables from.
Since I was discussing this with some other folks on IRC earlier:
thanks again for your continued assistance and dedication (and fast
response time)! You've done wonders for GDB.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb
2008-05-02 16:03 ` Daniel Jacobowitz
@ 2008-05-02 20:34 ` Eli Zaretskii
0 siblings, 0 replies; 16+ messages in thread
From: Eli Zaretskii @ 2008-05-02 20:34 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
> Date: Fri, 2 May 2008 12:02:26 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: gdb-patches@sourceware.org
>
> > Nobody is perfect...
>
> Sorry, didn't intend to sound accusatory
I didn't think you were, so no worries there.
> Since I was discussing this with some other folks on IRC earlier:
> thanks again for your continued assistance and dedication (and fast
> response time)! You've done wonders for GDB.
Thanks.
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2008-05-02 19:27 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-20 22:03 RFC: Use the ARM CPSR as a fallback to determine ARM/Thumb Daniel Jacobowitz
2006-02-21 15:36 ` Richard Earnshaw
2006-02-21 16:10 ` Daniel Jacobowitz
2006-03-02 22:23 ` Daniel Jacobowitz
2006-03-02 22:52 ` Mark Kettenis
2006-03-02 23:02 ` Daniel Jacobowitz
2006-03-02 23:10 ` Mark Kettenis
2006-03-02 23:23 ` Daniel Jacobowitz
2008-05-01 18:38 ` Daniel Jacobowitz
2008-05-02 10:17 ` Eli Zaretskii
2008-05-02 14:06 ` Daniel Jacobowitz
2008-05-02 15:47 ` Eli Zaretskii
2008-05-02 16:03 ` Daniel Jacobowitz
2008-05-02 20:34 ` Eli Zaretskii
2006-02-25 11:12 ` Jim Blandy
2006-02-26 13:10 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox