how to debug gdb?

Tomasz Gajewski tomga at wp.pl
Fri May 7 00:57:42 CEST 2021


Hi Christian,

>> can you somehow reproduce the problem with the gdb monitor test which
>> is used by gdb_monitor.run? This test also creates a pthread and the
>> breakpoint in 'test_thread_start()' appears to work as well as the
>> appearance in the thread info list.
>
> I'll experiment in the evening, compare bahavior and let know
> results. Your answer is encouraging. Thanks.

I checked and there are two things that led me to wrong conclusions.

First is that executing just 'pthread_create' under debugger does not
cause newly created thread to appear in output of 'info thread'. There
has to be something that is needed to execute asynchronously but since
program is stopped it does not happen.

Second is that I tried to put a breakpoint in function passed to
'pthread_create' and debugger never made it to stop on that
breakpoint. I also added some 'Genode::log' in this function but
received no output from it. That is why I had doubts about state of
threads support in 'gdb_monitor'.


Generally, I'm trying to run 'ssh_terminal' under 'gdb_monitor' and my
current state is published in my branch [1].

[1] https://github.com/tomga/genode/tree/gdb_ssh_terminal

After information that threads should not be a problem I checked again
and wrote quite some text about that probably I messed up something with
service routing that causes 'ssh_terminal' to hang in a call to announce
'Terminal' service in 'main.cc'. Later I removed what I wrote after
checking one idea that occured to be true - there are two 'asynchronous'
operations that 'gdb_monitor' intercepts quickly one after another:

 * pthread create
 * service announce

and it seems that if they are executed too quickly by debugged program
then there is a hang.

Adding a busy loop (for few seconds) before service announcement lets
'ssh_terminal' to go further, so it seems that it is a bug in
gdb_monitor.

I pushed additional commit that workarounds the hang problem, so it
should be easily testable.

Christian, can you confirm - given your knowledge about 'gdb_monitor'
internals - that a bug in it that reveals in such scenerio is possible?

Regards
Tomasz



More information about the users mailing list