[kgtp] r962 committed - *Merge from branches actionx*...

  • From: kgtp@xxxxxxxxxxxxxx
  • To: kgtp@xxxxxxxxxxxxx
  • Date: Sun, 11 Mar 2012 04:47:51 +0000

Revision: 962
Author:   teawater
Date:     Sat Mar 10 20:47:12 2012
Log:      *Merge from branches actionx*
* Increase the speed of agent code execution.
* Remove the current agent code "printf" support because GDB will support new
  format of agent code "printf".
* Fix bug about access $current_task_pid.

http://code.google.com/p/kgtp/source/detail?r=962

Modified:
 /trunk
 /trunk/UPDATE
 /trunk/gtp.c

=======================================
--- /trunk/UPDATE       Fri Mar  2 05:50:56 2012
+++ /trunk/UPDATE       Sat Mar 10 20:47:12 2012
@@ -4,6 +4,13 @@

 * Increase the speed of access to trace state variables.

+* Increase the speed of agent code execution.
+
+* Remove the current agent code "printf" support because GDB will support new
+  format of agent code "printf".
+
+* Fix bug about access $current_task_pid.
+
 *** 20120224

 * https://lkml.org/lkml/2012/2/26/127
=======================================
--- /trunk/gtp.c        Fri Mar  2 06:12:17 2012
+++ /trunk/gtp.c        Sat Mar 10 20:47:12 2012
@@ -249,12 +249,37 @@

 #define INT2CHAR(h)            ((h) > 9 ? (h) + 'a' - 10 : (h) + '0')

-#define OP_SPECIAL_GETV                0xfa
-#define OP_SPECIAL_SETV                0xfb
-#define OP_SPECIAL_TRACEV      0xfc
-#define OP_TRACE_PRINTK                0xfd
-#define OP_TRACE_QUICK_PRINTK  0xfe
-#define OP_TRACEV_PRINTK       0xff
+enum {
+       op_check_add = 0xe5,
+       op_check_sub,
+       op_check_mul,
+       op_check_div_signed,
+       op_check_div_unsigned,
+       op_check_rem_signed,
+       op_check_rem_unsigned,
+       op_check_lsh,
+       op_check_rsh_signed,
+       op_check_rsh_unsigned,
+       op_check_trace,
+       op_check_bit_and,
+       op_check_bit_or,
+       op_check_bit_xor,
+       op_check_equal,
+       op_check_less_signed,
+       op_check_less_unsigned,
+       op_check_pop,
+       op_check_swap,
+       op_check_if_goto,
+       op_check_printf,        /* XXX: still not used.  */
+
+       op_special_getv = 0xfa,
+       op_special_setv,
+       op_special_tracev,
+
+       op_trace_printk = 0xfd,
+       op_trace_quick_printk,
+       op_tracev_printk,
+};

 struct action_agent_exp {
        unsigned int    size;
@@ -441,7 +466,7 @@
        GTP_VAR_IRQ_COUNT_ID,
        GTP_VAR_PIPE_TRACE_ID,
        GTP_VAR_CURRENT_TASK_PID_ID,
-       GTP_VAR_SPECIAL_MAX = GTP_VAR_PIPE_TRACE_ID,
+       GTP_VAR_SPECIAL_MAX = GTP_VAR_CURRENT_TASK_PID_ID,
 };

 #define PREV_VAR       NULL
@@ -2769,96 +2794,6 @@

        return 0;
 }
