I found such answer on SO
https://stackoverflow.com/a/42987032/5709159
And there is my implementation
C# Unity
    [DllImport(m_pluginName, CallingConvention = CallingConvention.Cdecl)]
    public static extern IntPtr /* char const * */ get_profiling_info(IntPtr native_stream_ptr);
string foo(){
            string prof_info;
            IntPtr pU = get_profiling_info(stream);
            if (pU == IntPtr.Zero)
            {
                prof_info = null;
            }
            else
            {
                prof_info = Marshal.PtrToStringAnsi(pU);
            }
    return prof_info;
}
C++
    DllExport char const * get_profiling_info(void * native_stream_ptr)
    {
        TV_DecoderStream * stream_decoder = reinterpret_cast<TV_DecoderStream *>(native_stream_ptr);
        assert(stream_decoder != nullptr);
        std::string result = stream_decoder->m_prof_txt;
        return result.c_str();
    }
and there is an error I get
2020-10-15 17:27:42.488 4105-4134/com.com.unityandroidplayer E/AndroidRuntime: FATAL EXCEPTION: UnityMain
    Process: com.com.unityandroidplayer, PID: 4105
    java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    Version '2020.1.8f1 (22e8c0b0c3ec)', Build type 'Development', Scripting Backend 'mono', CPU 'armeabi-v7a'
    Build fingerprint: 'google/taimen/taimen:11/RP1A.201005.004/6782484:user/release-keys'
    Revision: 'rev_10'
    ABI: 'arm'
    Timestamp: 2020-10-15 17:27:41+0300
    pid: 4105, tid: 4134, name: UnityMain  >>> com.com.unityandroidplayer <<<
    uid: 10036
    signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0xbc344000
        r0  9ab64640  r1  bc343ff5  r2  003c11e2  r3  00000034
        r4  be389120  r5  be39cf68  r6  be3b2e10  r7  bc33f9c1
        r8  00000000  r9  0000046c  r10 00000001  r11 bc33f8a0
        ip  a0000000  sp  bc33f880  lr  bc6b8cec  pc  eaecb1d8
    
    backtrace:
          #00 pc 000351d8  /apex/com.android.runtime/lib/bionic/libc.so (__memcpy_base_aligned_a9+144) (BuildId: 92e55abcc7bb795778c1353de856043e)
          #01 pc 001019bf  [anon:stack_and_tls:4134]
    
    managed backtrace:
          #00 (wrapper managed-to-native) object:__icall_wrapper_mono_string_from_bstr_icall (intptr)
          #01 (wrapper managed-to-native) comCAPI:get_profiling_info (intptr)
          #02 comPlayer:OnGUI () <D:\TV_repo\com_unity\TestControlller2\Assets\Scripts\comPlayer.cs:322>
          #03 (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    
        at libc.__memcpy_base_aligned_a9(__memcpy_base_aligned_a9:144)
        at [anon:stack_and_tls:4134].0x1019bf(Native Method)
        at System.Object.__icall_wrapper_mono_string_from_bstr_icall (intptr)(Native Method)
        at comCAPI.get_profiling_info (intptr)(Native Method)
        at comPlayer.OnGUI ()(D:\TV_repo\com_unity\TestControlller2\Assets\Scripts\comPlayer.cs:322)
        at System.Object.runtime_invoke_void__this__ (object,intptr,intptr,intptr)(Native Method)
What am I doing wrong?
 
     
    