You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nuttx.apache.org by Fotis Panagiotopoulos <f....@gmail.com> on 2022/06/22 18:10:20 UTC

NuttX-aware debugging.

Hello,

I am in need of debugging NuttX in a thread-aware fashion, as I still hit a
dead-lock in networking that I haven't managed to track down yet.

I am using a custom target, based on the STM32F427VI and JLink as the
debugger.

I see that there is a plug-in for JLink GDB that was added in #4810.
Unfortunately, I never got this working. I commented on the PR, but I got
ignored.

So:

1. I cannot build the plug-in.
Running:

make -C tools -f Makefile.host all

I get:

/usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32 against
`.rodata.str1.8' can not be used when making a shared object; recompile
with -fPIC
collect2: error: ld returned 1 exit status
make: *** [Makefile.host:231: jlink-nuttx.so] Error 1

I added the -fPIC option, and it was built successfully.
If this is actually the correct option, then I guess the makefile has to be
fixed?


2. After building the plug-in with -fPIC, it crashes during start with a
segmentation fault.

Here is an example output:
https://pastebin.com/U1tqtMND


Has anyone managed to use this?
Any idea what the fault may be?

Re: NuttX-aware debugging.

Posted by Fotis Panagiotopoulos <f....@gmail.com>.
> Could you try this patch?

I just tried it, and it works correctly. Thank you!


Also, can you please check whether you can build the plug-in with -fPIC?
If it is needed for some distros, and it is not harmful for the rest, we
may add it permanently.



On Sat, Jun 25, 2022 at 3:34 PM Xiang Xiao <xi...@gmail.com>
wrote:

> On Fri, Jun 24, 2022 at 5:42 PM Fotis Panagiotopoulos <f.j.panag@gmail.com
> >
> wrote:
>
> > Hello everyone!
> >
> > I got it working.
> >
> >
> Good luck.
>
>
> > The issue is in RTOS_SetThreadReg().
> > For some reason g_plugin_priv.tcbinfo is NULL.
> >
> > I added a simple check:
> >
> >   if (g_plugin_priv.tcbinfo == 0)
> >     {
> >       return -EINVAL;
> >     }
> >
> > And now it works correctly.
> >
> >
> > I can submit a PR, however I have no idea how this plugin works, and
> thus I
> > do not know whether this value is expected to be NULL (and thus a check
> is
> > missing), or whether there is any other underlying issue.
> > Mr. Xiang, can you please have a look at this and comment?
> >
> >
> It's more simple to remove the below check from the code:
>   if (regindex > g_plugin_priv.tcbinfo->total_num)
>     {
>       return -EINVAL;
>     }
> since get_idx_from_pid already does the same check.
> Could you try this patch?
> https://github.com/apache/incubator-nuttx/pull/6520
>
>
> >
> >
> > On Thu, Jun 23, 2022 at 6:11 PM Xiang Xiao <xi...@gmail.com>
> > wrote:
> >
> > > We document the JLinker plugin usage, but it's the Chinese version
> only.
> > > Pengxiang, please prepare a document.
> > > In the meantime, Fotis, could you attach gdb to JLinkGDBServer and
> print
> > > the backtrace when it crashes, so we can identify the reason quickly.
> > >
> > >
> > > On Thu, Jun 23, 2022 at 10:36 PM Alan Carvalho de Assis <
> > acassis@gmail.com
> > > >
> > > wrote:
> > >
> > > > Please describe all the steps you are doing and such way everybody
> can
> > > > reproduce yet (same way I did in previous email).
> > > >
> > > > I don't think a library compile to Ubuntu will work on Fedora.
> > > >
> > > > Xiang, do you have a documentation about the JLink integration? BTW,
> > > > any news about the guy/gal Xiaomi was contracting to write better
> > > > documentation to NuttX ?
> > > >
> > > > BR,
> > > >
> > > > Alan
> > > >
> > > > On 6/23/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> > > > > I tried your instructions.
> > > > > The build fails on a clean repository too.
> > > > >
> > > > > I then tried a newer version of Ubuntu (as a Docker container, I do
> > not
> > > > > have access to any other Ubuntu machines).
> > > > > This time the build succeeded.
> > > > >
> > > > > However I haven't managed to debug the application from within this
> > > > Docker
> > > > > container.
> > > > >
> > > > > I took the successfully built plug-in, and used it on my Fedora
> > > machine.
> > > > > Again, it crashes in the same way.
> > > > >
> > > > >
> > > > > On Thu, Jun 23, 2022 at 5:06 PM Alan Carvalho de Assis <
> > > > acassis@gmail.com>
> > > > > wrote:
> > > > >
> > > > >> Hi Fotis,
> > > > >>
> > > > >> I'm using Ubuntu 20.04 and I can confirm it is working fine, I
> don't
> > > > >> need to add -fPIC.
> > > > >>
> > > > >> Please try a clear repository, I will do it here step-by-step on
> > /tmp
> > > > >> to removed after next reboot:
> > > > >>
> > > > >> $ cd /tmp/
> > > > >> $ git clone https://github.com/apache/incubator-nuttx nuttx
> > > > >> $ git clone https://github.com/apache/incubator-nuttx-apps apps
> > > > >> $ cd nuttx/
> > > > >> $ make -C tools -f Makefile.host all
> > > > >> $ ls -l tools/jlink*
> > > > >> -rwxrwxr-x 1 alan alan 17144 jun 23 11:02 tools/jlink-nuttx
> > > > >> -rw-rw-r-- 1 alan alan 16804 jun 23 11:01 tools/jlink-nuttx.c
> > > > >>
> > > > >> I didn't test it with JLinkGDBServer, but at least I can tell you
> it
> > > > >> is compiling fine.
> > > > >>
> > > > >> BR,
> > > > >>
> > > > >> Alan
> > > > >>
> > > > >> On 6/23/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> > > > >> >> Ahhh, so it is your Fedora 36 issue, hahaha
> > > > >> >
> > > > >> > No, it is not.
> > > > >> >
> > > > >> > I just tried on Ubuntu 18, and I got the exact same result.
> > > > >> >
> > > > >> > Build fails with the same error. I added the -fPIC flag, and the
> > > build
> > > > >> > succeeded.
> > > > >> > Then I tried to debug the firmware with JLink and GDB crashes
> > during
> > > > >> > init
> > > > >> > with a SEGFAULT.
> > > > >> >
> > > > >> > Just like on Fedora.
> > > > >> >
> > > > >> > So I guess, this is a problem with the plug-in itself?
> > > > >> >
> > > > >> > Those that have managed to use the plug-in successfully, what is
> > the
> > > > >> > version of JLinkGDBServer ?
> > > > >> > Mine is V7.54c.
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >> > On Thu, Jun 23, 2022 at 1:50 AM Alan Carvalho de Assis <
> > > > >> acassis@gmail.com>
> > > > >> > wrote:
> > > > >> >
> > > > >> >> Ahhh, so it is your Fedora 36 issue, hahaha
> > > > >> >>
> > > > >> >> Here on Ubuntu "make -C tools -f Makefile.host all" works fine.
> > > > >> >>
> > > > >> >> It created the jlink-nuttx.so file.
> > > > >> >>
> > > > >> >> BR,
> > > > >> >>
> > > > >> >> Alan
> > > > >> >>
> > > > >> >> On 6/22/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> > > > >> >> > Yes I enabled CONFIG_DEBUG_TCBINFO.
> > > > >> >> > (When disabled, debugging works normally but without being
> > > > >> >> > thread-aware).
> > > > >> >> >
> > > > >> >> > It seems that it is either a bug in the plugin itself, or
> > > something
> > > > >> >> > is
> > > > >> >> > wrong with my build.
> > > > >> >> >
> > > > >> >> > If it matters, I am using Fedora 36 with gcc (GCC) 12.1.1
> > > 20220507
> > > > >> (Red
> > > > >> >> Hat
> > > > >> >> > 12.1.1-1)
> > > > >> >> >
> > > > >> >> > Maybe someone can provide me with a pre-build .so file to
> test
> > if
> > > > >> >> > this
> > > > >> >> > is
> > > > >> >> > the cause?
> > > > >> >> >
> > > > >> >> >
> > > > >> >> >
> > > > >> >> >
> > > > >> >> > On Wed, Jun 22, 2022 at 10:30 PM Xiang Xiao <
> > > > >> xiaoxiang781216@gmail.com>
> > > > >> >> > wrote:
> > > > >> >> >
> > > > >> >> >> Did you enable CONFIG_DEBUG_TCBINFO in your defconfig:
> > > > >> >> >> incubator-nuttx/Kconfig at master · apache/incubator-nuttx
> > > > >> >> >> (github.com)
> > > > >> >> >> <
> > > > >> >>
> > > > >>
> > > >
> > >
> >
> https://github.com/apache/incubator-nuttx/blob/master/Kconfig#L1857-L1863
> > > > >> >> >> >
> > > > >> >> >> The plugin needs the g_tcbinfo to know the critical offset
> of
> > > the
> > > > >> >> >> field
> > > > >> >> >> in
> > > > >> >> >> tcb_s structure.
> > > > >> >> >>
> > > > >> >> >> On Thu, Jun 23, 2022 at 2:10 AM Fotis Panagiotopoulos
> > > > >> >> >> <f.j.panag@gmail.com
> > > > >> >> >> >
> > > > >> >> >> wrote:
> > > > >> >> >>
> > > > >> >> >> > Hello,
> > > > >> >> >> >
> > > > >> >> >> > I am in need of debugging NuttX in a thread-aware fashion,
> > as
> > > I
> > > > >> >> >> > still
> > > > >> >> >> hit a
> > > > >> >> >> > dead-lock in networking that I haven't managed to track
> down
> > > > yet.
> > > > >> >> >> >
> > > > >> >> >> > I am using a custom target, based on the STM32F427VI and
> > JLink
> > > > as
> > > > >> >> >> > the
> > > > >> >> >> > debugger.
> > > > >> >> >> >
> > > > >> >> >> > I see that there is a plug-in for JLink GDB that was added
> > in
> > > > >> #4810.
> > > > >> >> >> > Unfortunately, I never got this working. I commented on
> the
> > > PR,
> > > > >> >> >> > but
> > > > >> >> >> > I
> > > > >> >> >> > got
> > > > >> >> >> > ignored.
> > > > >> >> >> >
> > > > >> >> >> > So:
> > > > >> >> >> >
> > > > >> >> >> > 1. I cannot build the plug-in.
> > > > >> >> >> > Running:
> > > > >> >> >> >
> > > > >> >> >> > make -C tools -f Makefile.host all
> > > > >> >> >> >
> > > > >> >> >> > I get:
> > > > >> >> >> >
> > > > >> >> >> > /usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32
> against
> > > > >> >> >> > `.rodata.str1.8' can not be used when making a shared
> > object;
> > > > >> >> recompile
> > > > >> >> >> > with -fPIC
> > > > >> >> >> > collect2: error: ld returned 1 exit status
> > > > >> >> >> > make: *** [Makefile.host:231: jlink-nuttx.so] Error 1
> > > > >> >> >> >
> > > > >> >> >> > I added the -fPIC option, and it was built successfully.
> > > > >> >> >> > If this is actually the correct option, then I guess the
> > > > makefile
> > > > >> >> >> > has
> > > > >> >> >> > to
> > > > >> >> >> be
> > > > >> >> >> > fixed?
> > > > >> >> >> >
> > > > >> >> >> >
> > > > >> >> >> > 2. After building the plug-in with -fPIC, it crashes
> during
> > > > start
> > > > >> >> >> > with
> > > > >> >> >> > a
> > > > >> >> >> > segmentation fault.
> > > > >> >> >> >
> > > > >> >> >> > Here is an example output:
> > > > >> >> >> > https://pastebin.com/U1tqtMND
> > > > >> >> >> >
> > > > >> >> >> >
> > > > >> >> >> > Has anyone managed to use this?
> > > > >> >> >> > Any idea what the fault may be?
> > > > >> >> >> >
> > > > >> >> >>
> > > > >> >> >
> > > > >> >>
> > > > >> >
> > > > >>
> > > > >
> > > >
> > >
> >
>

