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 4/8] Implement target_emit_ops




On 09/18/2015 08:43 AM, Yao Qi wrote:
From: Pierre Langlois <pierre.langlois@arm.com>

This patch implements compiling agent expressions to native code for
AArch64.  This allows us to compile conditions set on fast tracepoints.

The compiled function has the following prologue:

High *------------------------------------------------------*
      | LR                                                   |
      | FP                                                   | <- FP
      | x1  (ULONGEST *value)                                |
      | x0  (unsigned char *regs)                            |
Low  *------------------------------------------------------*

We save the function's argument on the stack as well as the return
address and the frame pointer.  We then set the current frame pointer to
point to the previous one.

The generated code for the expression will freely update the stack
pointer so we use the frame pointer to refer to `*value' and `*regs'.
`*value' needs to be accessed in the epilogue of the function, in order
to set it to whatever is on top of the stack.  `*regs' needs to be passed
down to the `gdb_agent_get_reg' function with the `reg' operation.

+static void
+aarch64_emit_prologue (void)
+{
+  uint32_t buf[16];
+  uint32_t *p = buf;
+
+  /* This function emit a prologue for the following function prototype:
+
+     e
....

Hi,
I'm working on adding JIT compiling of agent expressions for ARM and I've been looking at the aarch64 implementation.

I'm wondering is there a reason we don't use gcc to generate the native bytecode like done on x86 ?

x86 has a macro like so :

#define EMIT_ASM(NAME, INSNS)						
  do									
    {									
      extern unsigned char start_ ## NAME, end_ ## NAME;		
      add_insns (&start_ ## NAME, &end_ ## NAME - &start_ ## NAME);	
      __asm__ ("jmp end_" #NAME "\n"					
	       "\t" "start_" #NAME ":"					
	       "\t" INSNS "\n"						
	       "\t" "end_" #NAME ":");					
    } while (0)

Could the same be done for armv7 or there's a reason that prevents it ?

Same question for aarch64 ?

Thanks,
Antoine



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