public inbox for gdb-testers@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb/gdb-7.12-branch] Fix a few gdb.base/jit-simple.exp problems
@ 2016-10-06 13:25 sergiodj+buildbot
  2016-10-06 13:25 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
                   ` (14 more replies)
  0 siblings, 15 replies; 33+ messages in thread
From: sergiodj+buildbot @ 2016-10-06 13:25 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT e027976f02ce8ed4cf0da79238226c03a640f2b3 ***

Author: Pedro Alves <palves@redhat.com>
Branch: gdb-7.12-branch
Commit: e027976f02ce8ed4cf0da79238226c03a640f2b3

Fix a few gdb.base/jit-simple.exp problems

I noticed that we sometimes get this:

  (gdb) print &__jit_debug_descriptor
  $1 = (struct jit_descriptor *) 0x601040 <__jit_debug_descriptor>
  (gdb) PASS: gdb.base/jit-simple.exp: blah 1
  [...]
  (gdb) run
  [...]
  Starting program: build/gdb/testsuite/outputs/gdb.base/jit-simple/jit-simple
  Unsupported JIT protocol version 4 in descriptor (expected 1)

  Breakpoint 2, main () at src/gdb/testsuite/gdb.base/jit-simple.c:36
  36        return 0;
  (gdb) print &__jit_debug_descriptor
  $2 = (struct jit_descriptor *) 0x601040 <__jit_debug_descriptor>
  (gdb) PASS: gdb.base/jit-simple.exp: blah 1

All tests PASSed, but note the "Unsupported JIT protocol version 4"
message.

Also notice that "__jit_debug_descriptor" has the same address before
and after the rerun, while the test is built in a way that should make
that address change between runs.

The test doesn't catch any of this because it doesn't compare
before/after addresses.

And then notice the "blah 1" test messages.  "blah" is clearly a WIP
message, but it should be at least "blah 2" the second time.  :-)

The reason this sometimes happens is that the test recompiles the
program and expects gdb to reload it automaticallyt on "run".  However,
if the original program and the new recompilation happen to be in the
same second, then gdb does not realize that the binary needs to be
reloaded.  (This is an old problem out of scope of this series.)  If
that happens, then GDB ends up using the wrong symbols for the program
that it spawns, reads the JIT descriptor out of the wrong address,
finds garbage, and prints that "unsupported version" notice.

Fix that in the same way gdb.base/reread.exp handles it -- by sleeping
one second before recompiling.

gdb/testsuite/ChangeLog:
2016-10-06  Pedro Alves  <palves@redhat.com>

	* gdb.base/jit-simple.exp (top level) Delete get_compiler_info
	call.
	(jit_run): Delete.
	(jit_test_reread): Use with_test_prefix.  Reload the main binary
	explicitly.  Compare the before/after addresses of the JIT
	descriptor.


^ permalink raw reply	[flat|nested] 33+ messages in thread
* [binutils-gdb/gdb-7.12-branch] Fix longjmp across readline w/ --enable-sjlj-exceptions toolchains
@ 2016-12-20 17:36 sergiodj+buildbot
  2016-12-20 18:17 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
  0 siblings, 1 reply; 33+ messages in thread
From: sergiodj+buildbot @ 2016-12-20 17:36 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT ada8ff522ce970e11dae4a3463c899b64e6f5006 ***

Author: Pedro Alves <palves@redhat.com>
Branch: gdb-7.12-branch
Commit: ada8ff522ce970e11dae4a3463c899b64e6f5006

Fix longjmp across readline w/ --enable-sjlj-exceptions toolchains

Nowadays, GDB propagates C++ exceptions across readline using
setjmp/longjmp 89525768cd08 ("Propagate GDB/C++ exceptions across
readline using sj/lj-based TRY/CATCH") because DWARF-based unwinding
can't cross C functions compiled without -fexceptions (see details
from the commit above).

Unfortunately, toolchains that use SjLj-based C++ exceptions got
broken with that fix, because _Unwind_SjLj_Unregister, which is put at
the exit of a function, is not executed due to the longjmp added by
that commit.

 (gdb) [New Thread 2936.0xb80]
 kill

 Thread 1 received signal SIGSEGV, Segmentation fault.
 0x03ff662b in ?? ()
 top?bt 15
 #0  0x03ff662b in ?? ()
 #1  0x00526b92 in stdin_event_handler (error=0, client_data=0x172ed8)
    at ../../binutils-gdb/gdb/event-top.c:555
 #2  0x00525a94 in handle_file_event (ready_mask=<optimized out>,
    file_ptr=0x3ff5cb8) at ../../binutils-gdb/gdb/event-loop.c:733
 #3  gdb_wait_for_event (block=block@entry=1)
    at ../../binutils-gdb/gdb/event-loop.c:884
 #4  0x00525bfb in gdb_do_one_event ()
    at ../../binutils-gdb/gdb/event-loop.c:347
 #5  0x00525ce5 in start_event_loop ()
    at ../../binutils-gdb/gdb/event-loop.c:371
 #6  0x0051fada in captured_command_loop (data=0x0)
    at ../../binutils-gdb/gdb/main.c:324
 #7  0x0051cf5d in catch_errors (
    func=func@entry=0x51fab0 <captured_command_loop(void*)>,
    func_args=func_args@entry=0x0,
    errstring=errstring@entry=0x7922bf <VEC_interp_factory_p_quick_push(VEC_inte rp_factory_p*, interp_factory*, char const*, unsigned int)::__PRETTY_FUNCTION__+351> "", mask=mask@entry=RETURN_MASK_ALL)
    at ../../binutils-gdb/gdb/exceptions.c:236
 #8  0x00520f0c in captured_main (data=0x328feb4)
    at ../../binutils-gdb/gdb/main.c:1149
 #9  gdb_main (args=args@entry=0x328feb4) at ../../binutils-gdb/gdb/main.c:1159
 #10 0x0071e400 in main (argc=1, argv=0x171220)
    at ../../binutils-gdb/gdb/gdb.c:32

Fix this by making the functions involved in setjmp/longjmp as
noexcept, so that the compiler knows it doesn't need to emit the
_Unwind_SjLj_Register / _Unwind_SjLj_Unregister calls for C++
exceptions.

Tested on x86_64 Fedora 23 with:
 - GCC 5.3.1 w/ DWARF-based exceptions.
 - GCC 7 built with --enable-sjlj-exceptions.

gdb/ChangeLog:
2016-12-20  Pedro Alves  <palves@redhat.com>
	    Yao Qi  <yao.qi@linaro.org>

	PR gdb/20977
	* event-top.c (gdb_rl_callback_read_char_wrapper_noexcept): New
	noexcept function, factored out from ...
	(gdb_rl_callback_read_char_wrapper): ... this.
	(gdb_rl_callback_handler): Mark noexcept.


^ permalink raw reply	[flat|nested] 33+ messages in thread
* [binutils-gdb/gdb-7.12-branch] mips-tdep: Make FCRs always 32-bit
@ 2016-10-06 19:26 sergiodj+buildbot
  2016-10-06 19:26 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
  2016-10-06 21:19 ` sergiodj+buildbot
  0 siblings, 2 replies; 33+ messages in thread
