public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/6] Refinement of scheduler-locking settings
@ 2023-12-29 10:41 Natalia Saiapova
  2023-12-29 10:41 ` [PATCH 1/6] gdb: use schedlock_applies in user_visible_resume_ptid Natalia Saiapova
                   ` (5 more replies)
  0 siblings, 6 replies; 13+ messages in thread
From: Natalia Saiapova @ 2023-12-29 10:41 UTC (permalink / raw)
  To: gdb-patches; +Cc: tankut.baris.aktemur

Hi all,

I want to come back to the topic I raised a few years ago about the
scheduler locking during the inferior calls.

For the history, here are the links to the previous threads:

https://sourceware.org/pipermail/gdb/2019-June/047996.html
https://sourceware.org/pipermail/gdb/2019-July/048003.html

> In multithreaded program, when several threads are stopped at a
> breakpoint and
> scheduler-locking mode is not 'on', there might be unexpected thread
> switches
> during an inferior call evaluation. If such thread switching occurs,
> the evaluation of the inferior call is abandoned:
> 
> ~~~
> (gdb) run
> Thread 1 "a.out" hit Breakpoint 2, main._omp_fn.0(void) () at
> multi-omp.cpp:18
> 18                                         std::cout <<
> omp_get_thread_num();
> (gdb) call do_something()
> [Switching to Thread 0x7ffff6327700 (LWP 32498)]
> 
> Thread 3 "a.out" hit Breakpoint 2, main._omp_fn.0(void) () at
> multi-omp.cpp:18
> 18                                         std::cout <<
> omp_get_thread_num();
> The program stopped in another thread while making a function call
> from GDB.
> Evaluation of the expression containing the function
> (do_something()) will be abandoned.
> When the function is done executing, GDB will silently stop.
> ~~~

The problem is that only scheduler-locking "on" can lock the scheduler
for inferior calls, which is quite restrictive for debugging.
A possible solution would be to add a new option, e.g., "eval", to the
existing "set scheduler-locking", but this might often be used
together with the "step" option, so a user would need to always remember
to switch the scheduler-locking to the correct option.

I chose a different and a more invasive direction and prepared a set of patches 
that introduce a finer control over the scheduler locking.  With that, a user
can choose for which types of commands the scheduler should be locked and mix
different locking strategies together.  For the moment, I distinguish two modes
(normal and replay) and three command types (continuing, stepping, and inferior
call evaluation).  This way, we can lock the scheduler during the stepping and
inferior calls, but leave it unlocked for "continue".

I tried to be backwards compatible, so all existing scheduler-locking
settings are expected to be preserved, however, the "show" commands had
to be changed.

I will be happy to hear your opinion on the proposed change to the
scheduler locking interface!

Regards
Natalia

My base commit is 
3bb1944a5a0 asan: buffer overflow in loongarch_elf_rtype_to_howto

Natalia Saiapova (6):
  gdb: use schedlock_applies in user_visible_resume_ptid.
  gdb, cli: remove left-over code from "set_logging_on".
  gdb, cli: pass the argument of a set command to its callback.
  gdb: change the internal representation of scheduler locking.
  gdb: add commands to control scheduler locking.
  gdb: add eval option to lock the scheduler during infcalls.

 gdb/NEWS                                      |  21 +
 gdb/cli/cli-logging.c                         |   5 -
 gdb/cli/cli-setshow.c                         |   2 +-
 gdb/doc/gdb.texinfo                           |  68 ++-
 gdb/infrun.c                                  | 410 +++++++++++++++---
 .../gdb.mi/user-selected-context-sync.exp     |  22 +-
 .../gdb.threads/hand-call-in-threads.exp      |   8 +-
 .../multiple-successive-infcall.exp           |   5 +-
 gdb/testsuite/gdb.threads/schedlock.exp       | 103 ++++-
 gdb/testsuite/lib/gdb.exp                     |  57 ++-
 10 files changed, 580 insertions(+), 121 deletions(-)

-- 
2.25.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-02-08 18:50 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-29 10:41 [PATCH 0/6] Refinement of scheduler-locking settings Natalia Saiapova
2023-12-29 10:41 ` [PATCH 1/6] gdb: use schedlock_applies in user_visible_resume_ptid Natalia Saiapova
2024-02-08 18:50   ` Tom Tromey
2023-12-29 10:41 ` [PATCH 2/6] gdb, cli: remove left-over code from "set_logging_on" Natalia Saiapova
2024-02-08 18:50   ` Tom Tromey
2023-12-29 10:41 ` [PATCH 3/6] gdb, cli: pass the argument of a set command to its callback Natalia Saiapova
2024-02-08 18:45   ` Tom Tromey
2023-12-29 10:42 ` [PATCH 4/6] gdb: change the internal representation of scheduler locking Natalia Saiapova
2023-12-29 11:49   ` Eli Zaretskii
2023-12-29 10:42 ` [PATCH 5/6] gdb: add commands to control " Natalia Saiapova
2023-12-29 12:03   ` Eli Zaretskii
2023-12-29 10:42 ` [PATCH 6/6] gdb: add eval option to lock the scheduler during infcalls Natalia Saiapova
2023-12-29 12:06   ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).