Re: NuttX-aware debugging.

Posted by Xiang Xiao <xi...@gmail.com>.
On Fri, Jun 24, 2022 at 5:42 PM Fotis Panagiotopoulos <f....@gmail.com>
wrote:

> Hello everyone!
>
> I got it working.
>
>
Good luck.


> The issue is in RTOS_SetThreadReg().
> For some reason g_plugin_priv.tcbinfo is NULL.
>
> I added a simple check:
>
>   if (g_plugin_priv.tcbinfo == 0)
>     {
>       return -EINVAL;
>     }
>
> And now it works correctly.
>
>
> I can submit a PR, however I have no idea how this plugin works, and thus I
> do not know whether this value is expected to be NULL (and thus a check is
> missing), or whether there is any other underlying issue.
> Mr. Xiang, can you please have a look at this and comment?
>
>
It's more simple to remove the below check from the code:
  if (regindex > g_plugin_priv.tcbinfo->total_num)
    {
      return -EINVAL;
    }
since get_idx_from_pid already does the same check.
Could you try this patch?
https://github.com/apache/incubator-nuttx/pull/6520


>
>
> On Thu, Jun 23, 2022 at 6:11 PM Xiang Xiao <xi...@gmail.com>
> wrote:
>
> > We document the JLinker plugin usage, but it's the Chinese version only.
> > Pengxiang, please prepare a document.
> > In the meantime, Fotis, could you attach gdb to JLinkGDBServer and print
> > the backtrace when it crashes, so we can identify the reason quickly.
> >
> >
> > On Thu, Jun 23, 2022 at 10:36 PM Alan Carvalho de Assis <
> acassis@gmail.com
> > >
> > wrote:
> >
> > > Please describe all the steps you are doing and such way everybody can
> > > reproduce yet (same way I did in previous email).
> > >
> > > I don't think a library compile to Ubuntu will work on Fedora.
> > >
> > > Xiang, do you have a documentation about the JLink integration? BTW,
> > > any news about the guy/gal Xiaomi was contracting to write better
> > > documentation to NuttX ?
> > >
> > > BR,
> > >
> > > Alan
> > >
> > > On 6/23/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> > > > I tried your instructions.
> > > > The build fails on a clean repository too.
> > > >
> > > > I then tried a newer version of Ubuntu (as a Docker container, I do
> not
> > > > have access to any other Ubuntu machines).
> > > > This time the build succeeded.
> > > >
> > > > However I haven't managed to debug the application from within this
> > > Docker
> > > > container.
> > > >
> > > > I took the successfully built plug-in, and used it on my Fedora
> > machine.
> > > > Again, it crashes in the same way.
> > > >
> > > >
> > > > On Thu, Jun 23, 2022 at 5:06 PM Alan Carvalho de Assis <
> > > acassis@gmail.com>
> > > > wrote:
> > > >
> > > >> Hi Fotis,
> > > >>
> > > >> I'm using Ubuntu 20.04 and I can confirm it is working fine, I don't
> > > >> need to add -fPIC.
> > > >>
> > > >> Please try a clear repository, I will do it here step-by-step on
> /tmp
> > > >> to removed after next reboot:
> > > >>
> > > >> $ cd /tmp/
> > > >> $ git clone https://github.com/apache/incubator-nuttx nuttx
> > > >> $ git clone https://github.com/apache/incubator-nuttx-apps apps
> > > >> $ cd nuttx/
> > > >> $ make -C tools -f Makefile.host all
> > > >> $ ls -l tools/jlink*
> > > >> -rwxrwxr-x 1 alan alan 17144 jun 23 11:02 tools/jlink-nuttx
> > > >> -rw-rw-r-- 1 alan alan 16804 jun 23 11:01 tools/jlink-nuttx.c
> > > >>
> > > >> I didn't test it with JLinkGDBServer, but at least I can tell you it
> > > >> is compiling fine.
> > > >>
> > > >> BR,
> > > >>
> > > >> Alan
> > > >>
> > > >> On 6/23/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> > > >> >> Ahhh, so it is your Fedora 36 issue, hahaha
> > > >> >
> > > >> > No, it is not.
> > > >> >
> > > >> > I just tried on Ubuntu 18, and I got the exact same result.
> > > >> >
> > > >> > Build fails with the same error. I added the -fPIC flag, and the
> > build
> > > >> > succeeded.
> > > >> > Then I tried to debug the firmware with JLink and GDB crashes
> during
> > > >> > init
> > > >> > with a SEGFAULT.
> > > >> >
> > > >> > Just like on Fedora.
> > > >> >
> > > >> > So I guess, this is a problem with the plug-in itself?
> > > >> >
> > > >> > Those that have managed to use the plug-in successfully, what is
> the
> > > >> > version of JLinkGDBServer ?
> > > >> > Mine is V7.54c.
> > > >> >
> > > >> >
> > > >> >
> > > >> >
> > > >> >
> > > >> >
> > > >> >
> > > >> >
> > > >> > On Thu, Jun 23, 2022 at 1:50 AM Alan Carvalho de Assis <
> > > >> acassis@gmail.com>
> > > >> > wrote:
> > > >> >
> > > >> >> Ahhh, so it is your Fedora 36 issue, hahaha
> > > >> >>
> > > >> >> Here on Ubuntu "make -C tools -f Makefile.host all" works fine.
> > > >> >>
> > > >> >> It created the jlink-nuttx.so file.
> > > >> >>
> > > >> >> BR,
> > > >> >>
> > > >> >> Alan
> > > >> >>
> > > >> >> On 6/22/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> > > >> >> > Yes I enabled CONFIG_DEBUG_TCBINFO.
> > > >> >> > (When disabled, debugging works normally but without being
> > > >> >> > thread-aware).
> > > >> >> >
> > > >> >> > It seems that it is either a bug in the plugin itself, or
> > something
> > > >> >> > is
> > > >> >> > wrong with my build.
> > > >> >> >
> > > >> >> > If it matters, I am using Fedora 36 with gcc (GCC) 12.1.1
> > 20220507
> > > >> (Red
> > > >> >> Hat
> > > >> >> > 12.1.1-1)
> > > >> >> >
> > > >> >> > Maybe someone can provide me with a pre-build .so file to test
> if
> > > >> >> > this
> > > >> >> > is
> > > >> >> > the cause?
> > > >> >> >
> > > >> >> >
> > > >> >> >
> > > >> >> >
> > > >> >> > On Wed, Jun 22, 2022 at 10:30 PM Xiang Xiao <
> > > >> xiaoxiang781216@gmail.com>
> > > >> >> > wrote:
> > > >> >> >
> > > >> >> >> Did you enable CONFIG_DEBUG_TCBINFO in your defconfig:
> > > >> >> >> incubator-nuttx/Kconfig at master · apache/incubator-nuttx
> > > >> >> >> (github.com)
> > > >> >> >> <
> > > >> >>
> > > >>
> > >
> >
> https://github.com/apache/incubator-nuttx/blob/master/Kconfig#L1857-L1863
> > > >> >> >> >
> > > >> >> >> The plugin needs the g_tcbinfo to know the critical offset of
> > the
> > > >> >> >> field
> > > >> >> >> in
> > > >> >> >> tcb_s structure.
> > > >> >> >>
> > > >> >> >> On Thu, Jun 23, 2022 at 2:10 AM Fotis Panagiotopoulos
> > > >> >> >> <f.j.panag@gmail.com
> > > >> >> >> >
> > > >> >> >> wrote:
> > > >> >> >>
> > > >> >> >> > Hello,
> > > >> >> >> >
> > > >> >> >> > I am in need of debugging NuttX in a thread-aware fashion,
> as
> > I
> > > >> >> >> > still
> > > >> >> >> hit a
> > > >> >> >> > dead-lock in networking that I haven't managed to track down
> > > yet.
> > > >> >> >> >
> > > >> >> >> > I am using a custom target, based on the STM32F427VI and
> JLink
> > > as
> > > >> >> >> > the
> > > >> >> >> > debugger.
> > > >> >> >> >
> > > >> >> >> > I see that there is a plug-in for JLink GDB that was added
> in
> > > >> #4810.
> > > >> >> >> > Unfortunately, I never got this working. I commented on the
> > PR,
> > > >> >> >> > but
> > > >> >> >> > I
> > > >> >> >> > got
> > > >> >> >> > ignored.
> > > >> >> >> >
> > > >> >> >> > So:
> > > >> >> >> >
> > > >> >> >> > 1. I cannot build the plug-in.
> > > >> >> >> > Running:
> > > >> >> >> >
> > > >> >> >> > make -C tools -f Makefile.host all
> > > >> >> >> >
> > > >> >> >> > I get:
> > > >> >> >> >
> > > >> >> >> > /usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32 against
> > > >> >> >> > `.rodata.str1.8' can not be used when making a shared
> object;
> > > >> >> recompile
> > > >> >> >> > with -fPIC
> > > >> >> >> > collect2: error: ld returned 1 exit status
> > > >> >> >> > make: *** [Makefile.host:231: jlink-nuttx.so] Error 1
> > > >> >> >> >
> > > >> >> >> > I added the -fPIC option, and it was built successfully.
> > > >> >> >> > If this is actually the correct option, then I guess the
> > > makefile
> > > >> >> >> > has
> > > >> >> >> > to
> > > >> >> >> be
> > > >> >> >> > fixed?
> > > >> >> >> >
> > > >> >> >> >
> > > >> >> >> > 2. After building the plug-in with -fPIC, it crashes during
> > > start
> > > >> >> >> > with
> > > >> >> >> > a
> > > >> >> >> > segmentation fault.
> > > >> >> >> >
> > > >> >> >> > Here is an example output:
> > > >> >> >> > https://pastebin.com/U1tqtMND
> > > >> >> >> >
> > > >> >> >> >
> > > >> >> >> > Has anyone managed to use this?
> > > >> >> >> > Any idea what the fault may be?
> > > >> >> >> >
> > > >> >> >>
> > > >> >> >
> > > >> >>
> > > >> >
> > > >>
> > > >
> > >
> >
>

Re: NuttX-aware debugging.

Posted by Fotis Panagiotopoulos <f....@gmail.com>.
Hello everyone!

I got it working.

The issue is in RTOS_SetThreadReg().
For some reason g_plugin_priv.tcbinfo is NULL.

I added a simple check:

  if (g_plugin_priv.tcbinfo == 0)
    {
      return -EINVAL;
    }

And now it works correctly.


I can submit a PR, however I have no idea how this plugin works, and thus I
do not know whether this value is expected to be NULL (and thus a check is
missing), or whether there is any other underlying issue.
Mr. Xiang, can you please have a look at this and comment?



On Thu, Jun 23, 2022 at 6:11 PM Xiang Xiao <xi...@gmail.com>
wrote:

> We document the JLinker plugin usage, but it's the Chinese version only.
> Pengxiang, please prepare a document.
> In the meantime, Fotis, could you attach gdb to JLinkGDBServer and print
> the backtrace when it crashes, so we can identify the reason quickly.
>
>
> On Thu, Jun 23, 2022 at 10:36 PM Alan Carvalho de Assis <acassis@gmail.com
> >
> wrote:
>
> > Please describe all the steps you are doing and such way everybody can
> > reproduce yet (same way I did in previous email).
> >
> > I don't think a library compile to Ubuntu will work on Fedora.
> >
> > Xiang, do you have a documentation about the JLink integration? BTW,
> > any news about the guy/gal Xiaomi was contracting to write better
> > documentation to NuttX ?
> >
> > BR,
> >
> > Alan
> >
> > On 6/23/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> > > I tried your instructions.
> > > The build fails on a clean repository too.
> > >
> > > I then tried a newer version of Ubuntu (as a Docker container, I do not
> > > have access to any other Ubuntu machines).
> > > This time the build succeeded.
> > >
> > > However I haven't managed to debug the application from within this
> > Docker
> > > container.
> > >
> > > I took the successfully built plug-in, and used it on my Fedora
> machine.
> > > Again, it crashes in the same way.
> > >
> > >
> > > On Thu, Jun 23, 2022 at 5:06 PM Alan Carvalho de Assis <
> > acassis@gmail.com>
> > > wrote:
> > >
> > >> Hi Fotis,
> > >>
> > >> I'm using Ubuntu 20.04 and I can confirm it is working fine, I don't
> > >> need to add -fPIC.
> > >>
> > >> Please try a clear repository, I will do it here step-by-step on /tmp
> > >> to removed after next reboot:
> > >>
> > >> $ cd /tmp/
> > >> $ git clone https://github.com/apache/incubator-nuttx nuttx
> > >> $ git clone https://github.com/apache/incubator-nuttx-apps apps
> > >> $ cd nuttx/
> > >> $ make -C tools -f Makefile.host all
> > >> $ ls -l tools/jlink*
> > >> -rwxrwxr-x 1 alan alan 17144 jun 23 11:02 tools/jlink-nuttx
> > >> -rw-rw-r-- 1 alan alan 16804 jun 23 11:01 tools/jlink-nuttx.c
> > >>
> > >> I didn't test it with JLinkGDBServer, but at least I can tell you it
> > >> is compiling fine.
> > >>
> > >> BR,
> > >>
> > >> Alan
> > >>
> > >> On 6/23/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> > >> >> Ahhh, so it is your Fedora 36 issue, hahaha
> > >> >
> > >> > No, it is not.
> > >> >
> > >> > I just tried on Ubuntu 18, and I got the exact same result.
> > >> >
> > >> > Build fails with the same error. I added the -fPIC flag, and the
> build
> > >> > succeeded.
> > >> > Then I tried to debug the firmware with JLink and GDB crashes during
> > >> > init
> > >> > with a SEGFAULT.
> > >> >
> > >> > Just like on Fedora.
> > >> >
> > >> > So I guess, this is a problem with the plug-in itself?
> > >> >
> > >> > Those that have managed to use the plug-in successfully, what is the
> > >> > version of JLinkGDBServer ?
> > >> > Mine is V7.54c.
> > >> >
> > >> >
> > >> >
> > >> >
> > >> >
> > >> >
> > >> >
> > >> >
> > >> > On Thu, Jun 23, 2022 at 1:50 AM Alan Carvalho de Assis <
> > >> acassis@gmail.com>
> > >> > wrote:
> > >> >
> > >> >> Ahhh, so it is your Fedora 36 issue, hahaha
> > >> >>
> > >> >> Here on Ubuntu "make -C tools -f Makefile.host all" works fine.
> > >> >>
> > >> >> It created the jlink-nuttx.so file.
> > >> >>
> > >> >> BR,
> > >> >>
> > >> >> Alan
> > >> >>
> > >> >> On 6/22/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> > >> >> > Yes I enabled CONFIG_DEBUG_TCBINFO.
> > >> >> > (When disabled, debugging works normally but without being
> > >> >> > thread-aware).
> > >> >> >
> > >> >> > It seems that it is either a bug in the plugin itself, or
> something
> > >> >> > is
> > >> >> > wrong with my build.
> > >> >> >
> > >> >> > If it matters, I am using Fedora 36 with gcc (GCC) 12.1.1
> 20220507
> > >> (Red
> > >> >> Hat
> > >> >> > 12.1.1-1)
> > >> >> >
> > >> >> > Maybe someone can provide me with a pre-build .so file to test if
> > >> >> > this
> > >> >> > is
> > >> >> > the cause?
> > >> >> >
> > >> >> >
> > >> >> >
> > >> >> >
> > >> >> > On Wed, Jun 22, 2022 at 10:30 PM Xiang Xiao <
> > >> xiaoxiang781216@gmail.com>
> > >> >> > wrote:
> > >> >> >
> > >> >> >> Did you enable CONFIG_DEBUG_TCBINFO in your defconfig:
> > >> >> >> incubator-nuttx/Kconfig at master · apache/incubator-nuttx
> > >> >> >> (github.com)
> > >> >> >> <
> > >> >>
> > >>
> >
> https://github.com/apache/incubator-nuttx/blob/master/Kconfig#L1857-L1863
> > >> >> >> >
> > >> >> >> The plugin needs the g_tcbinfo to know the critical offset of
> the
> > >> >> >> field
> > >> >> >> in
> > >> >> >> tcb_s structure.
> > >> >> >>
> > >> >> >> On Thu, Jun 23, 2022 at 2:10 AM Fotis Panagiotopoulos
> > >> >> >> <f.j.panag@gmail.com
> > >> >> >> >
> > >> >> >> wrote:
> > >> >> >>
> > >> >> >> > Hello,
> > >> >> >> >
> > >> >> >> > I am in need of debugging NuttX in a thread-aware fashion, as
> I
> > >> >> >> > still
> > >> >> >> hit a
> > >> >> >> > dead-lock in networking that I haven't managed to track down
> > yet.
> > >> >> >> >
> > >> >> >> > I am using a custom target, based on the STM32F427VI and JLink
> > as
> > >> >> >> > the
> > >> >> >> > debugger.
> > >> >> >> >
> > >> >> >> > I see that there is a plug-in for JLink GDB that was added in
> > >> #4810.
> > >> >> >> > Unfortunately, I never got this working. I commented on the
> PR,
> > >> >> >> > but
> > >> >> >> > I
> > >> >> >> > got
> > >> >> >> > ignored.
> > >> >> >> >
> > >> >> >> > So:
> > >> >> >> >
> > >> >> >> > 1. I cannot build the plug-in.
> > >> >> >> > Running:
> > >> >> >> >
> > >> >> >> > make -C tools -f Makefile.host all
> > >> >> >> >
> > >> >> >> > I get:
> > >> >> >> >
> > >> >> >> > /usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32 against
> > >> >> >> > `.rodata.str1.8' can not be used when making a shared object;
> > >> >> recompile
> > >> >> >> > with -fPIC
> > >> >> >> > collect2: error: ld returned 1 exit status
> > >> >> >> > make: *** [Makefile.host:231: jlink-nuttx.so] Error 1
> > >> >> >> >
> > >> >> >> > I added the -fPIC option, and it was built successfully.
> > >> >> >> > If this is actually the correct option, then I guess the
> > makefile
> > >> >> >> > has
> > >> >> >> > to
> > >> >> >> be
> > >> >> >> > fixed?
> > >> >> >> >
> > >> >> >> >
> > >> >> >> > 2. After building the plug-in with -fPIC, it crashes during
> > start
> > >> >> >> > with
> > >> >> >> > a
> > >> >> >> > segmentation fault.
> > >> >> >> >
> > >> >> >> > Here is an example output:
> > >> >> >> > https://pastebin.com/U1tqtMND
> > >> >> >> >
> > >> >> >> >
> > >> >> >> > Has anyone managed to use this?
> > >> >> >> > Any idea what the fault may be?
> > >> >> >> >
> > >> >> >>
> > >> >> >
> > >> >>
> > >> >
> > >>
> > >
> >
>

