Re: [PATCH v4 3/6] cxl/events: Update General Media Event Record to CXL spec rev 3.1
From: Steven Rostedt
Date: Wed Nov 27 2024 - 13:33:23 EST
On Wed, 27 Nov 2024 18:20:26 +0000
Shiju Jose <shiju.jose@xxxxxxxxxx> wrote:
> I tested removing hdr_uuid and region_uuid from the rasdaemon test setup
> as you suggested. As a result, libtraceevent parses correctly, as you mentioned.
>
> However, I encounter similar parsing error ("FAILED TO PARSE") when I add two additional
> decoded strings (%s) to the TP_printk, replacing (%u). Please see the attached format file,
> "format_cxl_general_media_v3.1_basic", for your reference.
Are you sure. I don't see anything wrong with that one. Which version of
libtraceevent do you have?
>
> I've also attached another format file, "format_cxl_general_media_v3.1_full",
> which contains the complete TP_printk() intended.
This one has some complex arguments and also uses the '&' address of an
argument.
>
> Can you please help or else can you share how to debug these errors in the
> libtraceevent setup?
Basically, I use the attached program (that just links to libtraceevent).
Note, I need to delete the first line of your files, which has the "cat"
command. But you can run this on the file itself:
./tep_load_event /sys/kernel/tracing/events/cxl/cxl_general_media/format
But you may need to be root to do that. If root just copies that file, you
can then run it as non-root.
# cp /sys/kernel/tracing/events/cxl/cxl_general_media/format /tmp
$ ./tep_load_event /tmp/format
I run it under gdb and see where it fails. But it should let you know if it
will pass or not. I put a breakpoint on tep_warning and when it gets hit, I
examine what it did up to that point.
-- Steve
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <event-parse.h>
static char *argv0;
static char *get_this_name(void)
{
static char *this_name;
char *arg;
char *p;
if (this_name)
return this_name;
arg = argv0;
p = arg+strlen(arg);
while (p >= arg && *p != '/')
p--;
p++;
this_name = p;
return p;
}
static void usage(void)
{
char *p = get_this_name();
printf("usage: %s exec\n"
"\n",p);
exit(-1);
}
static void __vdie(const char *fmt, va_list ap, int err)
{
int ret = errno;
char *p = get_this_name();
if (err && errno)
perror(p);
else
ret = -1;
fprintf(stderr, " ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
exit(ret);
}
void die(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
__vdie(fmt, ap, 0);
va_end(ap);
}
void pdie(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
__vdie(fmt, ap, 1);
va_end(ap);
}
int main (int argc, char **argv)
{
struct tep_handle *tep;
off_t size;
char *buf;
int ret;
argv0 = argv[0];
if (argc < 2)
usage();
tep = tep_alloc();
if (!tep)
pdie("tep_alloc");
tep_set_loglevel(TEP_LOG_ALL);
ret = open(argv[1], O_RDONLY);
if (ret < 0)
pdie(argv[1]);
size = lseek(ret, 0, SEEK_END);
if (size < 0)
pdie("lseek");
lseek(ret, 0, SEEK_SET);
buf = malloc(size);
if (!buf)
pdie("malloc");
size = read(ret, buf, size);
if (size < 0)
pdie("read");
close(ret);
ret = tep_parse_event(tep, buf, size, "sys");
if (ret < 0)
pdie("tep_parse_event");
free(buf);
tep_free(tep);
return 0;
}