This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] guile/: Add enum casts


On 28 October 2015 at 14:54, Pedro Alves <palves@redhat.com> wrote:
> In both cases the casts looks appropriate to me.  In the
> gdbscm_disasm_memory_error case, the status is marshaled through the
> opcodes disassemble interface.  In the
> gdbscm_unwind_stop_reason_string case, the int comes from Guile.
>
> gdb/ChangeLog:
> 2015-10-28  Pedro Alves  <palves@redhat.com>
>
>         * guile/scm-disasm.c (gdbscm_disasm_memory_error): Add cast.
>         * guile/scm-frame.c (gdbscm_unwind_stop_reason_string): Add cast.
> ---
>  gdb/guile/scm-disasm.c | 2 +-
>  gdb/guile/scm-frame.c  | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/guile/scm-disasm.c b/gdb/guile/scm-disasm.c
> index 78b38df..0cc2f84 100644
> --- a/gdb/guile/scm-disasm.c
> +++ b/gdb/guile/scm-disasm.c
> @@ -133,7 +133,7 @@ static void
>  gdbscm_disasm_memory_error (int status, bfd_vma memaddr,
>                             struct disassemble_info *info)
>  {
> -  memory_error (status, memaddr);
> +  memory_error ((enum target_xfer_status) status, memaddr);
>  }
>
>  /* disassemble_info.print_address_func for gdbscm_print_insn_from_port.
> diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c
> index 24e26e8..55e0faf 100644
> --- a/gdb/guile/scm-frame.c
> +++ b/gdb/guile/scm-frame.c
> @@ -1045,7 +1045,7 @@ gdbscm_unwind_stop_reason_string (SCM reason_scm)
>    if (reason < UNWIND_FIRST || reason > UNWIND_LAST)
>      scm_out_of_range (FUNC_NAME, reason_scm);
>
> -  str = unwind_stop_reason_to_string (reason);
> +  str = unwind_stop_reason_to_string ((enum unwind_stop_reason) reason);
>    return gdbscm_scm_from_c_string (str);
>  }
>
> --
> 1.9.3
>

The status comes from gdbscm_disasm_read_memory returning TARGET_XFER_E_IO:

  return status != NULL ? TARGET_XFER_E_IO : 0;

Does it make sense that this function returns TARGET_XFER_E_IO, and
not just -1 (or any other non-zero value) on error?  It's an
all-or-nothing memory read function, unlike those of the xfer_partial
interface.

I would have done a change similar to what you have done in
target_read_memory&co: make gdbscm_disasm_read_memory return -1 on
error, and change
  memory_error (status, memaddr);
to
  memory_error (TARGET_XFER_E_IO, memaddr);

Would it make sense?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]