Re: NuttX-aware debugging.

Posted by Xiang Xiao <xi...@gmail.com>.
We document the JLinker plugin usage, but it's the Chinese version only.
Pengxiang, please prepare a document.
In the meantime, Fotis, could you attach gdb to JLinkGDBServer and print
the backtrace when it crashes, so we can identify the reason quickly.


On Thu, Jun 23, 2022 at 10:36 PM Alan Carvalho de Assis <ac...@gmail.com>
wrote:

> Please describe all the steps you are doing and such way everybody can
> reproduce yet (same way I did in previous email).
>
> I don't think a library compile to Ubuntu will work on Fedora.
>
> Xiang, do you have a documentation about the JLink integration? BTW,
> any news about the guy/gal Xiaomi was contracting to write better
> documentation to NuttX ?
>
> BR,
>
> Alan
>
> On 6/23/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> > I tried your instructions.
> > The build fails on a clean repository too.
> >
> > I then tried a newer version of Ubuntu (as a Docker container, I do not
> > have access to any other Ubuntu machines).
> > This time the build succeeded.
> >
> > However I haven't managed to debug the application from within this
> Docker
> > container.
> >
> > I took the successfully built plug-in, and used it on my Fedora machine.
> > Again, it crashes in the same way.
> >
> >
> > On Thu, Jun 23, 2022 at 5:06 PM Alan Carvalho de Assis <
> acassis@gmail.com>
> > wrote:
> >
> >> Hi Fotis,
> >>
> >> I'm using Ubuntu 20.04 and I can confirm it is working fine, I don't
> >> need to add -fPIC.
> >>
> >> Please try a clear repository, I will do it here step-by-step on /tmp
> >> to removed after next reboot:
> >>
> >> $ cd /tmp/
> >> $ git clone https://github.com/apache/incubator-nuttx nuttx
> >> $ git clone https://github.com/apache/incubator-nuttx-apps apps
> >> $ cd nuttx/
> >> $ make -C tools -f Makefile.host all
> >> $ ls -l tools/jlink*
> >> -rwxrwxr-x 1 alan alan 17144 jun 23 11:02 tools/jlink-nuttx
> >> -rw-rw-r-- 1 alan alan 16804 jun 23 11:01 tools/jlink-nuttx.c
> >>
> >> I didn't test it with JLinkGDBServer, but at least I can tell you it
> >> is compiling fine.
> >>
> >> BR,
> >>
> >> Alan
> >>
> >> On 6/23/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> >> >> Ahhh, so it is your Fedora 36 issue, hahaha
> >> >
> >> > No, it is not.
> >> >
> >> > I just tried on Ubuntu 18, and I got the exact same result.
> >> >
> >> > Build fails with the same error. I added the -fPIC flag, and the build
> >> > succeeded.
> >> > Then I tried to debug the firmware with JLink and GDB crashes during
> >> > init
> >> > with a SEGFAULT.
> >> >
> >> > Just like on Fedora.
> >> >
> >> > So I guess, this is a problem with the plug-in itself?
> >> >
> >> > Those that have managed to use the plug-in successfully, what is the
> >> > version of JLinkGDBServer ?
> >> > Mine is V7.54c.
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > On Thu, Jun 23, 2022 at 1:50 AM Alan Carvalho de Assis <
> >> acassis@gmail.com>
> >> > wrote:
> >> >
> >> >> Ahhh, so it is your Fedora 36 issue, hahaha
> >> >>
> >> >> Here on Ubuntu "make -C tools -f Makefile.host all" works fine.
> >> >>
> >> >> It created the jlink-nuttx.so file.
> >> >>
> >> >> BR,
> >> >>
> >> >> Alan
> >> >>
> >> >> On 6/22/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> >> >> > Yes I enabled CONFIG_DEBUG_TCBINFO.
> >> >> > (When disabled, debugging works normally but without being
> >> >> > thread-aware).
> >> >> >
> >> >> > It seems that it is either a bug in the plugin itself, or something
> >> >> > is
> >> >> > wrong with my build.
> >> >> >
> >> >> > If it matters, I am using Fedora 36 with gcc (GCC) 12.1.1 20220507
> >> (Red
> >> >> Hat
> >> >> > 12.1.1-1)
> >> >> >
> >> >> > Maybe someone can provide me with a pre-build .so file to test if
> >> >> > this
> >> >> > is
> >> >> > the cause?
> >> >> >
> >> >> >
> >> >> >
> >> >> >
> >> >> > On Wed, Jun 22, 2022 at 10:30 PM Xiang Xiao <
> >> xiaoxiang781216@gmail.com>
> >> >> > wrote:
> >> >> >
> >> >> >> Did you enable CONFIG_DEBUG_TCBINFO in your defconfig:
> >> >> >> incubator-nuttx/Kconfig at master · apache/incubator-nuttx
> >> >> >> (github.com)
> >> >> >> <
> >> >>
> >>
> https://github.com/apache/incubator-nuttx/blob/master/Kconfig#L1857-L1863
> >> >> >> >
> >> >> >> The plugin needs the g_tcbinfo to know the critical offset of the
> >> >> >> field
> >> >> >> in
> >> >> >> tcb_s structure.
> >> >> >>
> >> >> >> On Thu, Jun 23, 2022 at 2:10 AM Fotis Panagiotopoulos
> >> >> >> <f.j.panag@gmail.com
> >> >> >> >
> >> >> >> wrote:
> >> >> >>
> >> >> >> > Hello,
> >> >> >> >
> >> >> >> > I am in need of debugging NuttX in a thread-aware fashion, as I
> >> >> >> > still
> >> >> >> hit a
> >> >> >> > dead-lock in networking that I haven't managed to track down
> yet.
> >> >> >> >
> >> >> >> > I am using a custom target, based on the STM32F427VI and JLink
> as
> >> >> >> > the
> >> >> >> > debugger.
> >> >> >> >
> >> >> >> > I see that there is a plug-in for JLink GDB that was added in
> >> #4810.
> >> >> >> > Unfortunately, I never got this working. I commented on the PR,
> >> >> >> > but
> >> >> >> > I
> >> >> >> > got
> >> >> >> > ignored.
> >> >> >> >
> >> >> >> > So:
> >> >> >> >
> >> >> >> > 1. I cannot build the plug-in.
> >> >> >> > Running:
> >> >> >> >
> >> >> >> > make -C tools -f Makefile.host all
> >> >> >> >
> >> >> >> > I get:
> >> >> >> >
> >> >> >> > /usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32 against
> >> >> >> > `.rodata.str1.8' can not be used when making a shared object;
> >> >> recompile
> >> >> >> > with -fPIC
> >> >> >> > collect2: error: ld returned 1 exit status
> >> >> >> > make: *** [Makefile.host:231: jlink-nuttx.so] Error 1
> >> >> >> >
> >> >> >> > I added the -fPIC option, and it was built successfully.
> >> >> >> > If this is actually the correct option, then I guess the
> makefile
> >> >> >> > has
> >> >> >> > to
> >> >> >> be
> >> >> >> > fixed?
> >> >> >> >
> >> >> >> >
> >> >> >> > 2. After building the plug-in with -fPIC, it crashes during
> start
> >> >> >> > with
> >> >> >> > a
> >> >> >> > segmentation fault.
> >> >> >> >
> >> >> >> > Here is an example output:
> >> >> >> > https://pastebin.com/U1tqtMND
> >> >> >> >
> >> >> >> >
> >> >> >> > Has anyone managed to use this?
> >> >> >> > Any idea what the fault may be?
> >> >> >> >
> >> >> >>
> >> >> >
> >> >>
> >> >
> >>
> >
>

Re: NuttX-aware debugging.

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Please describe all the steps you are doing and such way everybody can
reproduce yet (same way I did in previous email).

I don't think a library compile to Ubuntu will work on Fedora.

Xiang, do you have a documentation about the JLink integration? BTW,
any news about the guy/gal Xiaomi was contracting to write better
documentation to NuttX ?

BR,

Alan

On 6/23/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> I tried your instructions.
> The build fails on a clean repository too.
>
> I then tried a newer version of Ubuntu (as a Docker container, I do not
> have access to any other Ubuntu machines).
> This time the build succeeded.
>
> However I haven't managed to debug the application from within this Docker
> container.
>
> I took the successfully built plug-in, and used it on my Fedora machine.
> Again, it crashes in the same way.
>
>
> On Thu, Jun 23, 2022 at 5:06 PM Alan Carvalho de Assis <ac...@gmail.com>
> wrote:
>
>> Hi Fotis,
>>
>> I'm using Ubuntu 20.04 and I can confirm it is working fine, I don't
>> need to add -fPIC.
>>
>> Please try a clear repository, I will do it here step-by-step on /tmp
>> to removed after next reboot:
>>
>> $ cd /tmp/
>> $ git clone https://github.com/apache/incubator-nuttx nuttx
>> $ git clone https://github.com/apache/incubator-nuttx-apps apps
>> $ cd nuttx/
>> $ make -C tools -f Makefile.host all
>> $ ls -l tools/jlink*
>> -rwxrwxr-x 1 alan alan 17144 jun 23 11:02 tools/jlink-nuttx
>> -rw-rw-r-- 1 alan alan 16804 jun 23 11:01 tools/jlink-nuttx.c
>>
>> I didn't test it with JLinkGDBServer, but at least I can tell you it
>> is compiling fine.
>>
>> BR,
>>
>> Alan
>>
>> On 6/23/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
>> >> Ahhh, so it is your Fedora 36 issue, hahaha
>> >
>> > No, it is not.
>> >
>> > I just tried on Ubuntu 18, and I got the exact same result.
>> >
>> > Build fails with the same error. I added the -fPIC flag, and the build
>> > succeeded.
>> > Then I tried to debug the firmware with JLink and GDB crashes during
>> > init
>> > with a SEGFAULT.
>> >
>> > Just like on Fedora.
>> >
>> > So I guess, this is a problem with the plug-in itself?
>> >
>> > Those that have managed to use the plug-in successfully, what is the
>> > version of JLinkGDBServer ?
>> > Mine is V7.54c.
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > On Thu, Jun 23, 2022 at 1:50 AM Alan Carvalho de Assis <
>> acassis@gmail.com>
>> > wrote:
>> >
>> >> Ahhh, so it is your Fedora 36 issue, hahaha
>> >>
>> >> Here on Ubuntu "make -C tools -f Makefile.host all" works fine.
>> >>
>> >> It created the jlink-nuttx.so file.
>> >>
>> >> BR,
>> >>
>> >> Alan
>> >>
>> >> On 6/22/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
>> >> > Yes I enabled CONFIG_DEBUG_TCBINFO.
>> >> > (When disabled, debugging works normally but without being
>> >> > thread-aware).
>> >> >
>> >> > It seems that it is either a bug in the plugin itself, or something
>> >> > is
>> >> > wrong with my build.
>> >> >
>> >> > If it matters, I am using Fedora 36 with gcc (GCC) 12.1.1 20220507
>> (Red
>> >> Hat
>> >> > 12.1.1-1)
>> >> >
>> >> > Maybe someone can provide me with a pre-build .so file to test if
>> >> > this
>> >> > is
>> >> > the cause?
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > On Wed, Jun 22, 2022 at 10:30 PM Xiang Xiao <
>> xiaoxiang781216@gmail.com>
>> >> > wrote:
>> >> >
>> >> >> Did you enable CONFIG_DEBUG_TCBINFO in your defconfig:
>> >> >> incubator-nuttx/Kconfig at master · apache/incubator-nuttx
>> >> >> (github.com)
>> >> >> <
>> >>
>> https://github.com/apache/incubator-nuttx/blob/master/Kconfig#L1857-L1863
>> >> >> >
>> >> >> The plugin needs the g_tcbinfo to know the critical offset of the
>> >> >> field
>> >> >> in
>> >> >> tcb_s structure.
>> >> >>
>> >> >> On Thu, Jun 23, 2022 at 2:10 AM Fotis Panagiotopoulos
>> >> >> <f.j.panag@gmail.com
>> >> >> >
>> >> >> wrote:
>> >> >>
>> >> >> > Hello,
>> >> >> >
>> >> >> > I am in need of debugging NuttX in a thread-aware fashion, as I
>> >> >> > still
>> >> >> hit a
>> >> >> > dead-lock in networking that I haven't managed to track down yet.
>> >> >> >
>> >> >> > I am using a custom target, based on the STM32F427VI and JLink as
>> >> >> > the
>> >> >> > debugger.
>> >> >> >
>> >> >> > I see that there is a plug-in for JLink GDB that was added in
>> #4810.
>> >> >> > Unfortunately, I never got this working. I commented on the PR,
>> >> >> > but
>> >> >> > I
>> >> >> > got
>> >> >> > ignored.
>> >> >> >
>> >> >> > So:
>> >> >> >
>> >> >> > 1. I cannot build the plug-in.
>> >> >> > Running:
>> >> >> >
>> >> >> > make -C tools -f Makefile.host all
>> >> >> >
>> >> >> > I get:
>> >> >> >
>> >> >> > /usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32 against
>> >> >> > `.rodata.str1.8' can not be used when making a shared object;
>> >> recompile
>> >> >> > with -fPIC
>> >> >> > collect2: error: ld returned 1 exit status
>> >> >> > make: *** [Makefile.host:231: jlink-nuttx.so] Error 1
>> >> >> >
>> >> >> > I added the -fPIC option, and it was built successfully.
>> >> >> > If this is actually the correct option, then I guess the makefile
>> >> >> > has
>> >> >> > to
>> >> >> be
>> >> >> > fixed?
>> >> >> >
>> >> >> >
>> >> >> > 2. After building the plug-in with -fPIC, it crashes during start
>> >> >> > with
>> >> >> > a
>> >> >> > segmentation fault.
>> >> >> >
>> >> >> > Here is an example output:
>> >> >> > https://pastebin.com/U1tqtMND
>> >> >> >
>> >> >> >
>> >> >> > Has anyone managed to use this?
>> >> >> > Any idea what the fault may be?
>> >> >> >
>> >> >>
>> >> >
>> >>
>> >
>>
>

