Multi-arch exec, more register reading avoidance
authorPedro Alves <palves@redhat.com>
Mon, 9 Oct 2017 17:11:01 +0000 (18:11 +0100)
committerPedro Alves <palves@redhat.com>
Mon, 9 Oct 2017 17:11:01 +0000 (18:11 +0100)
commitcbd2b4e316370ab740433b06ed65786831232c8f
tree3d24752cec304cbbb0d261eac1f3f0119e600ba4
parenta181c0bf7461c28cdb72a4074c6d7608119fb575
Multi-arch exec, more register reading avoidance

As mentioned in commit bf93d7ba9931 ("Add thread after updating
gdbarch when exec'ing"), we should avoid doing register reads after a
process does an exec and before we've updated that inferior's gdbarch.
Otherwise, we may interpret the registers using the wrong
architecture.

There's still (at least) one case where we still read registers
post-exec with the pre-exec architecture.  That's when infrun decides
it needs to switch context to the exec'ing thread.  I.e., if the exec
event is processed at a time when the current thread is not already
the exec'ing thread, then we get (with the test added by this commit):

  continue
  Continuing.
  Truncated register 50 in remote 'g' packet
  Truncated register 50 in remote 'g' packet
  (gdb) FAIL: gdb.multi/multi-arch-exec.exp: selected_thread=2: follow_exec_mode=same: continue across exec that changes architecture

The fix is to avoid reading registers when switching context in this
case.

(I'd be nice to get rid of the constant stop_pc reading when switching
threads, but that'd be a deeper change.)

gdb/ChangeLog:
2017-10-09  Pedro Alves  <palves@redhat.com>

* infrun.c (handle_inferior_event_1) <TARGET_WAITKIND_EXECD>: Skip
reading registers when switching context.

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

* gdb.multi/multi-arch-exec.c: Include <pthread.h> and <assert.h>.
(barrier): New.
(thread_start, all_started): New functions.
(main): Spawn new thread and wait until it is scheduled.
* gdb.multi/multi-arch-exec.exp: Build $srcfile1 with the pthreads
option.
(do_test): Add 'selected_thread' parameter.  Run to all_started
instead of main.  Explicitly set the breakpoint at main.  Switch
to the SELECTED_THREAD thread.
(top level): Test handling the exec event with either the main
thread or the second thread selected.
gdb/ChangeLog
gdb/infrun.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.multi/multi-arch-exec.c
gdb/testsuite/gdb.multi/multi-arch-exec.exp
This page took 0.037823 seconds and 4 git commands to generate.