[mainline/7.12.1] Remove assert on exec_bfd in cris_delayed_get_disassembler

Message ID 1481292495-11609-1-git-send-email-yao.qi@linaro.org
State New, archived
Headers

Commit Message

Yao Qi Dec. 9, 2016, 2:08 p.m. UTC
  cris_delayed_get_disassembler has an assert that exec_bfd can't be
NULL, but this assert can be triggered like this,

(gdb) set architecture cris
The target architecture is assumed to be cris
(gdb) disassemble 0x0,+4
Dump of assembler code from 0x0 to 0x4:
   0x00000000:
../../binutils-gdb/gdb/cris-tdep.c:3798: internal-error: int cris_delayed_get_disassembler(bfd_vma, disassemble_info*): Assertion `exec_bfd != NULL' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.

however, cris_get_disassembler does have code to handle the case that
bfd is NULL,

  /* If there's no bfd in sight, we return what is valid as input in all
     contexts if fed back to the assembler: disassembly *with* register
     prefix.  Unfortunately this will be totally wrong for v32.  */
  if (abfd == NULL)
    return print_insn_cris_with_register_prefix;

This patch is to remove this assert.

gdb:

2016-12-09  Yao Qi  <yao.qi@linaro.org>

	PR tdep/20955
	* cris-tdep.c (cris_delayed_get_disassembler): Remove the
	assert.
---
 gdb/cris-tdep.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
  

Comments

Luis Machado Dec. 9, 2016, 3:13 p.m. UTC | #1
On 12/09/2016 08:08 AM, Yao Qi wrote:
> cris_delayed_get_disassembler has an assert that exec_bfd can't be
> NULL, but this assert can be triggered like this,
>
> (gdb) set architecture cris
> The target architecture is assumed to be cris
> (gdb) disassemble 0x0,+4
> Dump of assembler code from 0x0 to 0x4:
>    0x00000000:
> ../../binutils-gdb/gdb/cris-tdep.c:3798: internal-error: int cris_delayed_get_disassembler(bfd_vma, disassemble_info*): Assertion `exec_bfd != NULL' failed.
> A problem internal to GDB has been detected,
> further debugging may prove unreliable.
>
> however, cris_get_disassembler does have code to handle the case that
> bfd is NULL,
>
>   /* If there's no bfd in sight, we return what is valid as input in all
>      contexts if fed back to the assembler: disassembly *with* register
>      prefix.  Unfortunately this will be totally wrong for v32.  */
>   if (abfd == NULL)
>     return print_insn_cris_with_register_prefix;
>
> This patch is to remove this assert.
>
> gdb:
>
> 2016-12-09  Yao Qi  <yao.qi@linaro.org>
>
> 	PR tdep/20955
> 	* cris-tdep.c (cris_delayed_get_disassembler): Remove the
> 	assert.
> ---
>  gdb/cris-tdep.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
> index 084ff49..f2d9eed 100644
> --- a/gdb/cris-tdep.c
> +++ b/gdb/cris-tdep.c
> @@ -3792,10 +3792,7 @@ static int
>  cris_delayed_get_disassembler (bfd_vma addr, struct disassemble_info *info)
>  {
>    int (*print_insn) (bfd_vma addr, struct disassemble_info *info);
> -  /* FIXME: cagney/2003-08-27: It should be possible to select a CRIS
> -     disassembler, even when there is no BFD.  Does something like
> -     "gdb; target remote; disassmeble *0x123" work?  */
> -  gdb_assert (exec_bfd != NULL);
> +
>    print_insn = cris_get_disassembler (exec_bfd);
>    gdb_assert (print_insn != NULL);
>    return print_insn (addr, info);
>

The rl78/rx/cris fixes look good to me.
  
Yao Qi Dec. 12, 2016, 9:14 a.m. UTC | #2
On Fri, Dec 9, 2016 at 3:13 PM, Luis Machado <lgustavo@codesourcery.com> wrote:
>
> The rl78/rx/cris fixes look good to me.

I pushed this patch in to mainline and 7.12 branch.
  

Patch

diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 084ff49..f2d9eed 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -3792,10 +3792,7 @@  static int
 cris_delayed_get_disassembler (bfd_vma addr, struct disassemble_info *info)
 {
   int (*print_insn) (bfd_vma addr, struct disassemble_info *info);
-  /* FIXME: cagney/2003-08-27: It should be possible to select a CRIS
-     disassembler, even when there is no BFD.  Does something like
-     "gdb; target remote; disassmeble *0x123" work?  */
-  gdb_assert (exec_bfd != NULL);
+
   print_insn = cris_get_disassembler (exec_bfd);
   gdb_assert (print_insn != NULL);
   return print_insn (addr, info);