[PATCH] scripts: avoid matching 'char **' as string for systemtap

Daniel P. Berrangé via Devel posted 1 patch 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20260216100237.3635997-1-berrange@redhat.com
scripts/dtrace2systemtap.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] scripts: avoid matching 'char **' as string for systemtap
Posted by Daniel P. Berrangé via Devel 2 weeks ago
From: Daniel P. Berrangé <berrange@redhat.com>

When a probe argument is declared "char *" we reference the userspace
string value using 'user_string(...)' for systemtap.

Unfortunately our code generator also matches on args declared "char **"
and generates bogus code

   *cert = user_string($arg4);

which is a syntax error for systemtap.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
 scripts/dtrace2systemtap.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/dtrace2systemtap.py b/scripts/dtrace2systemtap.py
index 506db9c503..361dab1075 100755
--- a/scripts/dtrace2systemtap.py
+++ b/scripts/dtrace2systemtap.py
@@ -124,7 +124,7 @@ for file in filelist:
         for idx in range(len(argbits)):
             arg = argbits[idx]
             isstr = False
-            if 'char *' in arg:
+            if re.match(r'''.*char\s\*[^\*].*''', arg) is not None:
                 isstr = True
 
             m = re.search(r'''^.*\s\*?(\S+)$''', arg)
-- 
2.53.0

Re: [PATCH] scripts: avoid matching 'char **' as string for systemtap
Posted by Michal Prívozník via Devel 2 weeks ago
On 2/16/26 11:02, Daniel P. Berrangé via Devel wrote:
> From: Daniel P. Berrangé <berrange@redhat.com>
> 
> When a probe argument is declared "char *" we reference the userspace
> string value using 'user_string(...)' for systemtap.
> 
> Unfortunately our code generator also matches on args declared "char **"
> and generates bogus code
> 
>    *cert = user_string($arg4);
> 
> which is a syntax error for systemtap.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
> ---
>  scripts/dtrace2systemtap.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Michal