Re: NuttX-aware debugging.

Posted by Fotis Panagiotopoulos <f....@gmail.com>.
I tried your instructions.
The build fails on a clean repository too.

I then tried a newer version of Ubuntu (as a Docker container, I do not
have access to any other Ubuntu machines).
This time the build succeeded.

However I haven't managed to debug the application from within this Docker
container.

I took the successfully built plug-in, and used it on my Fedora machine.
Again, it crashes in the same way.


On Thu, Jun 23, 2022 at 5:06 PM Alan Carvalho de Assis <ac...@gmail.com>
wrote:

> Hi Fotis,
>
> I'm using Ubuntu 20.04 and I can confirm it is working fine, I don't
> need to add -fPIC.
>
> Please try a clear repository, I will do it here step-by-step on /tmp
> to removed after next reboot:
>
> $ cd /tmp/
> $ git clone https://github.com/apache/incubator-nuttx nuttx
> $ git clone https://github.com/apache/incubator-nuttx-apps apps
> $ cd nuttx/
> $ make -C tools -f Makefile.host all
> $ ls -l tools/jlink*
> -rwxrwxr-x 1 alan alan 17144 jun 23 11:02 tools/jlink-nuttx
> -rw-rw-r-- 1 alan alan 16804 jun 23 11:01 tools/jlink-nuttx.c
>
> I didn't test it with JLinkGDBServer, but at least I can tell you it
> is compiling fine.
>
> BR,
>
> Alan
>
> On 6/23/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> >> Ahhh, so it is your Fedora 36 issue, hahaha
> >
> > No, it is not.
> >
> > I just tried on Ubuntu 18, and I got the exact same result.
> >
> > Build fails with the same error. I added the -fPIC flag, and the build
> > succeeded.
> > Then I tried to debug the firmware with JLink and GDB crashes during init
> > with a SEGFAULT.
> >
> > Just like on Fedora.
> >
> > So I guess, this is a problem with the plug-in itself?
> >
> > Those that have managed to use the plug-in successfully, what is the
> > version of JLinkGDBServer ?
> > Mine is V7.54c.
> >
> >
> >
> >
> >
> >
> >
> >
> > On Thu, Jun 23, 2022 at 1:50 AM Alan Carvalho de Assis <
> acassis@gmail.com>
> > wrote:
> >
> >> Ahhh, so it is your Fedora 36 issue, hahaha
> >>
> >> Here on Ubuntu "make -C tools -f Makefile.host all" works fine.
> >>
> >> It created the jlink-nuttx.so file.
> >>
> >> BR,
> >>
> >> Alan
> >>
> >> On 6/22/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> >> > Yes I enabled CONFIG_DEBUG_TCBINFO.
> >> > (When disabled, debugging works normally but without being
> >> > thread-aware).
> >> >
> >> > It seems that it is either a bug in the plugin itself, or something is
> >> > wrong with my build.
> >> >
> >> > If it matters, I am using Fedora 36 with gcc (GCC) 12.1.1 20220507
> (Red
> >> Hat
> >> > 12.1.1-1)
> >> >
> >> > Maybe someone can provide me with a pre-build .so file to test if this
> >> > is
> >> > the cause?
> >> >
> >> >
> >> >
> >> >
> >> > On Wed, Jun 22, 2022 at 10:30 PM Xiang Xiao <
> xiaoxiang781216@gmail.com>
> >> > wrote:
> >> >
> >> >> Did you enable CONFIG_DEBUG_TCBINFO in your defconfig:
> >> >> incubator-nuttx/Kconfig at master · apache/incubator-nuttx
> >> >> (github.com)
> >> >> <
> >>
> https://github.com/apache/incubator-nuttx/blob/master/Kconfig#L1857-L1863
> >> >> >
> >> >> The plugin needs the g_tcbinfo to know the critical offset of the
> >> >> field
> >> >> in
> >> >> tcb_s structure.
> >> >>
> >> >> On Thu, Jun 23, 2022 at 2:10 AM Fotis Panagiotopoulos
> >> >> <f.j.panag@gmail.com
> >> >> >
> >> >> wrote:
> >> >>
> >> >> > Hello,
> >> >> >
> >> >> > I am in need of debugging NuttX in a thread-aware fashion, as I
> >> >> > still
> >> >> hit a
> >> >> > dead-lock in networking that I haven't managed to track down yet.
> >> >> >
> >> >> > I am using a custom target, based on the STM32F427VI and JLink as
> >> >> > the
> >> >> > debugger.
> >> >> >
> >> >> > I see that there is a plug-in for JLink GDB that was added in
> #4810.
> >> >> > Unfortunately, I never got this working. I commented on the PR, but
> >> >> > I
> >> >> > got
> >> >> > ignored.
> >> >> >
> >> >> > So:
> >> >> >
> >> >> > 1. I cannot build the plug-in.
> >> >> > Running:
> >> >> >
> >> >> > make -C tools -f Makefile.host all
> >> >> >
> >> >> > I get:
> >> >> >
> >> >> > /usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32 against
> >> >> > `.rodata.str1.8' can not be used when making a shared object;
> >> recompile
> >> >> > with -fPIC
> >> >> > collect2: error: ld returned 1 exit status
> >> >> > make: *** [Makefile.host:231: jlink-nuttx.so] Error 1
> >> >> >
> >> >> > I added the -fPIC option, and it was built successfully.
> >> >> > If this is actually the correct option, then I guess the makefile
> >> >> > has
> >> >> > to
> >> >> be
> >> >> > fixed?
> >> >> >
> >> >> >
> >> >> > 2. After building the plug-in with -fPIC, it crashes during start
> >> >> > with
> >> >> > a
> >> >> > segmentation fault.
> >> >> >
> >> >> > Here is an example output:
> >> >> > https://pastebin.com/U1tqtMND
> >> >> >
> >> >> >
> >> >> > Has anyone managed to use this?
> >> >> > Any idea what the fault may be?
> >> >> >
> >> >>
> >> >
> >>
> >
>

Re: NuttX-aware debugging.

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Hi Fotis,

I'm using Ubuntu 20.04 and I can confirm it is working fine, I don't
need to add -fPIC.

Please try a clear repository, I will do it here step-by-step on /tmp
to removed after next reboot:

$ cd /tmp/
$ git clone https://github.com/apache/incubator-nuttx nuttx
$ git clone https://github.com/apache/incubator-nuttx-apps apps
$ cd nuttx/
$ make -C tools -f Makefile.host all
$ ls -l tools/jlink*
-rwxrwxr-x 1 alan alan 17144 jun 23 11:02 tools/jlink-nuttx
-rw-rw-r-- 1 alan alan 16804 jun 23 11:01 tools/jlink-nuttx.c

I didn't test it with JLinkGDBServer, but at least I can tell you it
is compiling fine.

BR,

Alan

On 6/23/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
>> Ahhh, so it is your Fedora 36 issue, hahaha
>
> No, it is not.
>
> I just tried on Ubuntu 18, and I got the exact same result.
>
> Build fails with the same error. I added the -fPIC flag, and the build
> succeeded.
> Then I tried to debug the firmware with JLink and GDB crashes during init
> with a SEGFAULT.
>
> Just like on Fedora.
>
> So I guess, this is a problem with the plug-in itself?
>
> Those that have managed to use the plug-in successfully, what is the
> version of JLinkGDBServer ?
> Mine is V7.54c.
>
>
>
>
>
>
>
>
> On Thu, Jun 23, 2022 at 1:50 AM Alan Carvalho de Assis <ac...@gmail.com>
> wrote:
>
>> Ahhh, so it is your Fedora 36 issue, hahaha
>>
>> Here on Ubuntu "make -C tools -f Makefile.host all" works fine.
>>
>> It created the jlink-nuttx.so file.
>>
>> BR,
>>
>> Alan
>>
>> On 6/22/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
>> > Yes I enabled CONFIG_DEBUG_TCBINFO.
>> > (When disabled, debugging works normally but without being
>> > thread-aware).
>> >
>> > It seems that it is either a bug in the plugin itself, or something is
>> > wrong with my build.
>> >
>> > If it matters, I am using Fedora 36 with gcc (GCC) 12.1.1 20220507 (Red
>> Hat
>> > 12.1.1-1)
>> >
>> > Maybe someone can provide me with a pre-build .so file to test if this
>> > is
>> > the cause?
>> >
>> >
>> >
>> >
>> > On Wed, Jun 22, 2022 at 10:30 PM Xiang Xiao <xi...@gmail.com>
>> > wrote:
>> >
>> >> Did you enable CONFIG_DEBUG_TCBINFO in your defconfig:
>> >> incubator-nuttx/Kconfig at master · apache/incubator-nuttx
>> >> (github.com)
>> >> <
>> https://github.com/apache/incubator-nuttx/blob/master/Kconfig#L1857-L1863
>> >> >
>> >> The plugin needs the g_tcbinfo to know the critical offset of the
>> >> field
>> >> in
>> >> tcb_s structure.
>> >>
>> >> On Thu, Jun 23, 2022 at 2:10 AM Fotis Panagiotopoulos
>> >> <f.j.panag@gmail.com
>> >> >
>> >> wrote:
>> >>
>> >> > Hello,
>> >> >
>> >> > I am in need of debugging NuttX in a thread-aware fashion, as I
>> >> > still
>> >> hit a
>> >> > dead-lock in networking that I haven't managed to track down yet.
>> >> >
>> >> > I am using a custom target, based on the STM32F427VI and JLink as
>> >> > the
>> >> > debugger.
>> >> >
>> >> > I see that there is a plug-in for JLink GDB that was added in #4810.
>> >> > Unfortunately, I never got this working. I commented on the PR, but
>> >> > I
>> >> > got
>> >> > ignored.
>> >> >
>> >> > So:
>> >> >
>> >> > 1. I cannot build the plug-in.
>> >> > Running:
>> >> >
>> >> > make -C tools -f Makefile.host all
>> >> >
>> >> > I get:
>> >> >
>> >> > /usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32 against
>> >> > `.rodata.str1.8' can not be used when making a shared object;
>> recompile
>> >> > with -fPIC
>> >> > collect2: error: ld returned 1 exit status
>> >> > make: *** [Makefile.host:231: jlink-nuttx.so] Error 1
>> >> >
>> >> > I added the -fPIC option, and it was built successfully.
>> >> > If this is actually the correct option, then I guess the makefile
>> >> > has
>> >> > to
>> >> be
>> >> > fixed?
>> >> >
>> >> >
>> >> > 2. After building the plug-in with -fPIC, it crashes during start
>> >> > with
>> >> > a
>> >> > segmentation fault.
>> >> >
>> >> > Here is an example output:
>> >> > https://pastebin.com/U1tqtMND
>> >> >
>> >> >
>> >> > Has anyone managed to use this?
>> >> > Any idea what the fault may be?
>> >> >
>> >>
>> >
>>
>