From: sergiodj+buildbot @ 2016-10-06 19:26 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT 1ce1f6debf17be7a5121efa0684f0ec1449f8fc4 ***

Author: Maciej W. Rozycki <macro@imgtec.com>
Branch: gdb-7.12-branch
Commit: 1ce1f6debf17be7a5121efa0684f0ec1449f8fc4

mips-tdep: Make FCRs always 32-bit

Fix a regression from commit f8b73d13b7ca ("Target-described register
support for MIPS"),
<https://sourceware.org/ml/gdb-patches/2007-05/msg00340.html>,
<https://sourceware.org/ml/gdb-patches/2007-06/msg00256.html>, which
caused Floating Point Control Registers (FCRs) to be shown as 64-bit
with 64-bit targets.

This came from the legacy register format where all raw registers
matched the width of the architecture regardless of their actual size.
The correct size was then set in `mips_register_type' for cooked
registers presented to the user, which in the case of FCRs meant the
cooked size was always forced to 32 bits, reflecting their actual
hardware size, even though the raw format carried them in 64-bit
quantities on 64-bit targets.  The upper 32 bits carried in the raw FCR
format have always been don't-cares, not actually retrieved from
hardware and never written back.

With the introduction of XML register descriptions the layout of
previously defined raw registers has been preserved, so as to keep
existing register handling code unchanged and make it easier for GDB and
`gdbserver' to interact with each other whether neither, either or both
parties talking over RSP support XML register descriptions.  For the
XML-described case however `mips_register_type' is not used in raw to
cooked register conversion, so any special cases coded there are not
taken into account.

Instead a new function, `mips_pseudo_register_type', has been introduced
to handle size conversion, however lacking the special case for FCRs for
the Linux and the now defunct IRIX target.  The correct size has been
maintained for embedded targets however, due to the bundling of FCRs
with the embedded registers under the `rawnum >= MIPS_EMBED_FP0_REGNUM +
32' condition.

Add the missing case to `mips_pseudo_register_type' then, referring to
the FCR indices explicitly, and observing that between
`MIPS_EMBED_FP0_REGNUM + 32' and `MIPS_FIRST_EMBED_REGNUM' there is an
unused register slot whose contents are ignored so with the removal of
embedded FCRs from under that condition we don't have to care about it
and we can refer to the embedded registers starting from
MIPS_FIRST_EMBED_REGNUM instead.

Add a test case too so that we have means to check automatically that
the correct user-visible size of FCRs is maintained.

	gdb/
	* mips-tdep.c (mips_pseudo_register_type): Make FCRs always
	32-bit.

	gdb/testsuite/
	* gdb.arch/mips-fcr.exp: New test.
	* gdb.arch/mips-fcr.c: Source for the new test.
(cherry picked from commit 78b86327b5301231005b08a7c589b2b58e6b4322)


^ permalink raw reply	[flat|nested] 33+ messages in thread
* [binutils-gdb/gdb-7.12-branch] mips-tdep: Rearrange comments in `mips_pseudo_register_type'
@ 2016-10-06 19:23 sergiodj+buildbot
  2016-10-06 19:23 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
  2016-10-06 20:37 ` sergiodj+buildbot
  0 siblings, 2 replies; 33+ messages in thread
From: sergiodj+buildbot @ 2016-10-06 19:23 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT f92cb42932ec343d328f7dbd54d9ca5b542e322e ***

Author: Maciej W. Rozycki <macro@imgtec.com>
Branch: gdb-7.12-branch
Commit: f92cb42932ec343d328f7dbd54d9ca5b542e322e

mips-tdep: Rearrange comments in `mips_pseudo_register_type'

Rearrange comments throughout `mips_pseudo_register_type', placing them
ahead the condtionals they apply to consistently.

	gdb/
	* mips-tdep.c (mips_pseudo_register_type): Rearrange comments
	throughout.
(cherry picked from commit a6912260f813b1493efefd27cbcb6a73d933accc)


^ permalink raw reply	[flat|nested] 33+ messages in thread
* [binutils-gdb/gdb-7.12-branch] testsuite: solib-disc: Use `standard_output_file'
@ 2016-10-06 19:21 sergiodj+buildbot
  2016-10-06 19:21 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
  2016-10-06 19:54 ` sergiodj+buildbot
  0 siblings, 2 replies; 33+ messages in thread
From: sergiodj+buildbot @ 2016-10-06 19:21 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT 8ff5432c0c9912efc43f92837243aecfcf1c1098 ***

Author: Maciej W. Rozycki <macro@imgtec.com>
Branch: gdb-7.12-branch
Commit: 8ff5432c0c9912efc43f92837243aecfcf1c1098

testsuite: solib-disc: Use `standard_output_file'

Correct a commit 2151ccc56c74 ("Always organize test artifacts in a
directory hierarchy") regression causing:

Running .../gdb/testsuite/gdb.base/solib-disc.exp ...
gdb compile failed, Assembler messages:
Fatal error: can't create .../gdb/testsuite/gdb.base/so-disc-shr.c.o: No such file or directory

by using `standard_output_file' to construct output file names
throughout.

	gdb/testsuite/
	* gdb.base/solib-disc.exp: Use `standard_output_file'
	throughout.
(cherry picked from commit 7470adbb872d5363580eb5e0a8dbb231c286ee4c)


^ permalink raw reply	[flat|nested] 33+ messages in thread
* [binutils-gdb/gdb-7.12-branch] stack: fix gdb.dwarf2/dw2-undefined-ret-addr.exp regression
@ 2016-10-06 15:41 sergiodj+buildbot
  2016-10-06 16:08 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
  2016-10-06 16:10 ` sergiodj+buildbot
  0 siblings, 2 replies; 33+ messages in thread
From: sergiodj+buildbot @ 2016-10-06 15:41 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT 3929b7e909b48a20d5dac6631e519f3b6b2ac84e ***

Author: Markus Metzger <markus.t.metzger@intel.com>
Branch: gdb-7.12-branch
Commit: 3929b7e909b48a20d5dac6631e519f3b6b2ac84e

stack: fix gdb.dwarf2/dw2-undefined-ret-addr.exp regression

Commit a038fa3e14a4 stack: check frame_unwind_caller_id adds a frame_id check to
frame_info and treats a missing frame_id as NOT_AVAILABLE_ERROR.  This causes a
regression in gdb.dwarf2/dw2-undefined-ret-addr.exp.

Treat a missing frame_id as OPTIMIZED_OUT_ERROR instead.

See also https://sourceware.org/ml/gdb-patches/2016-07/msg00273.html.


^ permalink raw reply	[flat|nested] 33+ messages in thread
* [binutils-gdb/gdb-7.12-branch] Fix PR11094: JIT breakpoint is not properly recreated on reruns
@ 2016-10-06 13:29 sergiodj+buildbot
  2016-10-06 13:29 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
  2016-10-06 14:35 ` sergiodj+buildbot
  0 siblings, 2 replies; 33+ messages in thread
From: sergiodj+buildbot @ 2016-10-06 13:29 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT f8da6fe399c8dafa98e7dbed36d3562a919768f5 ***

Author: Pedro Alves <palves@redhat.com>
Branch: gdb-7.12-branch
Commit: f8da6fe399c8dafa98e7dbed36d3562a919768f5

Fix PR11094: JIT breakpoint is not properly recreated on reruns

Even though this was supposedly in the gdb 7.2 timeframe, the testcase
in PR11094 crashes current GDB with a segfault:

  Program received signal SIGSEGV, Segmentation fault.
  0x00000000005ee894 in event_location_to_string (location=0x0) at
  src/gdb/location.c:412
  412       if (EL_STRING (location) == NULL)
  (top-gdb) bt
  #0  0x00000000005ee894 in event_location_to_string (location=0x0) at
  src/gdb/location.c:412
  #1  0x000000000057411a in print_breakpoint_location (b=0x18288e0, loc=0x0) at
  src/gdb/breakpoint.c:6201
  #2  0x000000000057483f in print_one_breakpoint_location (b=0x18288e0,
  loc=0x182cf10, loc_number=0, last_loc=0x7fffffffd258, allflag=1)
      at src/gdb/breakpoint.c:6473
  #3  0x00000000005751e1 in print_one_breakpoint (b=0x18288e0,
  last_loc=0x7fffffffd258, allflag=1) at
  src/gdb/breakpoint.c:6707
  #4  0x000000000057589c in breakpoint_1 (args=0x0, allflag=1, filter=0x0) at
  src/gdb/breakpoint.c:6947
  #5  0x0000000000575aa8 in maintenance_info_breakpoints (args=0x0, from_tty=0)
  at src/gdb/breakpoint.c:7026
  [...]

This is GDB trying to print the location spec of the JIT event
breakpoint, but that's an internal breakpoint without one.

If I add a NULL check, then we see that the JIT breakpoint is now
pending (because its location has shlib_disabled set):

  (gdb) maint info breakpoints
  Num     Type           Disp Enb Address            What
  [...]
  -8      jit events     keep y   <PENDING>           inf 1
  [...]

But that's incorrect.  GDB should have managed to recreate the JIT
breakpoint's location for the second run.  So the problem is
elsewhere.

The problem is that if the JIT loads at the same address on the second
run, we never recreate the JIT breakpoint, because we hit this early
return:

  static int
  jit_breakpoint_re_set_internal (struct gdbarch *gdbarch,
				  struct jit_program_space_data *ps_data)
  {
    [...]
    if (ps_data->cached_code_address == addr)
      return 0;

    [...]
      delete_breakpoint (ps_data->jit_breakpoint);
    [...]
    ps_data->jit_breakpoint = create_jit_event_breakpoint (gdbarch, addr);

Fix this by deleting the breakpoint and discarding the cached code
address when the objfile where the previous JIT breakpoint was found
is deleted/unloaded in the first place.

The test that was originally added for PR11094 doesn't trip on this
because:

  #1 - It doesn't test the case of the JIT descriptor's address _not_
       changing between reruns.

  #2 - And then it doesn't do "maint info breakpoints", or really
       anything with the JIT at all.

  #3 - and even then, to trigger the problem the JIT descriptor needs
       to be in a separate library, while the current test puts it in
       the main program.

The patch extends the test to cover all combinations of these
scenarios.

gdb/ChangeLog:
2016-10-06  Pedro Alves  <palves@redhat.com>

	* jit.c (free_objfile_data): Delete the JIT breakpoint and clear
	the cached code address.

gdb/testsuite/ChangeLog:
2016-10-06  Pedro Alves  <palves@redhat.com>

	* gdb.base/jit-simple-dl.c: New file.
	* gdb.base/jit-simple-jit.c: New file, factored out from ...
	* gdb.base/jit-simple.c: ... this.
	* gdb.base/jit-simple.exp (jit_run): Delete.
	(build_jit): New proc.
	(jit_test_reread): Recompile either the main program or the shared
	library, depending on what is being tested.  Skip changing address
	if caller wants to.  Compare before/after addresses.  If testing
	standalone, explicitly load the binary.  Test "maint info
	breakpoints".
	(top level): Add "standalone vs shared lib" and "change address"
	vs "same address" axes.


^ permalink raw reply	[flat|nested] 33+ messages in thread
* [binutils-gdb/gdb-7.12-branch] Introduce cleanup to restore current_uiout
@ 2016-10-03 23:07 sergiodj+buildbot
  2016-10-03 23:16 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
  2016-10-03 23:29 ` sergiodj+buildbot
  0 siblings, 2 replies; 33+ messages in thread
From: sergiodj+buildbot @ 2016-10-03 23:07 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT 33de0b1741b1939dd5384e54a858e71d2029a365 ***

Author: Simon Marchi <simark@simark.ca>
Branch: gdb-7.12-branch
Commit: 33de0b1741b1939dd5384e54a858e71d2029a365

Introduce cleanup to restore current_uiout

Make a globally available cleanup from a pre-existing one in infrun.c.
This is used in a following patch.

gdb/ChangeLog:

	* infrun.c (restore_current_uiout_cleanup): Move to ui-out.c.
	(print_stop_event): Use make_cleanup_restore_current_uiout.
	* python/python.c (execute_gdb_command): Likewise.
	* ui-out.c (restore_current_uiout_cleanup): Move from infrun.c.
	(make_cleanup_restore_current_uiout): New function definition.
	* ui-out.h (make_cleanup_restore_current_uiout): New function
	declaration.
	* utils.c (do_restore_ui_out): Remove.
	(make_cleanup_restore_ui_out): Remove.
	* utils.h (make_cleanup_restore_ui_out): Remove.


^ permalink raw reply	[flat|nested] 33+ messages in thread
* [binutils-gdb/gdb-7.12-branch] Add test for user context selection sync
@ 2016-10-03 22:38 sergiodj+buildbot
  2016-10-03 22:38 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
  2016-10-03 22:55 ` sergiodj+buildbot
  0 siblings, 2 replies; 33+ messages in thread
From: sergiodj+buildbot @ 2016-10-03 22:38 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT ec55637a35d74522d4a1fbb65ed4137803ed9d64 ***

Author: Antoine Tremblay <antoine.tremblay@ericsson.com>
Branch: gdb-7.12-branch
Commit: ec55637a35d74522d4a1fbb65ed4137803ed9d64

Add test for user context selection sync

This patch adds a test to verify that events are sent properly to all
UIs when the user selection context (inferior, thread, frame) changes.

The goal of the C test file is to provide two threads that are stopped with the
same predictable backtrace (so that we can test frame switching).  The barrier
helps us know when the child threads are started.  Then, scheduler-locking is
used to bring each thread one by one to the position we expect them to be
during the test.

gdb/testsuite/ChangeLog:

YYYY-MM-DD  Antoine Tremblay  <antoine.tremblay@ericsson.com>
YYYY-MM-DD  Simon Marchi  <simon.marchi@ericsson.com>

	PR gdb/20487
	* gdb.mi/user-selected-context-sync.exp: New file.
	* gdb.mi/user-selected-context-sync.c: New file.


^ permalink raw reply	[flat|nested] 33+ messages in thread
* [binutils-gdb/gdb-7.12-branch] Emit inferior, thread and frame selection events to all UIs
@ 2016-10-03 22:35 sergiodj+buildbot
  2016-10-03 22:35 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
  2016-10-03 22:46 ` sergiodj+buildbot
  0 siblings, 2 replies; 33+ messages in thread
From: sergiodj+buildbot @ 2016-10-03 22:35 UTC (permalink / raw)
  To: gdb-testers

*** TEST RESULTS FOR COMMIT 1555a1e7846048adeee7b9734ab3ec200d776858 ***

Author: Antoine Tremblay <antoine.tremblay@ericsson.com>
Branch: gdb-7.12-branch
Commit: 1555a1e7846048adeee7b9734ab3ec200d776858

Emit inferior, thread and frame selection events to all UIs

With this patch, when an inferior, thread or frame is explicitly
selected by the user, notifications will appear on all CLI and MI UIs.
When a GDB console is integrated in a front-end, this allows the
front-end to follow a selection made by the user ont he CLI, and it
informs the user about selection changes made behind the scenes by the
front-end.

This patch addresses PR gdb/20487.

In order to communicate frame changes to the front-end, this patch adds
a new field to the =thread-selected event for the selected frame.  The
idea is that since inferior/thread/frame can be seen as a composition,
it makes sense to send them together in the same event.  The vision
would be to eventually send the inferior information as well, if we find
that it's needed, although the "=thread-selected" event would be
ill-named for that job.

Front-ends need to handle this new field if they want to follow the
frame selection changes that originate from the console.  The format of
the frame attribute is the same as what is found in the *stopped events.

Here's a detailed example for each command and the events they generate:

thread
------

1. CLI command:

     thread 1.3

   MI event:

     =thread-selected,id="3",frame={...}

2. MI command:

     -thread-select 3

   CLI event:

     [Switching to thread 1.3 ...]

3. MI command (CLI-in-MI):

     thread 1.3

   MI event/reply:

     &"thread 1.3\n"
     ~"#0  child_sub_function () ...
     =thread-selected,id="3",frame={level="0",...}
     ^done

frame
-----

1. CLI command:

     frame 1

   MI event:

     =thread-selected,id="3",frame={level="1",...}

2. MI command:

     -stack-select-frame 1

   CLI event:

     #1  0x00000000004007f0 in child_function...

3. MI command (CLI-in-MI):

     frame 1

   MI event/reply:

     &"frame 1\n"
     ~"#1  0x00000000004007f9 in ..."
     =thread-selected,id="3",frame={level="1"...}
     ^done

inferior
--------

Inferior selection events only go from the console to MI, since there's
no way to select the inferior in pure MI.

1. CLI command:

     inferior 2

   MI event:

     =thread-selected,id="3"

Note that if the user selects an inferior that is not started or exited,
the MI doesn't receive a notification.  Since there is no threads to
select, the =thread-selected event does not apply...

2. MI command (CLI-in-MI):

     inferior 2

   MI event/reply:

     &"inferior 2\n"
     ~"[Switching to inferior 2 ...]"
     =thread-selected,id="4",frame={level="0"...}
     ^done

Internal implementation detail: this patch makes it possible to suppress
notifications caused by a CLI command, like what is done in mi-interp.c.
This means that it's now possible to use the
add_com_suppress_notification function to register a command with some
event suppressed.  It is used to implement the select-frame command in
this patch.

The function command_notifies_uscc_observer was added to extract
the rather complicated logical expression from the if statement.  It is
also now clearer what that logic does: if the command used by the user
already notifies the user_selected_context_changed observer, there is
not need to notify it again.  It therefore protects again emitting the
event twice.

No regressions, tested on ubuntu 14.04 x86 with target boards unix and
native-extended-gdbserver.

gdb/ChangeLog:

YYYY-MM-DD  Antoine Tremblay  <antoine.tremblay@ericsson.com>
YYYY-MM-DD  Simon Marchi  <simon.marchi@ericsson.com>

	PR gdb/20487
	* NEWS: Mention new frame field of =thread-selected event.
	* cli/cli-decode.c (add_cmd): Initialize c->suppress_notification.
	(add_com_suppress_notification): New function definition.
	(cmd_func): Set and restore the suppress_notification flag.
	* cli/cli-deicode.h (struct cmd_list_element)
	<suppress_notification>: New field.
	* cli/cli-interp.c (cli_suppress_notification): New global variable.
	(cli_on_user_selected_context_changed): New function.
	(_initialize_cli_interp): Attach to user_selected_context_changed
	observer.
	* command.h (struct cli_suppress_notification): New structure.
	(cli_suppress_notification): New global variable declaration.
	(add_com_suppress_notification): New function declaration.
	* defs.h (enum user_selected_what_flag): New enum.
	(user_selected_what): New enum flag type.
	* frame.h (print_stack_frame_to_uiout): New function declaration.
	* gdbthread.h (print_selected_thread_frame): New function declaration.
	* inferior.c (print_selected_inferior): New function definition.
	(inferior_command): Remove printing of inferior/thread/frame switch
	notifications, notify user_selected_context_changed observer.
	* inferior.h (print_selected_inferior): New function declaration.
	* mi/mi-cmds.c (struct mi_cmd): Add user_selected_context
	suppression to stack-select-frame and thread-select commands.
	* mi/mi-interp.c (struct mi_suppress_notification)
	<user_selected_context>: Initialize.
	(mi_user_selected_context_changed): New function definition.
	(_initialize_mi_interp): Attach to user_selected_context_changed.
	* mi/mi-main.c (mi_cmd_thread_select): Print thread selection reply.
	(mi_execute_command): Handle notification suppression.  Notify
	user_selected_context_changed observer on thread change instead of printing
	event directly.  Don't send it if command already sends the notification.
	(command_notifies_uscc_observer): New function.
	(mi_cmd_execute): Don't handle notification suppression.
	* mi/mi-main.h (struct mi_suppress_notification)
	<user_selected_context>: New field.
	* stack.c (print_stack_frame_to_uiout): New function definition.
	(select_frame_command): Notify user_selected_context_changed
	observer.
	(frame_command): Call print_selected_thread_frame if there's no frame
	change or notify user_selected_context_changed observer if there is.
	(up_command): Notify user_selected_context_changed observer.
	(down_command): Likewise.
	(_initialize_stack): Suppress user_selected_context notification for
	command select-frame.
	* thread.c (thread_command): Notify
	user_selected_context_changed if the thread has changed, print
	thread info directly if it hasn't.
	(do_captured_thread_select): Do not print thread switch event.
	(print_selected_thread_frame): New function definition.
	* tui/tui-interp.c (tui_on_user_selected_context_changed):
	New function definition.
	(_initialize_tui_interp): Attach to user_selected_context_changed
	observer.

gdb/doc/ChangeLog:

	PR gdb/20487
	* gdb.texinfo (Context management): Update mention of frame
	change notifications.
	(gdb/mi Async Records): Document frame field in
	=thread-select event.
	* observer.texi (GDB Observers): New user_selected_context_changed
	observer.

gdb/testsuite/ChangeLog:

	PR gdb/20487
	* gdb.mi/mi-pthreads.exp (check_mi_thread_command_set): Adapt
	=thread-select-event check.


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

end of thread, other threads:[~2016-12-20 18:14 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-06 13:25 [binutils-gdb/gdb-7.12-branch] Fix a few gdb.base/jit-simple.exp problems sergiodj+buildbot
2016-10-06 13:25 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
2016-10-06 13:38 ` Failures on Fedora-x86_64-m32, branch gdb-7.12-branch sergiodj+buildbot
2016-10-06 13:41 ` Failures on Fedora-x86_64-native-gdbserver-m32, " sergiodj+buildbot
2016-10-06 13:46 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
2016-10-06 13:54 ` Failures on Fedora-x86_64-native-extended-gdbserver-m64, branch gdb-7.12-branch sergiodj+buildbot
2016-10-06 13:58 ` Failures on Fedora-x86_64-m64, " sergiodj+buildbot
2016-10-06 14:33 ` Failures on Fedora-i686, " sergiodj+buildbot
2016-10-06 14:57 ` Failures on Debian-s390x-native-gdbserver-m64, " sergiodj+buildbot
2016-10-06 15:36 ` Failures on Debian-s390x-m64, " sergiodj+buildbot
2016-10-06 15:51 ` Failures on Debian-s390x-native-extended-gdbserver-m64, " sergiodj+buildbot
2016-10-06 15:56 ` Failures on Debian-i686-native-extended-gdbserver, " sergiodj+buildbot
2016-10-07  2:56 ` Failures on Fedora-ppc64be-native-gdbserver-m64, " sergiodj+buildbot
2016-10-07  3:43 ` Failures on Fedora-ppc64be-native-extended-gdbserver-m64, " sergiodj+buildbot
2016-10-07  4:38 ` Failures on Fedora-ppc64le-native-extended-gdbserver-m64, " sergiodj+buildbot
2016-10-07  5:41 ` Failures on Fedora-ppc64le-native-gdbserver-m64, " sergiodj+buildbot
  -- strict thread matches above, loose matches on Subject: below --
2016-12-20 17:36 [binutils-gdb/gdb-7.12-branch] Fix longjmp across readline w/ --enable-sjlj-exceptions toolchains sergiodj+buildbot
2016-12-20 18:17 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
2016-10-06 19:26 [binutils-gdb/gdb-7.12-branch] mips-tdep: Make FCRs always 32-bit sergiodj+buildbot
2016-10-06 19:26 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
2016-10-06 21:19 ` sergiodj+buildbot
2016-10-06 19:23 [binutils-gdb/gdb-7.12-branch] mips-tdep: Rearrange comments in `mips_pseudo_register_type' sergiodj+buildbot
2016-10-06 19:23 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
2016-10-06 20:37 ` sergiodj+buildbot
2016-10-06 19:21 [binutils-gdb/gdb-7.12-branch] testsuite: solib-disc: Use `standard_output_file' sergiodj+buildbot
2016-10-06 19:21 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
2016-10-06 19:54 ` sergiodj+buildbot
2016-10-06 15:41 [binutils-gdb/gdb-7.12-branch] stack: fix gdb.dwarf2/dw2-undefined-ret-addr.exp regression sergiodj+buildbot
2016-10-06 16:08 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
2016-10-06 16:10 ` sergiodj+buildbot
2016-10-06 13:29 [binutils-gdb/gdb-7.12-branch] Fix PR11094: JIT breakpoint is not properly recreated on reruns sergiodj+buildbot
2016-10-06 13:29 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
2016-10-06 14:35 ` sergiodj+buildbot
2016-10-03 23:07 [binutils-gdb/gdb-7.12-branch] Introduce cleanup to restore current_uiout sergiodj+buildbot
2016-10-03 23:16 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
2016-10-03 23:29 ` sergiodj+buildbot
2016-10-03 22:38 [binutils-gdb/gdb-7.12-branch] Add test for user context selection sync sergiodj+buildbot
2016-10-03 22:38 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
2016-10-03 22:55 ` sergiodj+buildbot
2016-10-03 22:35 [binutils-gdb/gdb-7.12-branch] Emit inferior, thread and frame selection events to all UIs sergiodj+buildbot
2016-10-03 22:35 ` *** COMPILATION FAILED *** Failures on Fedora-x86_64-c-build-m64, branch gdb-7.12-branch *** BREAKAGE *** sergiodj+buildbot
2016-10-03 22:46 ` sergiodj+buildbot

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).