* [Bug tapsets/19489] New: printing array from memory
@ 2016-01-18 13:50 josch@mister-muffin.de
2016-01-18 14:27 ` [Bug tapsets/19489] " fche at redhat dot com
2016-07-25 15:32 ` csanting at sourceware dot org
0 siblings, 2 replies; 3+ messages in thread
From: josch@mister-muffin.de @ 2016-01-18 13:50 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=19489
Bug ID: 19489
Summary: printing array from memory
Product: systemtap
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: tapsets
Assignee: systemtap at sourceware dot org
Reporter: josch@mister-muffin.de
Target Milestone: ---
Hi,
consider the following C program:
#include <unistd.h>
int main()
{
char buffer[7] = {'f', 'o', 'o', 'b', 'a', 'r', '\n'};
write(1, buffer, 7);
char buffer2[2] = {'\0', '\n'};
write(1, buffer2, 2);
return 0;
}
and the following systemtap script:
probe syscall.write {
if (!target_set_pid(pid())) next;
printf("%s %s\n", name, argstr)
printf("%*M\n", $count, $buf);
}
execute like so:
$ sudo stap -v stdoutbuf.stp -o out -c "./a.out"
I'd expect the file `out` to contain the following content:
write 1, "foobar\n", 7
666f6f6261720a
write 1, "\000\n", 2
000a
Instead I get
write 1, "foobar\n", 7
66
write 1, "", 2
00
Notice the two problems:
1. apparently the argstr cannot handle the zero byte and instead of octal
encoding it, it just truncates the string.
2. printf("%*M") is not printing the full string
System information:
Operating system: Debian unstable
Kernel version: 4.4.0-rc8-amd64
Architecture: amd64
Systemtap version: 2.9/0.163, Debian version 2.9-2
gcc version: 5.2.1 20151028 (Debian 5.2.1-23)
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tapsets/19489] printing array from memory
2016-01-18 13:50 [Bug tapsets/19489] New: printing array from memory josch@mister-muffin.de
@ 2016-01-18 14:27 ` fche at redhat dot com
2016-07-25 15:32 ` csanting at sourceware dot org
1 sibling, 0 replies; 3+ messages in thread
From: fche at redhat dot com @ 2016-01-18 14:27 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=19489
Frank Ch. Eigler <fche at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fche at redhat dot com
--- Comment #1 from Frank Ch. Eigler <fche at redhat dot com> ---
Thanks for your report.
The core of the problem appears to be our use of user_string_n2_quoted in the
syscall.write alias (see .../tapset/linux/syscalls2.stp), specifically the
interpretation of the "n". The function interprets it as a maximum, not an
exact buffer length (see [man function::user_string_n2_quoted]'s mention of C
strings).
We could revise the behaviour of that function to treat its input as a buffer
of definite size, if most or all other uses of that function would benefit.
In the interim, you can use
printf("%.*M", $count, $buf)
(note the ^ dot!)
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tapsets/19489] printing array from memory
2016-01-18 13:50 [Bug tapsets/19489] New: printing array from memory josch@mister-muffin.de
2016-01-18 14:27 ` [Bug tapsets/19489] " fche at redhat dot com
@ 2016-07-25 15:32 ` csanting at sourceware dot org
1 sibling, 0 replies; 3+ messages in thread
From: csanting at sourceware dot org @ 2016-07-25 15:32 UTC (permalink / raw)
To: systemtap
https://sourceware.org/bugzilla/show_bug.cgi?id=19489
Cody Santing <csanting at sourceware dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |csanting at sourceware dot org
Assignee|systemtap at sourceware dot org |csanting at sourceware dot org
--
You are receiving this mail because:
You are the assignee for the bug.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-07-25 15:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-18 13:50 [Bug tapsets/19489] New: printing array from memory josch@mister-muffin.de
2016-01-18 14:27 ` [Bug tapsets/19489] " fche at redhat dot com
2016-07-25 15:32 ` csanting at sourceware dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).