public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* problem in tuning mysql code use systemtap
@ 2012-03-24  7:02 ch huang
  2012-03-24  9:23 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: ch huang @ 2012-03-24  7:02 UTC (permalink / raw)
  To: systemtap

i try to tuning mysql code use systemtap, and mysql debuginfo is installed

$ rpm -qa|grep Percona.*debuginfo
Percona-Server-55-debuginfo-5.5.20-rel24.1.217.rhel5

here is probe point which i choose

$ stap -L 'process("/usr/sbin/mysqld").function("*")'|grep mysql_execute_command
process("/usr/sbin/mysqld").function("mysql_execute_command@/usr/src/debug/Percona-Server-5.5.20-rel24.1/Percona-Server-5.5.20-rel24.1/sql/sql_parse.cc:1991")
$thd:struct THD*

so i use $$parms$ see  elements in struct THD , here is output

 thd={.prev=0x2aaacc2aaa90, .next=0x147146f0, .free_list=0x0,
.mem_root=0x1537d1e8, .state=3, .id=0, .mark_used_columns=1,
.name={...}, .lex=0x1537c030, .query_string={...}, .db="pharmnet",
.db_length=8, .m_reprepare_observer=0x0, .open_tables=0x0,
.temporary_tables=0x0, .LOCK_temporary_tables={...},
.derived_tables=0x0, .lock=0x0, .extra_lock=0x0,
.locked_tables_mode=0, .current_tablenr=1, .state_flags=0,
.mdl_context={...}, .rli_fake=0x0, .query_without_comments={...},
.query_cache_tls={...}, .net={...},

and i choose query_string for looking ,and here is my script

function __get_sql:string (thd:long){
        my_sql = thd
           ? (@defined(@cast(thd, "THD")->query_string)
                ? @cast(thd, "THD")->query_string
                : "NOTHING")
           : "NO Thread"
        return my_sql
}

probe process("/usr/sbin/mysqld").function("mysql_execute_command").return {
        myh = __get_sql($thd)
        printf(" %p : %s \n",$thd,myh)
}

compile is fine,but output is not expected ,why?

 0x1537a460 : NOTHING
 0x1537a460 : NOTHING
 0x1537a460 : NOTHING
 0x1537a460 : NOTHING
 0x1537a460 : NOTHING

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: problem in tuning mysql code use systemtap
  2012-03-24  7:02 problem in tuning mysql code use systemtap ch huang
@ 2012-03-24  9:23 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2012-03-24  9:23 UTC (permalink / raw)
  To: ch huang; +Cc: systemtap

On Sat, Mar 24, 2012 at 03:01:59PM +0800, ch huang wrote:
> function __get_sql:string (thd:long){
>         my_sql = thd
>            ? (@defined(@cast(thd, "THD")->query_string)
>                 ? @cast(thd, "THD")->query_string
>                 : "NOTHING")
>            : "NO Thread"
>         return my_sql
> }
> 
> probe process("/usr/sbin/mysqld").function("mysql_execute_command").return {
>         myh = __get_sql($thd)
>         printf(" %p : %s \n",$thd,myh)
> }
> 
> compile is fine,but output is not expected ,why?
> 
>  0x1537a460 : NOTHING

This is because @cast defaults to the "kernel" for none probe contexts.
function __get_sql isn't a probe context and so @cast doesn't know
where you want the cast from. You can try telling it explicitly, with
@cast(thd, "THD", "/usr/sbin/mysqld")->query_string

See http://sourceware.org/systemtap/langref/Language_elements.html#SECTION000661100000000000000

Cheers,

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-24  9:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-24  7:02 problem in tuning mysql code use systemtap ch huang
2012-03-24  9:23 ` Mark Wielaard

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).