Re: NuttX-aware debugging.

Posted by Fotis Panagiotopoulos <f....@gmail.com>.
> Ahhh, so it is your Fedora 36 issue, hahaha

No, it is not.

I just tried on Ubuntu 18, and I got the exact same result.

Build fails with the same error. I added the -fPIC flag, and the build
succeeded.
Then I tried to debug the firmware with JLink and GDB crashes during init
with a SEGFAULT.

Just like on Fedora.

So I guess, this is a problem with the plug-in itself?

Those that have managed to use the plug-in successfully, what is the
version of JLinkGDBServer ?
Mine is V7.54c.








On Thu, Jun 23, 2022 at 1:50 AM Alan Carvalho de Assis <ac...@gmail.com>
wrote:

> Ahhh, so it is your Fedora 36 issue, hahaha
>
> Here on Ubuntu "make -C tools -f Makefile.host all" works fine.
>
> It created the jlink-nuttx.so file.
>
> BR,
>
> Alan
>
> On 6/22/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> > Yes I enabled CONFIG_DEBUG_TCBINFO.
> > (When disabled, debugging works normally but without being thread-aware).
> >
> > It seems that it is either a bug in the plugin itself, or something is
> > wrong with my build.
> >
> > If it matters, I am using Fedora 36 with gcc (GCC) 12.1.1 20220507 (Red
> Hat
> > 12.1.1-1)
> >
> > Maybe someone can provide me with a pre-build .so file to test if this is
> > the cause?
> >
> >
> >
> >
> > On Wed, Jun 22, 2022 at 10:30 PM Xiang Xiao <xi...@gmail.com>
> > wrote:
> >
> >> Did you enable CONFIG_DEBUG_TCBINFO in your defconfig:
> >> incubator-nuttx/Kconfig at master · apache/incubator-nuttx (github.com)
> >> <
> https://github.com/apache/incubator-nuttx/blob/master/Kconfig#L1857-L1863
> >> >
> >> The plugin needs the g_tcbinfo to know the critical offset of the field
> >> in
> >> tcb_s structure.
> >>
> >> On Thu, Jun 23, 2022 at 2:10 AM Fotis Panagiotopoulos
> >> <f.j.panag@gmail.com
> >> >
> >> wrote:
> >>
> >> > Hello,
> >> >
> >> > I am in need of debugging NuttX in a thread-aware fashion, as I still
> >> hit a
> >> > dead-lock in networking that I haven't managed to track down yet.
> >> >
> >> > I am using a custom target, based on the STM32F427VI and JLink as the
> >> > debugger.
> >> >
> >> > I see that there is a plug-in for JLink GDB that was added in #4810.
> >> > Unfortunately, I never got this working. I commented on the PR, but I
> >> > got
> >> > ignored.
> >> >
> >> > So:
> >> >
> >> > 1. I cannot build the plug-in.
> >> > Running:
> >> >
> >> > make -C tools -f Makefile.host all
> >> >
> >> > I get:
> >> >
> >> > /usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32 against
> >> > `.rodata.str1.8' can not be used when making a shared object;
> recompile
> >> > with -fPIC
> >> > collect2: error: ld returned 1 exit status
> >> > make: *** [Makefile.host:231: jlink-nuttx.so] Error 1
> >> >
> >> > I added the -fPIC option, and it was built successfully.
> >> > If this is actually the correct option, then I guess the makefile has
> >> > to
> >> be
> >> > fixed?
> >> >
> >> >
> >> > 2. After building the plug-in with -fPIC, it crashes during start with
> >> > a
> >> > segmentation fault.
> >> >
> >> > Here is an example output:
> >> > https://pastebin.com/U1tqtMND
> >> >
> >> >
> >> > Has anyone managed to use this?
> >> > Any idea what the fault may be?
> >> >
> >>
> >
>

Re: NuttX-aware debugging.

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Ahhh, so it is your Fedora 36 issue, hahaha

Here on Ubuntu "make -C tools -f Makefile.host all" works fine.

It created the jlink-nuttx.so file.

BR,

Alan

On 6/22/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> Yes I enabled CONFIG_DEBUG_TCBINFO.
> (When disabled, debugging works normally but without being thread-aware).
>
> It seems that it is either a bug in the plugin itself, or something is
> wrong with my build.
>
> If it matters, I am using Fedora 36 with gcc (GCC) 12.1.1 20220507 (Red Hat
> 12.1.1-1)
>
> Maybe someone can provide me with a pre-build .so file to test if this is
> the cause?
>
>
>
>
> On Wed, Jun 22, 2022 at 10:30 PM Xiang Xiao <xi...@gmail.com>
> wrote:
>
>> Did you enable CONFIG_DEBUG_TCBINFO in your defconfig:
>> incubator-nuttx/Kconfig at master · apache/incubator-nuttx (github.com)
>> <https://github.com/apache/incubator-nuttx/blob/master/Kconfig#L1857-L1863
>> >
>> The plugin needs the g_tcbinfo to know the critical offset of the field
>> in
>> tcb_s structure.
>>
>> On Thu, Jun 23, 2022 at 2:10 AM Fotis Panagiotopoulos
>> <f.j.panag@gmail.com
>> >
>> wrote:
>>
>> > Hello,
>> >
>> > I am in need of debugging NuttX in a thread-aware fashion, as I still
>> hit a
>> > dead-lock in networking that I haven't managed to track down yet.
>> >
>> > I am using a custom target, based on the STM32F427VI and JLink as the
>> > debugger.
>> >
>> > I see that there is a plug-in for JLink GDB that was added in #4810.
>> > Unfortunately, I never got this working. I commented on the PR, but I
>> > got
>> > ignored.
>> >
>> > So:
>> >
>> > 1. I cannot build the plug-in.
>> > Running:
>> >
>> > make -C tools -f Makefile.host all
>> >
>> > I get:
>> >
>> > /usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32 against
>> > `.rodata.str1.8' can not be used when making a shared object; recompile
>> > with -fPIC
>> > collect2: error: ld returned 1 exit status
>> > make: *** [Makefile.host:231: jlink-nuttx.so] Error 1
>> >
>> > I added the -fPIC option, and it was built successfully.
>> > If this is actually the correct option, then I guess the makefile has
>> > to
>> be
>> > fixed?
>> >
>> >
>> > 2. After building the plug-in with -fPIC, it crashes during start with
>> > a
>> > segmentation fault.
>> >
>> > Here is an example output:
>> > https://pastebin.com/U1tqtMND
>> >
>> >
>> > Has anyone managed to use this?
>> > Any idea what the fault may be?
>> >
>>
>

