Patchwork PATCH4 - evaluate breakpoint condition on target - final patch - call of translation gdb bytecode to TCG code, add translated breakpoint condition code to the translation block

login
register
mail settings
Submitter Anna Neiman
Date Feb. 26, 2013, 1:52 p.m.
Message ID <1361886771-11074-1-git-send-email-anna_neiman@mentor.com>
Download mbox | patch
Permalink /patch/223225/
State New
Headers show

Comments

Anna Neiman - Feb. 26, 2013, 1:52 p.m.
Signed-off-by: Anna Neiman <anna_neiman@mentor.com>
---
 target-arm/translate.c |   43 ++++++++++++++++++++++++++++++++++++++-----
 translate-all.c        |    3 +++
 2 files changed, 41 insertions(+), 5 deletions(-)

Patch

diff --git a/target-arm/translate.c b/target-arm/translate.c
index f2f649d..140caa8 100644
--- a/target-arm/translate.c
+++ b/target-arm/translate.c
@@ -32,6 +32,7 @@ 
 #include "helper.h"
 #define GEN_HELPER 1
 #include "helper.h"
+#include "translate-gdbagent.h"
 
 #define ENABLE_ARCH_4T    arm_feature(env, ARM_FEATURE_V4T)
 #define ENABLE_ARCH_5     arm_feature(env, ARM_FEATURE_V5)
@@ -153,6 +154,24 @@  static inline void store_cpu_offset(TCGv var, int offset)
     tcg_temp_free_i32(var);
 }
 
+static void cpu_get_reg_var_arm(TCGv var, int reg);
+static void cpu_set_var_to_env_ptr_arm(TCGv_ptr var_ptr, int offset);
+
+static void cpu_get_reg_var_arm(TCGv var, int reg)
+{
+    tcg_gen_mov_i32(var, cpu_R[reg]);
+}
+
+static void cpu_set_var_to_env_ptr_arm(TCGv_ptr var_ptr, int offset)
+{  
+    tcg_gen_addi_ptr(var_ptr, cpu_env,offset);  
+}
+static void set_funcs_for_bp_agent(void)
+{
+    cpu_get_reg_var_func = cpu_get_reg_var_arm;
+    cpu_set_var_to_env_ptr_func =  cpu_set_var_to_env_ptr_arm;
+}
+
 #define store_cpu_field(var, name) \
     store_cpu_offset(var, offsetof(CPUARMState, name))
 
@@ -9851,6 +9870,7 @@  static inline void gen_intermediate_code_internal(CPUARMState *env,
         tcg_gen_movi_i32(tmp, 0);
         store_cpu_field(tmp, condexec_bits);
       }
+    set_funcs_for_bp_agent();
     do {
 #ifdef CONFIG_USER_ONLY
         /* Intercept jump to the magic kernel page.  */
@@ -9874,11 +9894,24 @@  static inline void gen_intermediate_code_internal(CPUARMState *env,
         if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) {
             QTAILQ_FOREACH(bp, &env->breakpoints, entry) {
                 if (bp->pc == dc->pc) {
-                    gen_exception_insn(dc, 0, EXCP_DEBUG);
-                    /* Advance PC so that clearing the breakpoint will
-                       invalidate this TB.  */
-                    dc->pc += 2;
-                    goto done_generating;
+                    if (bp_has_cond(bp)) {
+                        int bp_condlabel = gen_new_label();
+                        int res = tcg_gen_bp_cond
+                          (env, &tcg_ctx, bp, bp_condlabel);
+                        /* tcg_gen_bp_cond can return 0
+                           in case internal error,
+                           in particular gen_opc_buf overload */
+                        gen_exception(EXCP_DEBUG);
+                        if (res) {
+                            gen_set_label(bp_condlabel);
+                        }
+                    } else {
+                        gen_exception_insn(dc, 0, EXCP_DEBUG);
+                        /* Advance PC so that clearing the breakpoint will
+                           invalidate this TB.  */
+                        dc->pc += 2;
+                        goto done_generating;
+                    }
                     break;
                 }
             }
diff --git a/translate-all.c b/translate-all.c
index b50fb89..9a0a5ef 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -59,6 +59,7 @@ 
 
 #include "exec/cputlb.h"
 #include "translate-all.h"
+#include "translate-gdbagent.h"
 
 //#define DEBUG_TB_INVALIDATE
 //#define DEBUG_FLUSH
@@ -150,6 +151,8 @@  int cpu_gen_code(CPUArchState *env, TranslationBlock *tb, int *gen_code_size_ptr
                        exceptions */
     ti = profile_getclock();
 #endif
+    bp_agent_init();
+
     tcg_func_start(s);
 
     gen_intermediate_code(env, tb);