Re: [PATCH] [RFCv3] perf: robustify proc and debugfs file recording

From: Peter Zijlstra
Date: Thu Jul 14 2011 - 08:56:17 EST


On Thu, 2011-07-14 at 08:45 -0400, Steven Rostedt wrote:
> ---
> tools/perf/util/trace-event-info.c | 120 ++++++++------------------------=
> -----
> 1 file changed, 29 insertions(+), 91 deletions(-)
>
> Index: linux-ozlabs/tools/perf/util/trace-event-info.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- linux-ozlabs.orig/tools/perf/util/trace-event-info.c 2011-07-13 20:42:2=
> 4.442945973 +1000
> +++ linux-ozlabs/tools/perf/util/trace-event-info.c 2011-07-14 10:14:19.072=
> 946058 +1000
> @@ -183,106 +183,59 @@
> return *ptr =3D=3D 0x01020304;
> }
> =20
> -static unsigned long long copy_file_fd(int fd)
> +/* unfortunately, you can not stat debugfs or proc files for size */
> +static void record_file(const char *file, size_t hdr_sz)
> {
> unsigned long long size =3D 0;

Yeah, its all the rage, we're supposed to write full RFC compliant email
parsers these days :(

/Content-Transfer-Encoding:.*quoted-printable.*/ {
decode = 1;
}

// {
tmp = $0

if (!decode) {
print tmp
next
}

if (concat) {
tmp = last tmp
concat = 0;
}

if (tmp ~ /=$/) {
concat = 1;
gsub("=$", "", tmp);
}

offset = 0;
while (match(tmp, /=[[:xdigit:]][[:xdigit:]]/, a)) {
if (a[0] < offset)
break;
hex = substr(a[0], 2)
char = sprintf("%c", strtonum("0x"hex))
gsub(a[0], char, tmp)
offset = a[0];
}

if (concat) {
last = tmp
next
}

print tmp
}


Should decode that crap I think..
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/