[PATCH v3 0/1] PR20684, preserve user selected context when invoking MI commands

Jan Vrany jan.vrany@labware.com
Thu Jan 27 14:50:10 GMT 2022


This is a next version of the patch fixing some regression

Changes since previous iteration [1]:

* updates to accomodate new C++ification of MI commands pushed in
December last year.
* updates to handle cases pointed out by Simon
* add testcase

Changes since v1:

* address Simon's comments [2]
* add more tests for -stack-select-frame

Changes since v2:

Fix regression in mi-nonstop.exp and mi-nsthrexec.exp. This
was caused by extra user selected thread notification being sent
when resuming a thread like:

 -exec-continue --thread 2

The culprit was this part of mi_excecute_command ():

         else if (inferior_ptid != null_ptid)
           {
             struct thread_info *ti = inferior_thread ();

             report_change = (ti->global_num != command->thread);
           }

This "else" is only executed when command specifies --thread.

Imagine currently selected thread is thread 1 and -exec-continue --thread 2
is issued.

BEFORE applying this patch, no change would be reported because mi_cmd_execute ()
would switch the thread to thread 2 so `ti->global_num != command->thread` would
be false.

AFTER appling this patch, mi_cmd_execute () would switch the thread *and then restore*
back so `ti->global_num != command->thread` would be true.

Therefore I removed this whole `else if` branch: since mi_cmd_execute () now restores
the thread if --thread is passed (except few limited commands that notify themselves),
this condition would hold each time thread passed to --thread is different than current
thread. Removing it preserves the behavior.

Removing that "else if" branch allowed me to merge two nested ifs into one to (hopefully)
make the code simpler.

Thanks!

Jan


[1]: https://sourceware.org/pipermail/gdb-patches/2021-February/175897.html


Jan Vrany (1):
  gdb/mi: PR20684, preserve user selected thread and frame when invoking
    MI commands

 gdb/mi/mi-cmds.h                             |  12 ++
 gdb/mi/mi-main.c                             |  54 ++++---
 gdb/testsuite/gdb.mi/mi-cmd-user-context.exp | 155 +++++++++++++++++++
 3 files changed, 198 insertions(+), 23 deletions(-)
 create mode 100644 gdb/testsuite/gdb.mi/mi-cmd-user-context.exp

-- 
2.30.2



More information about the Gdb-patches mailing list