This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: How to access userspace c++ strings in systemtap script
- From: William Cohen <wcohen at redhat dot com>
- To: systemtap at sourceware dot org
- Date: Wed, 3 Oct 2018 10:41:11 -0400
- Subject: Re: How to access userspace c++ strings in systemtap script
- References: <6a195aa5-3f86-b23c-a216-4c06c95458bd@redhat.com>
On 10/3/18 10:12 AM, William Cohen wrote:
> Hi,
>
> I would like to get a clearer picture about which sysetmtap scripts
> take a long time to process. The goal is to provide a little stacked
> bar of the phases for each scripts that is run. I would like to use
> the the systemtap stap.pass* probe points to give that information.
> Each of these stap.pass** probe points provide the session argument which should
> provides a pointer to the internal information including the script_file.
>
> The question is how to access c++ string script_file in struct systemtap_session.
> The following snippet of code doesn't work:
>
> script_file = @cast(session, "struct systemtap_session")->script_file
> script = user_string2(script_file, "<unavailable>")
>
> Ends up with giving the following error:
>
> semantic error: while processing probe process("/usr/bin/stap").statement(0x7814e) from: process("/usr/bin/stap").mark("pass4__end") from: stap.pass4.end from: stap.pass4.end
>
> semantic error: 'class basic_string<char, std::char_traits<char>, std::allocator<char> >' (/usr/include/c++/8/bits/basic_string.h:77) is being accessed instead of a member such as '->_M_allocated_capacity': operator '->' at ./stap_time.stp:24:59
> source: script_file = @cast(session, "struct systemtap_session")->script_file
> ^
>
> Pass 2: analysis failed. [man error::pass2]
>
>
> Attached is the WIP script.
>
> -Will
>
After some digging around I found that the following provided access to the string text:
script_file = @cast(session, "struct systemtap_session")->script_file->_M_local_buf
-Will