-
-#define gtp_action_x_getv                                              \
-       do {                                                            \
-               struct gtp_var  *tve;                                   \
-                                                                       \
-               tve = gtp_gtp_var_array_find(arg);                      \
-               if (!tve)                                               \
-                       goto code_error_out;                            \
-                                                                       \
-               stack[sp++] = top;                                      \
-                                                                       \
-               top = gtp_get_var(gts, tve);                            \
-       } while (0)
-
-#ifdef GTP_PERF_EVENTS
-#define gtp_action_x_setv_pe                                           \
-       do {                                                            \
-               if (tve->ptid == pe_tv_en)                           \
-                       gtp_pe_set_en(tve->pts, (int)top);           \
-               else if (tve->ptid == pe_tv_val)                     \
-                       gtp_perf_event_set(tve->pts->event, (u64)top);    \
-       } while (0)
-#else
-#define gtp_action_x_setv_pe
-#endif
-
-#define gtp_action_x_setv                              \
-       do {                                            \
-               struct gtp_var  *tve;                   \
-                                                       \
-               tve = gtp_gtp_var_array_find(arg);      \
-               if (!tve)                               \
-                       goto code_error_out;            \
-               gtp_action_x_setv_pe;                   \
-               tve->val = (uint64_t)top;            \
-       } while (0)
-
-#define gtp_action_x_tracev                                            \
-       do {                                                            \
-               if (!gts->tpe->have_printk) {                             \
-                       struct gtp_var  *tve;                           \
-                                                                       \
-                       tve = gtp_gtp_var_array_find(arg);              \
-                       if (!tve)                                       \
-                               goto code_error_out;                    \
-                                                                       \
-                       if (gtp_collect_var(gts, tve)) {                \
-                               /* gtp_collect_var will set error       \
-                                  status with itself if it got         \
-                                  error. */                            \
-                               goto out;                               \
-                       }                                               \
-               }                                                       \
-       } while (0)
-
-#define gtp_action_x_tracev_printk                                     \
-       do {                                                            \
-               struct gtp_var  *tve;                                   \
-                                                                       \
-               tve = gtp_gtp_var_array_find(arg);                      \
-               if (!tve)                                               \
-                       goto code_error_out;                            \
-                                                                       \
-               if (gtp_action_printk(gts, gtp_get_var(gts, tve), 0)) { \
-                       /* gtp_collect_var will set error status with   \
-                          itself if it got error. */                   \
-                       goto out;                                       \
-               }                                                       \
-       } while (0)
-
-#define gtp_action_x_printf                                            \
-       do {                                                            \
-               if (strstr((char *)(ebuf + pc), "%s")) {              \
-                       int     i;                                      \
-                       char    buf[50];                                \
-                                                                       \
-                       for (i = 0; i < 50; i++) {                   \
-                               if (probe_kernel_read(buf + i,          \
-                                                     argv + i, 1))     \
-                                       goto code_error_out;            \
-                               if (!buf[i])                            \
-                                       break;                          \
-                       }                                               \
-                       snprintf(pbuf, psize, (char *)(ebuf + pc),      \
-                                buf);                                  \
-               } else {                                                \
-                       snprintf(pbuf, psize, (char *)(ebuf + pc),      \
-                                argv);                                 \
-               }                                                       \
-       } while (0)

 #define STACK_MAX      32
 static DEFINE_PER_CPU(ULONGEST[STACK_MAX], action_x_stack);
@@ -2896,695 +2831,558 @@
        if (unlikely(ae->u.exp.need_var_lock))
                spin_lock(&gtp_var_lock);

