* [Qemu-devel] [PATCH] target-tilegx: Support dumping working flow instructions and registers
@ 2016-03-16 15:38 chengang
2016-03-16 15:51 ` Chen Gang
0 siblings, 1 reply; 3+ messages in thread
From: chengang @ 2016-03-16 15:38 UTC (permalink / raw)
To: rth, peter.maydell, cmetcalf, laurent; +Cc: walt, qemu-devel, Chen Gang
From: Chen Gang <gang.chen.5i5j@gmail.com>
It is only for debug and analyzing tilegx qemu related issues.
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
target-tilegx/helper.c | 34 ++++++++++++++++++++++++++++++++++
target-tilegx/helper.h | 2 ++
target-tilegx/translate.c | 37 +++++++++++++++++++++++++++++++++++++
3 files changed, 73 insertions(+)
diff --git a/target-tilegx/helper.c b/target-tilegx/helper.c
index 616c5c7..c7cfe66 100644
--- a/target-tilegx/helper.c
+++ b/target-tilegx/helper.c
@@ -160,3 +160,37 @@ uint64_t helper_cmul2(uint64_t srca, uint64_t srcb, int shift, int round)
return deposit32(realr >> shift, 16, 16, imagr >> shift);
}
+
+extern char **debug_buf;
+
+#define DEBUG_DUMP_REGS
+
+static void dump_regs(CPUTLGState *env, int idx)
+{
+#ifdef DEBUG_DUMP_REGS
+ int i;
+
+ if (debug_buf[idx][2] == '\n') {
+ for (i = 0; i < TILEGX_R_COUNT; i++) {
+ if (!(i % 4)) {
+ fprintf(stderr, "\n");
+ }
+ fprintf(stderr, "r%2.2u = %16.16lx, ", i, env->regs[i]);
+ }
+ fprintf(stderr, "\n");
+ for (i = 0; i < TILEGX_SPR_COUNT; i++) {
+ if (!(i % 8)) {
+ fprintf(stderr, "\n");
+ }
+ fprintf(stderr, "s%2.2u = %16.16lx, ", i, env->spregs[i]);
+ }
+ fprintf(stderr, "\n");
+ }
+#endif
+}
+
+void helper_print_step(CPUTLGState *env, int idx)
+{
+ fprintf(stderr, "%s", debug_buf[idx]);
+ dump_regs(env, idx);
+}
diff --git a/target-tilegx/helper.h b/target-tilegx/helper.h
index 9281d0f..74f796a 100644
--- a/target-tilegx/helper.h
+++ b/target-tilegx/helper.h
@@ -24,3 +24,5 @@ DEF_HELPER_FLAGS_2(v1shrs, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_2(v2shl, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_2(v2shru, TCG_CALL_NO_RWG_SE, i64, i64, i64)
DEF_HELPER_FLAGS_2(v2shrs, TCG_CALL_NO_RWG_SE, i64, i64, i64)
+
+DEF_HELPER_2(print_step, void, env, int)
diff --git a/target-tilegx/translate.c b/target-tilegx/translate.c
index 03918eb..8489494 100644
--- a/target-tilegx/translate.c
+++ b/target-tilegx/translate.c
@@ -47,6 +47,43 @@ static const char * const reg_names[64] = {
"sn", "idn0", "idn1", "udn0", "udn1", "udn2", "udn2", "zero"
};
+#define STATIC_DEBUG
+
+char **debug_buf;
+
+#ifdef STATIC_DEBUG
+
+#include <stdarg.h>
+
+#define qemu_log_mask(flag, fmt, ...) debug_print(flag, fmt, ##__VA_ARGS__)
+
+static int debug_idx;
+
+extern void debug_print(int flag, const char *fmt, ...);
+
+void debug_print(int flag, const char *fmt, ...)
+{
+ va_list args;
+ char buf[0x400];
+ TCGv_i32 tmp;
+
+ va_start(args, fmt);
+ vsprintf(buf, fmt, args);
+ va_end(args);
+
+ if (!debug_buf) {
+ debug_buf = malloc(sizeof(char *) * 0x400000);
+ }
+ debug_buf[debug_idx] = malloc(strlen(buf) + 1);
+ strcpy(debug_buf[debug_idx], buf);
+
+ tmp = tcg_const_i32(debug_idx++);
+ gen_helper_print_step(cpu_env, tmp);
+ tcg_temp_free_i32(tmp);
+}
+
+#endif
+
/* Modified registers are cached in temporaries until the end of the bundle. */
typedef struct {
unsigned reg;
--
1.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [Qemu-devel] [PATCH] target-tilegx: Support dumping working flow instructions and registers
2016-03-16 15:38 [Qemu-devel] [PATCH] target-tilegx: Support dumping working flow instructions and registers chengang
@ 2016-03-16 15:51 ` Chen Gang
2016-03-27 9:56 ` Chen Gang
0 siblings, 1 reply; 3+ messages in thread
From: Chen Gang @ 2016-03-16 15:51 UTC (permalink / raw)
To: chengang, rth, peter.maydell, cmetcalf, laurent; +Cc: walt, qemu-devel
Hello all:
It is only for analyzing issues, I guess it is helpful, so I send it,
welcome any other ideas, suggestions, and completions.
And next, I shall continue to improve the floating point instruction
features: "remove (u)int64_to_float64 from fdouble implementation".
Thanks.
On 3/16/16 23:38, chengang@emindsoft.com.cn wrote:
> From: Chen Gang <gang.chen.5i5j@gmail.com>
>
> It is only for debug and analyzing tilegx qemu related issues.
>
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
> target-tilegx/helper.c | 34 ++++++++++++++++++++++++++++++++++
> target-tilegx/helper.h | 2 ++
> target-tilegx/translate.c | 37 +++++++++++++++++++++++++++++++++++++
> 3 files changed, 73 insertions(+)
>
> diff --git a/target-tilegx/helper.c b/target-tilegx/helper.c
> index 616c5c7..c7cfe66 100644
> --- a/target-tilegx/helper.c
> +++ b/target-tilegx/helper.c
> @@ -160,3 +160,37 @@ uint64_t helper_cmul2(uint64_t srca, uint64_t srcb, int shift, int round)
>
> return deposit32(realr >> shift, 16, 16, imagr >> shift);
> }
> +
> +extern char **debug_buf;
> +
> +#define DEBUG_DUMP_REGS
> +
> +static void dump_regs(CPUTLGState *env, int idx)
> +{
> +#ifdef DEBUG_DUMP_REGS
> + int i;
> +
> + if (debug_buf[idx][2] == '\n') {
> + for (i = 0; i < TILEGX_R_COUNT; i++) {
> + if (!(i % 4)) {
> + fprintf(stderr, "\n");
> + }
> + fprintf(stderr, "r%2.2u = %16.16lx, ", i, env->regs[i]);
> + }
> + fprintf(stderr, "\n");
> + for (i = 0; i < TILEGX_SPR_COUNT; i++) {
> + if (!(i % 8)) {
> + fprintf(stderr, "\n");
> + }
> + fprintf(stderr, "s%2.2u = %16.16lx, ", i, env->spregs[i]);
> + }
> + fprintf(stderr, "\n");
> + }
> +#endif
> +}
> +
> +void helper_print_step(CPUTLGState *env, int idx)
> +{
> + fprintf(stderr, "%s", debug_buf[idx]);
> + dump_regs(env, idx);
> +}
> diff --git a/target-tilegx/helper.h b/target-tilegx/helper.h
> index 9281d0f..74f796a 100644
> --- a/target-tilegx/helper.h
> +++ b/target-tilegx/helper.h
> @@ -24,3 +24,5 @@ DEF_HELPER_FLAGS_2(v1shrs, TCG_CALL_NO_RWG_SE, i64, i64, i64)
> DEF_HELPER_FLAGS_2(v2shl, TCG_CALL_NO_RWG_SE, i64, i64, i64)
> DEF_HELPER_FLAGS_2(v2shru, TCG_CALL_NO_RWG_SE, i64, i64, i64)
> DEF_HELPER_FLAGS_2(v2shrs, TCG_CALL_NO_RWG_SE, i64, i64, i64)
> +
> +DEF_HELPER_2(print_step, void, env, int)
> diff --git a/target-tilegx/translate.c b/target-tilegx/translate.c
> index 03918eb..8489494 100644
> --- a/target-tilegx/translate.c
> +++ b/target-tilegx/translate.c
> @@ -47,6 +47,43 @@ static const char * const reg_names[64] = {
> "sn", "idn0", "idn1", "udn0", "udn1", "udn2", "udn2", "zero"
> };
>
> +#define STATIC_DEBUG
> +
> +char **debug_buf;
> +
> +#ifdef STATIC_DEBUG
> +
> +#include <stdarg.h>
> +
> +#define qemu_log_mask(flag, fmt, ...) debug_print(flag, fmt, ##__VA_ARGS__)
> +
> +static int debug_idx;
> +
> +extern void debug_print(int flag, const char *fmt, ...);
> +
> +void debug_print(int flag, const char *fmt, ...)
> +{
> + va_list args;
> + char buf[0x400];
> + TCGv_i32 tmp;
> +
> + va_start(args, fmt);
> + vsprintf(buf, fmt, args);
> + va_end(args);
> +
> + if (!debug_buf) {
> + debug_buf = malloc(sizeof(char *) * 0x400000);
> + }
> + debug_buf[debug_idx] = malloc(strlen(buf) + 1);
> + strcpy(debug_buf[debug_idx], buf);
> +
> + tmp = tcg_const_i32(debug_idx++);
> + gen_helper_print_step(cpu_env, tmp);
> + tcg_temp_free_i32(tmp);
> +}
> +
> +#endif
> +
> /* Modified registers are cached in temporaries until the end of the bundle. */
> typedef struct {
> unsigned reg;
>
--
Chen Gang (陈刚)
Managing Natural Environments is the Duty of Human Beings.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [Qemu-devel] [PATCH] target-tilegx: Support dumping working flow instructions and registers
2016-03-16 15:51 ` Chen Gang
@ 2016-03-27 9:56 ` Chen Gang
0 siblings, 0 replies; 3+ messages in thread
From: Chen Gang @ 2016-03-27 9:56 UTC (permalink / raw)
To: rth, peter.maydell, cmetcalf, laurent; +Cc: walt, qemu-devel
Hello all:
Is this patch helpful? If it shouldn't be merged into our master branch,
please let me know, I shall treat it as my own local patch (when I
update my local master branch, I'll merge it at last).
Thanks.
On 3/16/16 23:51, Chen Gang wrote:
> Hello all:
>
> It is only for analyzing issues, I guess it is helpful, so I send it,
> welcome any other ideas, suggestions, and completions.
>
> And next, I shall continue to improve the floating point instruction
> features: "remove (u)int64_to_float64 from fdouble implementation".
>
> Thanks.
>
> On 3/16/16 23:38, chengang@emindsoft.com.cn wrote:
>> From: Chen Gang <gang.chen.5i5j@gmail.com>
>>
>> It is only for debug and analyzing tilegx qemu related issues.
>>
>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>> ---
>> target-tilegx/helper.c | 34 ++++++++++++++++++++++++++++++++++
>> target-tilegx/helper.h | 2 ++
>> target-tilegx/translate.c | 37 +++++++++++++++++++++++++++++++++++++
>> 3 files changed, 73 insertions(+)
>>
>> diff --git a/target-tilegx/helper.c b/target-tilegx/helper.c
>> index 616c5c7..c7cfe66 100644
>> --- a/target-tilegx/helper.c
>> +++ b/target-tilegx/helper.c
>> @@ -160,3 +160,37 @@ uint64_t helper_cmul2(uint64_t srca, uint64_t srcb, int shift, int round)
>>
>> return deposit32(realr >> shift, 16, 16, imagr >> shift);
>> }
>> +
>> +extern char **debug_buf;
>> +
>> +#define DEBUG_DUMP_REGS
>> +
>> +static void dump_regs(CPUTLGState *env, int idx)
>> +{
>> +#ifdef DEBUG_DUMP_REGS
>> + int i;
>> +
>> + if (debug_buf[idx][2] == '\n') {
>> + for (i = 0; i < TILEGX_R_COUNT; i++) {
>> + if (!(i % 4)) {
>> + fprintf(stderr, "\n");
>> + }
>> + fprintf(stderr, "r%2.2u = %16.16lx, ", i, env->regs[i]);
>> + }
>> + fprintf(stderr, "\n");
>> + for (i = 0; i < TILEGX_SPR_COUNT; i++) {
>> + if (!(i % 8)) {
>> + fprintf(stderr, "\n");
>> + }
>> + fprintf(stderr, "s%2.2u = %16.16lx, ", i, env->spregs[i]);
>> + }
>> + fprintf(stderr, "\n");
>> + }
>> +#endif
>> +}
>> +
>> +void helper_print_step(CPUTLGState *env, int idx)
>> +{
>> + fprintf(stderr, "%s", debug_buf[idx]);
>> + dump_regs(env, idx);
>> +}
>> diff --git a/target-tilegx/helper.h b/target-tilegx/helper.h
>> index 9281d0f..74f796a 100644
>> --- a/target-tilegx/helper.h
>> +++ b/target-tilegx/helper.h
>> @@ -24,3 +24,5 @@ DEF_HELPER_FLAGS_2(v1shrs, TCG_CALL_NO_RWG_SE, i64, i64, i64)
>> DEF_HELPER_FLAGS_2(v2shl, TCG_CALL_NO_RWG_SE, i64, i64, i64)
>> DEF_HELPER_FLAGS_2(v2shru, TCG_CALL_NO_RWG_SE, i64, i64, i64)
>> DEF_HELPER_FLAGS_2(v2shrs, TCG_CALL_NO_RWG_SE, i64, i64, i64)
>> +
>> +DEF_HELPER_2(print_step, void, env, int)
>> diff --git a/target-tilegx/translate.c b/target-tilegx/translate.c
>> index 03918eb..8489494 100644
>> --- a/target-tilegx/translate.c
>> +++ b/target-tilegx/translate.c
>> @@ -47,6 +47,43 @@ static const char * const reg_names[64] = {
>> "sn", "idn0", "idn1", "udn0", "udn1", "udn2", "udn2", "zero"
>> };
>>
>> +#define STATIC_DEBUG
>> +
>> +char **debug_buf;
>> +
>> +#ifdef STATIC_DEBUG
>> +
>> +#include <stdarg.h>
>> +
>> +#define qemu_log_mask(flag, fmt, ...) debug_print(flag, fmt, ##__VA_ARGS__)
>> +
>> +static int debug_idx;
>> +
>> +extern void debug_print(int flag, const char *fmt, ...);
>> +
>> +void debug_print(int flag, const char *fmt, ...)
>> +{
>> + va_list args;
>> + char buf[0x400];
>> + TCGv_i32 tmp;
>> +
>> + va_start(args, fmt);
>> + vsprintf(buf, fmt, args);
>> + va_end(args);
>> +
>> + if (!debug_buf) {
>> + debug_buf = malloc(sizeof(char *) * 0x400000);
>> + }
>> + debug_buf[debug_idx] = malloc(strlen(buf) + 1);
>> + strcpy(debug_buf[debug_idx], buf);
>> +
>> + tmp = tcg_const_i32(debug_idx++);
>> + gen_helper_print_step(cpu_env, tmp);
>> + tcg_temp_free_i32(tmp);
>> +}
>> +
>> +#endif
>> +
>> /* Modified registers are cached in temporaries until the end of the bundle. */
>> typedef struct {
>> unsigned reg;
>>
>
--
Chen Gang (陈刚)
Managing Natural Environments is the Duty of Human Beings.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-27 9:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-16 15:38 [Qemu-devel] [PATCH] target-tilegx: Support dumping working flow instructions and registers chengang
2016-03-16 15:51 ` Chen Gang
2016-03-27 9:56 ` Chen Gang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).