[SPDK] Re: Print backtrace in SPDK

Wenhua Liu <liuw at vmware.com>
Newsgroups dev.linux.lists.spdk
Message-ID <[email protected]>
Thanks Andrey for suggestion. The backtrace(3) seems to be the right way, but is not sufficient.

There is a function rte_dump_stack which calls backtrace and backtrace_symbols. I copied it into nvmf_tcp_close_qpair and modified a little bit as below:
+       {
+               void *func[BACKTRACE_SIZE];
+               char **symb = NULL;
+               int size;
+       
+               size = backtrace(func, BACKTRACE_SIZE);
+               symb = backtrace_symbols(func, size);
+       
+               if (symb == NULL)
+                       return;
+       
+               while (size > 0) {
+                       SPDK_ERRLOG("%d: [%s]\n", size, symb[size - 1]);
+                       size --;
+               }
+       
+               free(symb);
+       }

The output I got is like:
[2020-08-22 21:44:34.404823] tcp.c:2395:nvmf_tcp_close_qpair: *ERROR*: 13: [build/bin/nvmf_tgt(+0x126fe) [0x5627642236fe]]
[2020-08-22 21:44:34.404857] tcp.c:2395:nvmf_tcp_close_qpair: *ERROR*: 12: [/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf3) [0x7fed1369d1e3]]
[2020-08-22 21:44:34.404868] tcp.c:2395:nvmf_tcp_close_qpair: *ERROR*: 11: [build/bin/nvmf_tgt(+0x128e9) [0x5627642238e9]]
[2020-08-22 21:44:34.404876] tcp.c:2395:nvmf_tcp_close_qpair: *ERROR*: 10: [build/bin/nvmf_tgt(+0xd9f32) [0x5627642eaf32]]
[2020-08-22 21:44:34.404882] tcp.c:2395:nvmf_tcp_close_qpair: *ERROR*: 9: [build/bin/nvmf_tgt(+0xdc096) [0x5627642ed096]]
[2020-08-22 21:44:34.404889] tcp.c:2395:nvmf_tcp_close_qpair: *ERROR*: 8: [build/bin/nvmf_tgt(+0xdbc73) [0x5627642ecc73]]
[2020-08-22 21:44:34.404895] tcp.c:2395:nvmf_tcp_close_qpair: *ERROR*: 7: [build/bin/nvmf_tgt(+0xdbb5d) [0x5627642ecb5d]]
[2020-08-22 21:44:34.404902] tcp.c:2395:nvmf_tcp_close_qpair: *ERROR*: 6: [build/bin/nvmf_tgt(+0xe35da) [0x5627642f45da]]
[2020-08-22 21:44:34.404908] tcp.c:2395:nvmf_tcp_close_qpair: *ERROR*: 5: [build/bin/nvmf_tgt(+0xe3054) [0x5627642f4054]]
[2020-08-22 21:44:34.404915] tcp.c:2395:nvmf_tcp_close_qpair: *ERROR*: 4: [build/bin/nvmf_tgt(+0xe2d94) [0x5627642f3d94]]
[2020-08-22 21:44:34.404922] tcp.c:2395:nvmf_tcp_close_qpair: *ERROR*: 3: [build/bin/nvmf_tgt(+0xca3b7) [0x5627642db3b7]]
[2020-08-22 21:44:34.404928] tcp.c:2395:nvmf_tcp_close_qpair: *ERROR*: 2: [build/bin/nvmf_tgt(+0xd09e8) [0x5627642e19e8]]
[2020-08-22 21:44:34.404935] tcp.c:2395:nvmf_tcp_close_qpair: *ERROR*: 1: [build/bin/nvmf_tgt(+0xd8158) [0x5627642e9158]]

This is not very helpful.

Thanks,
-Wenhua


On 8/22/20, 12:58 AM, "Andrey Kuzmin" <andrey.v.kuzmin(a)gmail.com> wrote:

    On Sat, Aug 22, 2020, 10:14 Wenhua Liu <liuw(a)vmware.com> wrote:

    > Hi,
    >
    > Does anyone know if there is a function in SPDK that prints the backtrace?
    >

    backtrace(3) lets you do that.

    Regards,
    Andrey


    > I run into a “Connection Reset by Peer” issue on host side when testing
    > NVMe/TCP. I identified it’s because some queue pairs are closed
    > unexpectedly by calling nvmf_tcp_close_qpair, but I could not figure out
    > how/why this function is called. I thought if the backtrace can be printed
    > when calling this function, it might be helpful to me to find the root
    > cause.
    >
    > Thanks,
    > -Wenhua
    > _______________________________________________
    > SPDK mailing list -- spdk(a)lists.01.org
    > To unsubscribe send an email to spdk-leave(a)lists.01.org
    >
    _______________________________________________
    SPDK mailing list -- spdk(a)lists.01.org
    To unsubscribe send an email to spdk-leave(a)lists.01.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.