[PATCH] tcg/tci: Fix enable-debug got an error

Song Gao posted 1 patch 1 year, 10 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220705065943.2353930-2-gaosong@loongson.cn
Maintainers: Stefan Weil <sw@weilnetz.de>, Richard Henderson <richard.henderson@linaro.org>
tcg/tci/tcg-target.c.inc | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
[PATCH] tcg/tci: Fix enable-debug got an error
Posted by Song Gao 1 year, 10 months ago
When building tcg configure with --enable-tcg-interpreter and --enable-debug,
We may got an error:

In file included from ../tcg/tcg.c:432:
/root/code/github/soft-qemu/qemu/tcg/tci/tcg-target.c.inc: In function 'tcg_target_init':
/root/code/github/soft-qemu/qemu/tcg/tci/tcg-target.c.inc:829:9: error: too few arguments to function 'qemu_set_log'
  829 |         qemu_set_log(strtol(envval, NULL, 0));
      |         ^~~~~~~~~~~~
In file included from /root/code/github/soft-qemu/qemu/include/exec/log.h:4,
                 from ../tcg/tcg.c:61:
/root/code/github/soft-qemu/qemu/include/qemu/log.h:84:6: note: declared here
   84 | bool qemu_set_log(int log_flags, Error **errp);
      |      ^~~~~~~~~~~~

Signed-off-by: Song Gao <gaosong@loongson.cn>
---
 tcg/tci/tcg-target.c.inc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc
index 98337c567a..b7c41fe6c3 100644
--- a/tcg/tci/tcg-target.c.inc
+++ b/tcg/tci/tcg-target.c.inc
@@ -824,9 +824,15 @@ static void tcg_out_nop_fill(tcg_insn_unit *p, int count)
 static void tcg_target_init(TCGContext *s)
 {
 #if defined(CONFIG_DEBUG_TCG_INTERPRETER)
+    Error *err = NULL;
     const char *envval = getenv("DEBUG_TCG");
     if (envval) {
-        qemu_set_log(strtol(envval, NULL, 0));
+        if (qemu_set_log(strtol(envval, NULL, 0), &err)) {
+            error_report("DEBUG_TCG got an errr, envval %s", envval);
+        }
+        if (err) {
+            g_error_free(err);
+        }
     }
 #endif
 
-- 
2.31.1
Re: [PATCH] tcg/tci: Fix enable-debug got an error
Posted by Richard Henderson 1 year, 10 months ago
On 7/5/22 12:29, Song Gao wrote:
> When building tcg configure with --enable-tcg-interpreter and --enable-debug,
> We may got an error:
> 
> In file included from ../tcg/tcg.c:432:
> /root/code/github/soft-qemu/qemu/tcg/tci/tcg-target.c.inc: In function 'tcg_target_init':
> /root/code/github/soft-qemu/qemu/tcg/tci/tcg-target.c.inc:829:9: error: too few arguments to function 'qemu_set_log'
>    829 |         qemu_set_log(strtol(envval, NULL, 0));
>        |         ^~~~~~~~~~~~
> In file included from /root/code/github/soft-qemu/qemu/include/exec/log.h:4,
>                   from ../tcg/tcg.c:61:
> /root/code/github/soft-qemu/qemu/include/qemu/log.h:84:6: note: declared here
>     84 | bool qemu_set_log(int log_flags, Error **errp);
>        |      ^~~~~~~~~~~~
> 
> Signed-off-by: Song Gao <gaosong@loongson.cn>
> ---
>   tcg/tci/tcg-target.c.inc | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/tcg/tci/tcg-target.c.inc b/tcg/tci/tcg-target.c.inc
> index 98337c567a..b7c41fe6c3 100644
> --- a/tcg/tci/tcg-target.c.inc
> +++ b/tcg/tci/tcg-target.c.inc
> @@ -824,9 +824,15 @@ static void tcg_out_nop_fill(tcg_insn_unit *p, int count)
>   static void tcg_target_init(TCGContext *s)
>   {
>   #if defined(CONFIG_DEBUG_TCG_INTERPRETER)
> +    Error *err = NULL;
>       const char *envval = getenv("DEBUG_TCG");
>       if (envval) {
> -        qemu_set_log(strtol(envval, NULL, 0));
> +        if (qemu_set_log(strtol(envval, NULL, 0), &err)) {
> +            error_report("DEBUG_TCG got an errr, envval %s", envval);
> +        }
> +        if (err) {
> +            g_error_free(err);
> +        }

I would rather remove this hack entirely.  I have just cc'd you on such a patch.


r~