systemtap可以将int局部变量作为目标,但不能在用户空间中将字符串作为局部变量作为目标

时间:2020-02-08 09:05:11

标签: c++ c++17 systemtap

我使用systemtap定位用户空间变量,我的应用程序代码如下

std::string Zhangcount(std::string cstr, int i, MarketData const & marketData){
    double  price = marketData.price;
     char s='x';
    cstr = "woaimaomao";
    if(i==3000){
   //     usleep(30);
    }
    return cstr;
}

我的系统点击代码是:

 probe process("process").function("Zhangcount").return {
  printf("i=%d\n",@entry( $i))                                                                                                                                                                                                                                              
  printf("cstr=%s\n",@entry( $cstr))
}

printf("i=%d\n",@entry( $i))可以在应用程序中打印正确的值,但是printf("cstr=%s\n",@entry( $cstr))导致如下错误: semantic error: 'class basic_string<char, std::char_traits<char>, std::allocator<char> >' (/usr/local/include/c++/9.1.0/bits/basic_string.h:77) is being accessed instead of a member such as '->_M_allocated_capacity': identifier '$cstr' at linestime.stp:26:30 source: printf("cstr=%s\n",@entry( $cstr)) 我搜索了几天,但不知道要解决它。

0 个答案:

没有答案
相关问题