Re: NuttX-aware debugging.

Posted by Abdelatif Guettouche <ab...@gmail.com>.
> 1) Using OpenOCD + GDB: some years ago Mr. Masayuki-san submitted
support to OpenOCD get thread awareness;

The current support in upstream OpenOCD is outdated.  If you want to
use OpenOCD maybe you can try building from
https://github.com/Ouss4/openocd-esp32/tree/nuttx
Although I focused on Xtensa and RISC-V and did very little testing on
ARM, most of the code is platform independent.

On Wed, Jun 22, 2022 at 11:37 PM Fotis Panagiotopoulos
<f....@gmail.com> wrote:
>
> Yes I enabled CONFIG_DEBUG_TCBINFO.
> (When disabled, debugging works normally but without being thread-aware).
>
> It seems that it is either a bug in the plugin itself, or something is
> wrong with my build.
>
> If it matters, I am using Fedora 36 with gcc (GCC) 12.1.1 20220507 (Red Hat
> 12.1.1-1)
>
> Maybe someone can provide me with a pre-build .so file to test if this is
> the cause?
>
>
>
>
> On Wed, Jun 22, 2022 at 10:30 PM Xiang Xiao <xi...@gmail.com>
> wrote:
>
> > Did you enable CONFIG_DEBUG_TCBINFO in your defconfig:
> > incubator-nuttx/Kconfig at master · apache/incubator-nuttx (github.com)
> > <https://github.com/apache/incubator-nuttx/blob/master/Kconfig#L1857-L1863
> > >
> > The plugin needs the g_tcbinfo to know the critical offset of the field in
> > tcb_s structure.
> >
> > On Thu, Jun 23, 2022 at 2:10 AM Fotis Panagiotopoulos <f.j.panag@gmail.com
> > >
> > wrote:
> >
> > > Hello,
> > >
> > > I am in need of debugging NuttX in a thread-aware fashion, as I still
> > hit a
> > > dead-lock in networking that I haven't managed to track down yet.
> > >
> > > I am using a custom target, based on the STM32F427VI and JLink as the
> > > debugger.
> > >
> > > I see that there is a plug-in for JLink GDB that was added in #4810.
> > > Unfortunately, I never got this working. I commented on the PR, but I got
> > > ignored.
> > >
> > > So:
> > >
> > > 1. I cannot build the plug-in.
> > > Running:
> > >
> > > make -C tools -f Makefile.host all
> > >
> > > I get:
> > >
> > > /usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32 against
> > > `.rodata.str1.8' can not be used when making a shared object; recompile
> > > with -fPIC
> > > collect2: error: ld returned 1 exit status
> > > make: *** [Makefile.host:231: jlink-nuttx.so] Error 1
> > >
> > > I added the -fPIC option, and it was built successfully.
> > > If this is actually the correct option, then I guess the makefile has to
> > be
> > > fixed?
> > >
> > >
> > > 2. After building the plug-in with -fPIC, it crashes during start with a
> > > segmentation fault.
> > >
> > > Here is an example output:
> > > https://pastebin.com/U1tqtMND
> > >
> > >
> > > Has anyone managed to use this?
> > > Any idea what the fault may be?
> > >
> >

Re: NuttX-aware debugging.

Posted by Fotis Panagiotopoulos <f....@gmail.com>.
Yes I enabled CONFIG_DEBUG_TCBINFO.
(When disabled, debugging works normally but without being thread-aware).

It seems that it is either a bug in the plugin itself, or something is
wrong with my build.

If it matters, I am using Fedora 36 with gcc (GCC) 12.1.1 20220507 (Red Hat
12.1.1-1)

Maybe someone can provide me with a pre-build .so file to test if this is
the cause?




On Wed, Jun 22, 2022 at 10:30 PM Xiang Xiao <xi...@gmail.com>
wrote:

> Did you enable CONFIG_DEBUG_TCBINFO in your defconfig:
> incubator-nuttx/Kconfig at master · apache/incubator-nuttx (github.com)
> <https://github.com/apache/incubator-nuttx/blob/master/Kconfig#L1857-L1863
> >
> The plugin needs the g_tcbinfo to know the critical offset of the field in
> tcb_s structure.
>
> On Thu, Jun 23, 2022 at 2:10 AM Fotis Panagiotopoulos <f.j.panag@gmail.com
> >
> wrote:
>
> > Hello,
> >
> > I am in need of debugging NuttX in a thread-aware fashion, as I still
> hit a
> > dead-lock in networking that I haven't managed to track down yet.
> >
> > I am using a custom target, based on the STM32F427VI and JLink as the
> > debugger.
> >
> > I see that there is a plug-in for JLink GDB that was added in #4810.
> > Unfortunately, I never got this working. I commented on the PR, but I got
> > ignored.
> >
> > So:
> >
> > 1. I cannot build the plug-in.
> > Running:
> >
> > make -C tools -f Makefile.host all
> >
> > I get:
> >
> > /usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32 against
> > `.rodata.str1.8' can not be used when making a shared object; recompile
> > with -fPIC
> > collect2: error: ld returned 1 exit status
> > make: *** [Makefile.host:231: jlink-nuttx.so] Error 1
> >
> > I added the -fPIC option, and it was built successfully.
> > If this is actually the correct option, then I guess the makefile has to
> be
> > fixed?
> >
> >
> > 2. After building the plug-in with -fPIC, it crashes during start with a
> > segmentation fault.
> >
> > Here is an example output:
> > https://pastebin.com/U1tqtMND
> >
> >
> > Has anyone managed to use this?
> > Any idea what the fault may be?
> >
>

