[PATCH 1/3] Fix inferior memory reading in GDBServer for arm/aarch32.

Yao Qi qiyaoltc@gmail.com
Thu Dec 1 14:44:00 GMT 2016


On Mon, Nov 28, 2016 at 07:27:56AM -0500, Antoine Tremblay wrote:
> Before this patch, some functions would read the inferior memory with
> (*the_target)->read_memory, which returns the raw memory, rather than the
> shadowed memory.
> 
> This is wrong since these functions do not expect to read a breakpoint
> instruction and can lead to invalid behavior.
> 
> Use of raw memory in get_next_pcs_read_memory_unsigned_integer for example
> could lead to get_next_pc returning an invalid pc.

Can you elaborate under what circumstance breakpoints are still in memory
when these functions are called?  Can we have a test case?
 
> @@ -769,15 +770,15 @@ arm_sigreturn_next_pc (struct regcache *regcache, int svc_number,
>    gdb_assert (svc_number == __NR_sigreturn || svc_number == __NR_rt_sigreturn);
>  
>    collect_register_by_name (regcache, "sp", &sp);
> -  (*the_target->read_memory) (sp, (unsigned char *) &sp_data, 4);
> +  target_read_memory (sp, (unsigned char *) &sp_data, 4);
>  
>    pc_offset = arm_linux_sigreturn_next_pc_offset
>      (sp, sp_data, svc_number, __NR_sigreturn == svc_number ? 1 : 0);
>  
> -  (*the_target->read_memory) (sp + pc_offset, (unsigned char *) &next_pc, 4);
> +  target_read_memory (sp + pc_offset, (unsigned char *) &next_pc, 4);
>  
>    /* Set IS_THUMB according the CPSR saved on the stack.  */
> -  (*the_target->read_memory) (sp + pc_offset + 4, (unsigned char *) &cpsr, 4);
> +  target_read_memory (sp + pc_offset + 4, (unsigned char *) &cpsr, 4);
>    *is_thumb = ((cpsr & CPSR_T) != 0);

We are reading from stack, so we don't need to check weather there is
a breakpoint or not.

-- 
Yao (齐尧)



More information about the Gdb-patches mailing list