Bug 215521 - error: 'struct tep_print_arg_string' has no member named 'offset'
Summary: error: 'struct tep_print_arg_string' has no member named 'offset'
Status: RESOLVED CODE_FIX
Alias: None
Product: Tools
Classification: Unclassified
Component: Trace-cmd/Kernelshark (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Default virtual assignee for Trace-cmd and kernelshark
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-22 19:38 UTC by Vitaly Chikunov
Modified: 2022-06-07 16:40 UTC (History)
1 user (show)

See Also:
Kernel Version: 5.15
Subsystem:
Regression: No
Bisected commit-id:


Attachments
libtraceevent: Fix backward compatibility with tep_print_arg_string (4.18 KB, patch)
2022-01-24 15:20 UTC, Steven Rostedt
Details | Diff
libtraceevent: Fix backward compatibility with tep_print_arg_string (2.90 KB, patch)
2022-01-24 15:25 UTC, Steven Rostedt
Details | Diff

Description Vitaly Chikunov 2022-01-22 19:38:50 UTC
For ALT Linux I try to build trace-cmd with libtraceevent as external package. And there is build error:

```
builder@i586:~/RPM/BUILD/trace-cmd-2.9.6/python$ gcc -fpic -c  -pipe -frecord-gcc-switches -Wall -fdiagnostics-color=always -fdiagnostics-color=always -fdiagnostics-color=always -g -O2  -march=i586 -mtune=generic -Wno-unused-result -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -DVSOCK -D_GNU_SOURCE -I/usr/src/RPM/BUILD/trace-cmd-2.9.6/include -I/usr/src/RPM/BUILD/trace-cmd-2.9.6/../../include -I/usr/src/RPM/BUILD/trace-cmd-2.9.6/include/trace-cmd -I/usr/src/RPM/BUILD/trace-cmd-2.9.6/lib/trace-cmd/include -I/usr/src/RPM/BUILD/trace-cmd-2.9.6/lib/trace-cmd/include/private -I/usr/src/RPM/BUILD/trace-cmd-2.9.6/tracecmd/include -I/usr/include/traceevent -Dwarning=tep_warning -Dpr_info=tep_info -I/usr/include/tracefs -I/usr/include/traceevent -DVAR_DIR="/var" '-DPLUGIN_TRACEEVENT_DIR="/usr/lib/traceevent/plugins"' '-DPLUGIN_TRACECMD_DIR=""'   -DHAVE_BLK_TC_FLUSH `pkg-config --cflags python3`  ctracecmd_wrap.c
ctracecmd_wrap.c: In function 'tep_info':
ctracecmd_wrap.c:2779:9: warning: implicit declaration of function '__vpr_info'; did you mean 'pr_info'? [-Wimplicit-function-declaration]
 2779 |         __vpr_info(fmt, ap);
      |         ^~~~~~~~~~
      |         pr_info
ctracecmd_wrap.c: In function 'tep_warning':
ctracecmd_wrap.c:2791:9: warning: implicit declaration of function '__vwarning'; did you mean 'tep_vwarning'? [-Wimplicit-function-declaration]
 2791 |         __vwarning(fmt, ap);
      |         ^~~~~~~~~~
      |         tep_vwarning
ctracecmd_wrap.c: In function 'python_callback':
ctracecmd_wrap.c:3910:9: warning: 'PyEval_CallObjectWithKeywords' is deprecated [-Wdeprecated-declarations]
 3910 |         result = PyEval_CallObject(context, arglist);
      |         ^~~~~~
In file included from /usr/include/python3.9/Python.h:141,
                 from ctracecmd_wrap.c:154:
/usr/include/python3.9/ceval.h:17:43: note: declared here
   17 | Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
      |                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ctracecmd_wrap.c: In function '_wrap_tep_print_arg_string_offset_set':
ctracecmd_wrap.c:7208:19: error: 'struct tep_print_arg_string' has no member named 'offset'
 7208 |   if (arg1) (arg1)->offset = arg2;
      |                   ^~
ctracecmd_wrap.c: In function '_wrap_tep_print_arg_string_offset_get':
ctracecmd_wrap.c:7231:25: error: 'struct tep_print_arg_string' has no member named 'offset'
 7231 |   result = (int) ((arg1)->offset);
      |                         ^~
ctracecmd_wrap.c: In function '_wrap_tep_print_arg_bitmask_offset_set':
ctracecmd_wrap.c:7356:19: error: 'struct tep_print_arg_bitmask' has no member named 'offset'
 7356 |   if (arg1) (arg1)->offset = arg2;
      |                   ^~
ctracecmd_wrap.c: In function '_wrap_tep_print_arg_bitmask_offset_get':
ctracecmd_wrap.c:7379:25: error: 'struct tep_print_arg_bitmask' has no member named 'offset'
 7379 |   result = (int) ((arg1)->offset);
      |                         ^~
```

It seems that `struct tep_print_arg_string` in libtraceevent 1.5.0 is defined as

struct tep_print_arg_string {
        char                    *string;
        struct tep_format_field *field;
};

But trace-cmd 2.9.6 expects:

struct tep_print_arg_string {
        char                    *string;
        int                     offset;
};
Comment 1 Vitaly Chikunov 2022-01-22 19:40:58 UTC
I tried to build trace-cmd, libtraceevent, and libtracefs using latest versions available in git repos, is that wrong? Did I miss something?
Comment 2 Steven Rostedt 2022-01-24 15:10:20 UTC
Thanks for reporting this. You are right. I usually test to make sure the stable versions of trace-cmd still build, I must have missed this. I'll have to figure out how to fix this.

-- Steve
Comment 3 Steven Rostedt 2022-01-24 15:20:58 UTC
Created attachment 300309 [details]
libtraceevent: Fix backward compatibility with tep_print_arg_string

It appears that trace-cmd 2.9.6 referenced the tep_print_arg_string to get to the offset, which was removed by libtraceevent commit 512d7be1 ("libtraceevent: Add __rel_loc relative location attribute support"). Add the offset back to both tep_print_arg_string and to tep_print_arg_bitmask (yeah, it adds a hole in the structure), for backward compatibility.
Comment 4 Steven Rostedt 2022-01-24 15:25:17 UTC
Created attachment 300310 [details]
libtraceevent: Fix backward compatibility with tep_print_arg_string

It appears that trace-cmd 2.9.6 referenced the tep_print_arg_string to
get to the offset, which was removed by libtraceevent commit 512d7be1
("libtraceevent: Add __rel_loc relative location attribute support").
Add the offset back to both tep_print_arg_string and to
tep_print_arg_bitmask (yeah, it adds a hole in the structure), for
backward compatibility.

--
v2 - I accidentally added unrelated changes to the previous patch.
Comment 5 Steven Rostedt 2022-01-24 15:26:21 UTC
(In reply to Vitaly Chikunov from comment #1)
> I tried to build trace-cmd, libtraceevent, and libtracefs using latest
> versions available in git repos, is that wrong? Did I miss something?

I uploaded a patch to be applied to libtraceevent 1.5.0. Can you add that and see if it fixes the issue for you?

Thanks,

-- Steve
Comment 6 Vitaly Chikunov 2022-01-24 17:20:37 UTC
After applying this patch to libtraceevent, trace-cmd compiles successfully.
Thanks!

Note You need to log in before you can comment on or make changes to this bug.