Re: NuttX-aware debugging.

Posted by Xiang Xiao <xi...@gmail.com>.
Did you enable CONFIG_DEBUG_TCBINFO in your defconfig:
incubator-nuttx/Kconfig at master · apache/incubator-nuttx (github.com)
<https://github.com/apache/incubator-nuttx/blob/master/Kconfig#L1857-L1863>
The plugin needs the g_tcbinfo to know the critical offset of the field in
tcb_s structure.

On Thu, Jun 23, 2022 at 2:10 AM Fotis Panagiotopoulos <f....@gmail.com>
wrote:

> Hello,
>
> I am in need of debugging NuttX in a thread-aware fashion, as I still hit a
> dead-lock in networking that I haven't managed to track down yet.
>
> I am using a custom target, based on the STM32F427VI and JLink as the
> debugger.
>
> I see that there is a plug-in for JLink GDB that was added in #4810.
> Unfortunately, I never got this working. I commented on the PR, but I got
> ignored.
>
> So:
>
> 1. I cannot build the plug-in.
> Running:
>
> make -C tools -f Makefile.host all
>
> I get:
>
> /usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32 against
> `.rodata.str1.8' can not be used when making a shared object; recompile
> with -fPIC
> collect2: error: ld returned 1 exit status
> make: *** [Makefile.host:231: jlink-nuttx.so] Error 1
>
> I added the -fPIC option, and it was built successfully.
> If this is actually the correct option, then I guess the makefile has to be
> fixed?
>
>
> 2. After building the plug-in with -fPIC, it crashes during start with a
> segmentation fault.
>
> Here is an example output:
> https://pastebin.com/U1tqtMND
>
>
> Has anyone managed to use this?
> Any idea what the fault may be?
>

Re: NuttX-aware debugging.

Posted by Alan Carvalho de Assis <ac...@gmail.com>.
Hi Fotis,

There are two (at least) options to debug NuttX with Thread awareness:

1) Using OpenOCD + GDB: some years ago Mr. Masayuki-san submitted
support to OpenOCD get thread awareness;

2) Using Segger JLink + GDB: this is the option you are trying. I
think we don't have a documentation to it yet. I never tried it, but
Mr. Xiang used and he included the support on NuttX.

(N.B.: there is also ORBTrace tool that people can use with NuttX to
get thread awareness, our friend Dave Marples said it is available,
see: https://discord.com/channels/716091708336504884/716091708819111959
, last NuttX Online Workshop he also presented about it, the video is
available at NuttX Channel on YouTube)

I only used option 1 until now, you can find some old thread about it:

https://lists.apache.org/thread/hzx8wfh178j6hzfnb1qfpxmv5c8qb2xm

BR,

Alan

On 6/22/22, Fotis Panagiotopoulos <f....@gmail.com> wrote:
> Hello,
>
> I am in need of debugging NuttX in a thread-aware fashion, as I still hit a
> dead-lock in networking that I haven't managed to track down yet.
>
> I am using a custom target, based on the STM32F427VI and JLink as the
> debugger.
>
> I see that there is a plug-in for JLink GDB that was added in #4810.
> Unfortunately, I never got this working. I commented on the PR, but I got
> ignored.
>
> So:
>
> 1. I cannot build the plug-in.
> Running:
>
> make -C tools -f Makefile.host all
>
> I get:
>
> /usr/bin/ld: /tmp/cclxEqhk.o: relocation R_X86_64_32 against
> `.rodata.str1.8' can not be used when making a shared object; recompile
> with -fPIC
> collect2: error: ld returned 1 exit status
> make: *** [Makefile.host:231: jlink-nuttx.so] Error 1
>
> I added the -fPIC option, and it was built successfully.
> If this is actually the correct option, then I guess the makefile has to be
> fixed?
>
>
> 2. After building the plug-in with -fPIC, it crashes during start with a
> segmentation fault.
>
> Here is an example output:
> https://pastebin.com/U1tqtMND
>
>
> Has anyone managed to use this?
> Any idea what the fault may be?
>