-       if (ae->type == 'X') {
-               while (pc < ae->u.exp.size) {
+       while (1) {
 #ifdef GTP_DEBUG
-                       printk(GTP_DEBUG "gtp_parse_x: cmd %x\n", ebuf[pc]);
+               printk(GTP_DEBUG "gtp_parse_x: cmd %x\n", ebuf[pc]);
 #endif

-                       switch (ebuf[pc++]) {
-                       /* add */
-                       case 0x02:
+               switch (ebuf[pc++]) {
+               /* add */
+               case 0x02:
+                       top += stack[--sp];
+                       break;
+
+               case op_check_add:
+                       if (sp)
                                top += stack[--sp];
-                               break;
-                       /* sub */
-                       case 0x03:
+                       else
+                               goto code_error_out;
+                       break;
+
+               /* sub */
+               case 0x03:
+                       top = stack[--sp] - top;
+                       break;
+
+               case op_check_sub:
+                       if (sp)
                                top = stack[--sp] - top;
-                               break;
-                       /* mul */
-                       case 0x04:
+                       else
+                               goto code_error_out;
+                       break;
+
+               /* mul */
+               case 0x04:
+                       top *= stack[--sp];
+                       break;
+
+               case op_check_mul:
+                       if (sp)
                                top *= stack[--sp];
-                               break;
+                       else
+                               goto code_error_out;
+                       break;
+
 #ifndef CONFIG_MIPS
-                       /* div_signed */
-                       case 0x05:
-                               if (top) {
-                                       LONGEST l = (LONGEST) stack[--sp];
-                                       do_div(l, (LONGEST) top);
-                                       top = l;
-                               } else
-                                       goto code_error_out;
-                               break;
-                       /* div_unsigned */
-                       case 0x06:
-                               if (top) {
-                                       ULONGEST ul = stack[--sp];
-                                       do_div(ul, top);
-                                       top = ul;
-                               } else
-                                       goto code_error_out;
-                               break;
-                       /* rem_signed */
-                       case 0x07:
-                               if (top) {
-                                       LONGEST l1 = (LONGEST) stack[--sp];
-                                       LONGEST l2 = (LONGEST) top;
-                                       top = do_div(l1, l2);
-                               } else
-                                       goto code_error_out;
-                               break;
-                       /* rem_unsigned */
-                       case 0x08:
-                               if (top) {
-                                       ULONGEST ul1 = stack[--sp];
-                                       ULONGEST ul2 = top;
-                                       top = do_div(ul1, ul2);
-                               } else
-                                       goto code_error_out;
-                               break;
+               /* div_signed */
+               case 0x05:
+                       if (top) {
+                               LONGEST l = (LONGEST) stack[--sp];
+                               do_div(l, (LONGEST) top);
+                               top = l;
+                       } else
+                               goto code_error_out;
+                       break;
+
+               case op_check_div_signed:
+                       if (top && sp) {
+                               LONGEST l = (LONGEST) stack[--sp];
+                               do_div(l, (LONGEST) top);
+                               top = l;
+                       } else
+                               goto code_error_out;
+                       break;
+
+               /* div_unsigned */
+               case 0x06:
+                       if (top) {
+                               ULONGEST ul = stack[--sp];
+                               do_div(ul, top);
+                               top = ul;
+                       } else
+                               goto code_error_out;
+                       break;
+
+               case op_check_div_unsigned:
+                       if (top && sp) {
+                               ULONGEST ul = stack[--sp];
+                               do_div(ul, top);
+                               top = ul;
+                       } else
+                               goto code_error_out;
+                       break;
+
+               /* rem_signed */
+               case 0x07:
+                       if (top) {
+                               LONGEST l1 = (LONGEST) stack[--sp];
+                               LONGEST l2 = (LONGEST) top;
+                               top = do_div(l1, l2);
+                       } else
+                               goto code_error_out;
+                       break;
+
+               case op_check_rem_signed:
+                       if (top && sp) {
+                               LONGEST l1 = (LONGEST) stack[--sp];
+                               LONGEST l2 = (LONGEST) top;
+                               top = do_div(l1, l2);
+                       } else
+                               goto code_error_out;
+                       break;
+
+               /* rem_unsigned */
+               case 0x08:
+                       if (top) {
+                               ULONGEST ul1 = stack[--sp];
+                               ULONGEST ul2 = top;
+                               top = do_div(ul1, ul2);
+                       } else
+                               goto code_error_out;
+                       break;
+
+               case op_check_rem_unsigned:
+                       if (top && sp) {
+                               ULONGEST ul1 = stack[--sp];
+                               ULONGEST ul2 = top;
+                               top = do_div(ul1, ul2);
+                       } else
+                               goto code_error_out;
+                       break;
 #endif
-                       /* lsh */
-                       case 0x09:
+
+               /* lsh */
+               case 0x09:
+                       top = stack[--sp] << top;
+                       break;
+
+               case op_check_lsh:
+                       if (sp)
                                top = stack[--sp] << top;
-                               break;
-                       /* rsh_signed */
-                       case 0x0a:
+                       else
+                               goto code_error_out;
+                       break;
+
+               /* rsh_signed */
+               case 0x0a:
+                       top = ((LONGEST) stack[--sp]) >> top;
+                       break;
+
+               case op_check_rsh_signed:
+                       if (sp)
                                top = ((LONGEST) stack[--sp]) >> top;
-                               break;
-                       /* rsh_unsigned */
-                       case 0x0b:
+                       else
+                               goto code_error_out;
+                       break;
+
+               /* rsh_unsigned */
+               case 0x0b:
+                       top = stack[--sp] >> top;
+                       break;
+
+               case op_check_rsh_unsigned:
+                       if (sp)
                                top = stack[--sp] >> top;
-                               break;
-                       /* trace */
-                       case 0x0c:
-                               --sp;
-                               if (!gts->tpe->have_printk) {
-                                       if (gtp_action_memory_read
-                                               (gts, -1,
-                                                (CORE_ADDR) stack[sp],
-                                                (size_t) top))
-                                               goto out;
+                       else
+                               goto code_error_out;
+                       break;
+
+               /* trace */
+               case 0x0c:
+                       --sp;
+                       if (!gts->tpe->have_printk) {
+                               if (gtp_action_memory_read
+                                       (gts, -1,
+                                               (CORE_ADDR) stack[sp],
+                                               (size_t) top))
+                                       goto out;
+                       }
+                       top = stack[--sp];
+                       break;
+
+               case op_check_trace:
+                       if (sp > 1) {
+                               if (gtp_action_memory_read
+                                       (gts, -1, (CORE_ADDR) stack[--sp],
+                                       (size_t) top)) {
+                                       /* gtp_action_memory_read will
+                                               set error status with itself
+                                               if it got error. */
+                                       goto out;
                                }
                                top = stack[--sp];
-                               break;
-                       /* trace_printk */
-                       case OP_TRACE_PRINTK:
-                               if (gtp_action_printk(gts,
-                                                     (ULONGEST)stack[--sp],
-                                                     (size_t) top))
+                       } else
+                               goto code_error_out;
+                       break;
+
+               /* trace_printk */
+               case op_trace_printk:
+                       if (gtp_action_printk(gts,
+                                               (ULONGEST)stack[--sp],
+                                               (size_t) top))
+                               goto out;
+                       top = stack[--sp];
+                       break;
+
+               /* trace_quick */
+               case 0x0d:
+                       if (!gts->tpe->have_printk) {
+                               if (gtp_action_memory_read
+                                       (gts, -1, (CORE_ADDR) top,
+                                               (size_t) ebuf[pc]))
                                        goto out;
-                               top = stack[--sp];
-                               break;
-                       /* trace_quick */
-                       case 0x0d:
-                               if (!gts->tpe->have_printk) {
-                                       if (gtp_action_memory_read
-                                               (gts, -1, (CORE_ADDR) top,
-                                                (size_t) ebuf[pc]))
-                                               goto out;
-                               }
-                               pc++;
-                               break;
-                       /* trace_quick_printk */
-                       case OP_TRACE_QUICK_PRINTK:
-                               if (gtp_action_printk(gts, (ULONGEST) top,
-                                                     (size_t) ebuf[pc++]))
-                                       goto out;
-                               break;
-                       /* log_not */
-                       case 0x0e:
-                               top = !top;
-                               break;
-                       /* bit_and */
-                       case 0x0f:
+                       }
+                       pc++;
+                       break;
+
+               /* trace_quick_printk */
+               case op_trace_quick_printk:
+                       if (gtp_action_printk(gts, (ULONGEST) top,
+                                               (size_t) ebuf[pc++]))
+                               goto out;
+                       break;
+
+               /* log_not */
+               case 0x0e:
+                       top = !top;
+                       break;
+
+               /* bit_and */
+               case 0x0f:
+                       top &= stack[--sp];
+                       break;
+
+               case op_check_bit_and:
+                       if (sp)
                                top &= stack[--sp];
-                               break;
-                       /* bit_or */
-                       case 0x10:
+                       else
+                               goto code_error_out;
+                       break;
+
+               /* bit_or */
+               case 0x10:
+                       top |= stack[--sp];
+                       break;
+
+               case op_check_bit_or:
+                       if (sp)
                                top |= stack[--sp];
-                               break;
-                       /* bit_xor */
-                       case 0x11:
+                       else
+                               goto code_error_out;
+                       break;
+
+               /* bit_xor */
+               case 0x11:
+                       top ^= stack[--sp];
+                       break;
+
+               case op_check_bit_xor:
+                       if (sp)
                                top ^= stack[--sp];
-                               break;
-                       /* bit_not */
-                       case 0x12:
-                               top = ~top;
-                               break;
-                       /* equal */
-                       case 0x13:
+                       else
+                               goto code_error_out;
+                       break;
+
+               /* bit_not */
+               case 0x12:
+                       top = ~top;
+                       break;
+
+               /* equal */
+               case 0x13:
+                       top = (stack[--sp] == top);
+                       break;
+
+               case op_check_equal:
+                       if (sp)
                                top = (stack[--sp] == top);
-                               break;
-                       /* less_signed */
-                       case 0x14:
+                       else
+                               goto code_error_out;
+                       break;
+
+               /* less_signed */
+               case 0x14:
+                       top = (((LONGEST) stack[--sp])
+                               < ((LONGEST) top));
+                       break;
+
+               case op_check_less_signed:
+                       if (sp)
                                top = (((LONGEST) stack[--sp])
                                        < ((LONGEST) top));
-                               break;
-                       /* less_unsigned */
-                       case 0x15:
+                       else
+                               goto code_error_out;
+                       break;
+
+               /* less_unsigned */
+               case 0x15:
+                       top = (stack[--sp] < top);
+                       break;
+
+               case op_check_less_unsigned:
+                       if (sp)
                                top = (stack[--sp] < top);
-                               break;
-                       /* ext */
-                       case 0x16:
-                               arg = ebuf[pc++];
-                               if (arg < (sizeof(LONGEST)*8)) {
-                                       LONGEST mask = 1 << (arg - 1);
-                                       top &= ((LONGEST) 1 << arg) - 1;
-                                       top = (top ^ mask) - mask;
-                               }
-                               break;
-                       /* ref8 */
-                       case 0x17:
-                               if (probe_kernel_read
-                                       (cnv.u8.bytes,
-                                       (void *)(CORE_ADDR)top, 1))
-                                       goto code_error_out;
-                               top = (ULONGEST) cnv.u8.val;
-                               break;
-                       /* ref16 */
-                       case 0x18:
-                               if (probe_kernel_read
-                                       (cnv.u16.bytes,
-                                       (void *)(CORE_ADDR)top, 2))
-                                       goto code_error_out;
-                               top = (ULONGEST) cnv.u16.val;
-                               break;
-                       /* ref32 */
-                       case 0x19:
-                               if (probe_kernel_read
-                                       (cnv.u32.bytes,
-                                       (void *)(CORE_ADDR)top, 4))
-                                       goto code_error_out;
-                               top = (ULONGEST) cnv.u32.val;
-                               break;
-                       /* ref64 */
-                       case 0x1a:
-                               if (probe_kernel_read
-                                       (cnv.u64.bytes,
-                                       (void *)(CORE_ADDR)top, 8))
-                                       goto code_error_out;
-                               top = (ULONGEST) cnv.u64.val;
-                               break;
-                       /* if_goto */
-                       case 0x20:
-                               /* The not check sp code don't
-                                  support if_goto.  */
+                       else
                                goto code_error_out;
-                               break;
-                       /* goto */
-                       case 0x21:
-                               pc = (ebuf[pc] << 8) + (ebuf[pc + 1]);
-                               break;
-                       /* const8 */
-                       case 0x22:
-                               stack[sp++] = top;
-                               top = ebuf[pc++];
-                               break;
-                       /* const16 */
-                       case 0x23:
-                               stack[sp++] = top;
-                               top = ebuf[pc++];
-                               top = (top << 8) + ebuf[pc++];
-                               break;
-                       /* const32 */
-                       case 0x24:
-                               stack[sp++] = top;
-                               top = ebuf[pc++];
-                               top = (top << 8) + ebuf[pc++];
-                               top = (top << 8) + ebuf[pc++];
-                               top = (top << 8) + ebuf[pc++];
-                               break;
-                       /* const64 */
-                       case 0x25:
-                               stack[sp++] = top;
-                               top = ebuf[pc++];
-                               top = (top << 8) + ebuf[pc++];
-                               top = (top << 8) + ebuf[pc++];
-                               top = (top << 8) + ebuf[pc++];
-                               top = (top << 8) + ebuf[pc++];
-                               top = (top << 8) + ebuf[pc++];
-                               top = (top << 8) + ebuf[pc++];
-                               top = (top << 8) + ebuf[pc++];
-                               break;
-                       /* reg */
-                       case 0x26:
-                               stack[sp++] = top;
-                               arg = ebuf[pc++];
-                               arg = (arg << 8) + ebuf[pc++];
-                               top = gtp_action_reg_read(gts->regs, gts->tpe,
-                                                         arg);
-                               if (gts->tpe->reason != gtp_stop_normal)
-                                       goto error_out;
-                               break;
-                       /* end */
-                       case 0x27:
-                               if (gts->run)
-                                       *(gts->run) = (int)top;
-                               goto out;
-                               break;
-                       /* dup */
-                       case 0x28:
-                               stack[sp++] = top;
-                               break;
+                       break;
+
+               /* ext */
+               case 0x16:
+                       arg = ebuf[pc++];
+                       if (arg < (sizeof(LONGEST)*8)) {
+                               LONGEST mask = 1 << (arg - 1);
+                               top &= ((LONGEST) 1 << arg) - 1;
+                               top = (top ^ mask) - mask;
+                       }
+                       break;
+
+               /* ref8 */
+               case 0x17:
+                       if (probe_kernel_read
+                               (cnv.u8.bytes,
+                               (void *)(CORE_ADDR)top, 1))
+                               goto code_error_out;
+                       top = (ULONGEST) cnv.u8.val;
+                       break;
+
+               /* ref16 */
+               case 0x18:
+                       if (probe_kernel_read
+                               (cnv.u16.bytes,
+                               (void *)(CORE_ADDR)top, 2))
+                               goto code_error_out;
+                       top = (ULONGEST) cnv.u16.val;
+                       break;
+
+               /* ref32 */
+               case 0x19:
+                       if (probe_kernel_read
+                               (cnv.u32.bytes,
+                               (void *)(CORE_ADDR)top, 4))
+                               goto code_error_out;
+                       top = (ULONGEST) cnv.u32.val;
+                       break;
+
+               /* ref64 */
+               case 0x1a:
+                       if (probe_kernel_read
+                               (cnv.u64.bytes,
+                               (void *)(CORE_ADDR)top, 8))
+                               goto code_error_out;
+                       top = (ULONGEST) cnv.u64.val;
+                       break;
+
+               /* if_goto */
+               case 0x20:
+                       if (top)
+                               pc = (ebuf[pc] << 8)
+                                       + (ebuf[pc + 1]);
+                       else
+                               pc += 2;
                        /* pop */
-                       case 0x29:
+                       top = stack[--sp];
+                       break;
+
+               case op_check_if_goto:
+                       if (top)
+                               pc = (ebuf[pc] << 8)
+                                       + (ebuf[pc + 1]);
+                       else
+                               pc += 2;
+                       /* pop */
+                       if (sp)
                                top = stack[--sp];
-                               break;
-                       /* zero_ext */
-                       case 0x2a:
-                               arg = ebuf[pc++];
-                               if (arg < (sizeof(LONGEST)*8))
-                                       top &= ((LONGEST) 1 << arg) - 1;
-                               break;
-                       /* swap */
-                       case 0x2b:
+                       else
+                               goto code_error_out;
+                       break;
+
+               /* goto */
+               case 0x21:
+                       pc = (ebuf[pc] << 8) + (ebuf[pc + 1]);
+                       break;
+
+               /* const8 */
+               case 0x22:
+                       stack[sp++] = top;
+                       top = ebuf[pc++];
+                       break;
+
+               /* const16 */
+               case 0x23:
+                       stack[sp++] = top;
+                       top = ebuf[pc++];
+                       top = (top << 8) + ebuf[pc++];
+                       break;
+
+               /* const32 */
+               case 0x24:
+                       stack[sp++] = top;
+                       top = ebuf[pc++];
+                       top = (top << 8) + ebuf[pc++];
+                       top = (top << 8) + ebuf[pc++];
+                       top = (top << 8) + ebuf[pc++];
+                       break;
+
+               /* const64 */
+               case 0x25:
+                       stack[sp++] = top;
+                       top = ebuf[pc++];
+                       top = (top << 8) + ebuf[pc++];
+                       top = (top << 8) + ebuf[pc++];
+                       top = (top << 8) + ebuf[pc++];
+                       top = (top << 8) + ebuf[pc++];
+                       top = (top << 8) + ebuf[pc++];
+                       top = (top << 8) + ebuf[pc++];
+                       top = (top << 8) + ebuf[pc++];
+                       break;
+
+               /* reg */
+               case 0x26:
+                       stack[sp++] = top;
+                       arg = ebuf[pc++];
+                       arg = (arg << 8) + ebuf[pc++];
+                       top = gtp_action_reg_read(gts->regs, gts->tpe,
+                                                       arg);
+                       if (gts->tpe->reason != gtp_stop_normal)
+                               goto error_out;
+                       break;
+
+               /* end */
+               case 0x27:
+                       if (gts->run)
+                               *(gts->run) = (int)top;
+                       goto out;
+                       break;
+
+               /* dup */
+               case 0x28:
+                       stack[sp++] = top;
+                       break;
+
+               /* pop */
+               case 0x29:
+                       top = stack[--sp];
+                       break;
+
+               case op_check_pop:
+                       if (sp)
+                               top = stack[--sp];
+                       else
+                               goto code_error_out;
+                       break;
+
+               /* zero_ext */
+               case 0x2a:
+                       arg = ebuf[pc++];
+                       if (arg < (sizeof(LONGEST)*8))
+                               top &= ((LONGEST) 1 << arg) - 1;
+                       break;
+
+               /* swap */
+               case 0x2b:
+                       stack[sp] = top;
+                       top = stack[sp - 1];
+                       stack[sp - 1] = stack[sp];
+                       break;
+
+               case op_check_swap:
+                       if (sp) {
                                stack[sp] = top;
                                top = stack[sp - 1];
                                stack[sp - 1] = stack[sp];
-                               break;
-                       /* getv */
-                       case 0x2c:
+                       } else
+                               goto code_error_out;
+                       break;
+
+               /* getv */
+               case 0x2c:
+                       arg = ebuf[pc++];
+                       arg = (arg << 8) + ebuf[pc++];
+
+                       stack[sp++] = top;
+
+                       top = gtp_get_var(gts, gtp_gtp_var_array_find(arg));
+                       break;
+
+               /* getv_sepecial */
+               case op_special_getv:
+                       arg = ebuf[pc++];
+                       arg = (arg << 8) + ebuf[pc++];
+                       stack[sp++] = top;
+                       top = gtp_get_var_special(gts, arg);
+                       break;
+
+               /* setv */
+               case 0x2d: {
+                               struct gtp_var  *tve;
+
                                arg = ebuf[pc++];
                                arg = (arg << 8) + ebuf[pc++];
-                               gtp_action_x_getv;
-                               break;
-                       /* getv_sepecial */
-                       case OP_SPECIAL_GETV:
-                               arg = ebuf[pc++];
-                               arg = (arg << 8) + ebuf[pc++];
-                               stack[sp++] = top;
-                               top = gtp_get_var_special(gts, arg);
-                               break;
-                       /* setv */
-                       case 0x2d:
-                               arg = ebuf[pc++];
-                               arg = (arg << 8) + ebuf[pc++];
-                               gtp_action_x_setv;
-                               break;
-                       /* setv_sepecial */
-                       case OP_SPECIAL_SETV:
-                               arg = ebuf[pc++];
-                               arg = (arg << 8) + ebuf[pc++];
-                               gtp_set_var_special(gts, arg, top);
-                               break;
-                       /* tracev */
-                       case 0x2e:
-                               arg = ebuf[pc++];
-                               arg = (arg << 8) + ebuf[pc++];
-                               gtp_action_x_tracev;
-                               break;
-                       /* tracev_special */
-                       case OP_SPECIAL_TRACEV:
-                               arg = ebuf[pc++];
-                               arg = (arg << 8) + ebuf[pc++];
-                               gtp_collect_var_special(gts, arg);
-                               break;
-                       /* tracev_printk */
-                       case OP_TRACEV_PRINTK:
-                               arg = ebuf[pc++];
-                               arg = (arg << 8) + ebuf[pc++];
-                               gtp_action_x_tracev_printk;
-                               break;
-                       /* printf */
-                       case 0x31: {
-                                       arg = ebuf[pc++];
-
-                                       if (arg) {
-                                               void    *argv = (void *)
-                                                               (unsigned long)
-                                                               top;
-
-                                               /* pop */
-                                               top = stack[--sp];
-
-                                               gtp_action_x_printf;
-                                       } else
-                                               snprintf(pbuf, psize,
-                                                        (char *)(ebuf + pc));
-                                       psize -= strlen(pbuf);
-                                       pbuf += strlen(pbuf);
-
-                                       pc += strlen((char *)ebuf + pc) + 1;
-                               }
-                               break;
-                       }
-               }
-       } else {
-               /* The x execution code don't support printk so it doesn't have
-                  printk ae support.  */
-               while (pc < ae->u.exp.size) {
-#ifdef GTP_DEBUG
-                       printk(GTP_DEBUG "gtp_parse_x: cmd %x\n", ebuf[pc]);
-#endif
-
-                       switch (ebuf[pc++]) {
-                       /* add */
-                       case 0x02:
-                               if (sp)
-                                       top += stack[--sp];
-                               else
-                                       goto code_error_out;
-                               break;
-                       /* sub */
-                       case 0x03:
-                               if (sp)
-                                       top = stack[--sp] - top;
-                               else
-                                       goto code_error_out;
-                               break;
-                       /* mul */
-                       case 0x04:
-                               if (sp)
-                                       top *= stack[--sp];
-                               else
-                                       goto code_error_out;
-                               break;
-#ifndef CONFIG_MIPS
-                       /* div_signed */
-                       case 0x05:
-                               if (top && sp) {
-                                       LONGEST l = (LONGEST) stack[--sp];
-                                       do_div(l, (LONGEST) top);
-                                       top = l;
-                               } else
-                                       goto code_error_out;
-                               break;
-                       /* div_unsigned */
-                       case 0x06:
-                               if (top && sp) {
-                                       ULONGEST ul = stack[--sp];
-                                       do_div(ul, top);
-                                       top = ul;
-                               } else
-                                       goto code_error_out;
-                               break;
-                       /* rem_signed */
-                       case 0x07:
-                               if (top && sp) {
-                                       LONGEST l1 = (LONGEST) stack[--sp];
-                                       LONGEST l2 = (LONGEST) top;
-                                       top = do_div(l1, l2);
-                               } else
-                                       goto code_error_out;
-                               break;
-                       /* rem_unsigned */
-                       case 0x08:
-                               if (top && sp) {
-                                       ULONGEST ul1 = stack[--sp];
-                                       ULONGEST ul2 = top;
-                                       top = do_div(ul1, ul2);
***The diff for this file has been truncated for email.***

Other related posts:

  • » [kgtp] r962 committed - *Merge from branches actionx*... - kgtp