[all-commits] [llvm/llvm-project] 8d9400: [lldb] [Process/NetBSD] Improve threading support

Michał Górny via All-commits all-commits at lists.llvm.org
Mon Nov 25 11:12:10 PST 2019


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 8d9400b65b972cb50fe2266360443192ea107ec9
      https://github.com/llvm/llvm-project/commit/8d9400b65b972cb50fe2266360443192ea107ec9
  Author: Michał Górny <mgorny at gentoo.org>
  Date:   2019-11-25 (Mon, 25 Nov 2019)

  Changed paths:
    M lldb/packages/Python/lldbsuite/test/commands/watchpoints/hello_watchlocation/TestWatchLocation.py
    M lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_set_command/TestWatchLocationWithWatchSet.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentBreakpointOneDelayBreakpointThreads.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithBreak.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithSignal.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithWatchpoint.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentCrashWithWatchpointBreakpointSignal.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelaySignalBreak.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointSignal.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelayedCrashWithBreakpointWatchpoint.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyBreakpoints.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyCrash.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalBreak.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointThreads.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_break/TestExitDuringBreak.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/exit_during_step/TestExitDuringStep.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/num_threads/TestNumThreads.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_exit/TestThreadExit.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/thread_specific_break/TestThreadSpecificBreakpoint.py
    M lldb/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestLLDBIterator.py
    M lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py
    A lldb/packages/Python/lldbsuite/test/tools/lldb-server/TestGdbRemote_vContThreads.py
    M lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
    M lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.h
    M lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
    M lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h

  Log Message:
  -----------
  [lldb] [Process/NetBSD] Improve threading support

Implement major improvements to multithreaded program support.  Notably,
support tracking new and exited threads, associate signals and events
with correct threads and support controlling individual threads when
resuming.

Firstly, use PT_SET_EVENT_MASK to enable reporting of created and exited
threads via SIGTRAP.  Handle TRAP_LWP events to keep track
of the currently running threads.

Secondly, update the signal (both generic and SIGTRAP) handling code
to account for per-thread signals correctly.  Signals delivered
to the whole process are reported on all threads, while per-thread
signals and events are reported only to the specific thread.
The remaining threads are marked as 'stopped with no reason'.  Note that
NetBSD always stops all threads on debugger events.

Thirdly, implement the ability to set every thread as running, stopped
or single-stepping separately while continuing the process.  This also
provides the ability to send a signal to the whole process or to one
of its thread while resuming.

Differential Revision: https://reviews.llvm.org/D70022


  Commit: d970d4d4aa7345ebf8b7169b09f2775a93f86c33
      https://github.com/llvm/llvm-project/commit/d970d4d4aa7345ebf8b7169b09f2775a93f86c33
  Author: Michał Górny <mgorny at gentoo.org>
  Date:   2019-11-25 (Mon, 25 Nov 2019)

  Changed paths:
    M lldb/packages/Python/lldbsuite/test/commands/watchpoints/multiple_threads/TestWatchpointMultipleThreads.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentBreakpointsDelayedBreakpointOneWatchpoint.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelaySignalWatch.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentDelayWatchBreak.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentSignalWatch.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoBreakpointsOneWatchpoint.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentWatchBreak.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentWatchBreakDelay.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentWatchpointDelayWatchpointOneBreakpoint.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentWatchpointWithDelayWatchpointThreads.py
    M lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
    M lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.cpp
    M lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
    M lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
    M lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h
    M lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.cpp
    M lldb/source/Plugins/Process/NetBSD/NativeThreadNetBSD.h
    A lldb/test/Shell/Watchpoint/Inputs/thread-dbreg.c
    A lldb/test/Shell/Watchpoint/netbsd-nouserdbregs.test
    M lldb/test/Shell/lit.cfg.py

  Log Message:
  -----------
  [lldb] [Process/NetBSD] Copy watchpoints to newly-created threads

NetBSD ptrace interface does not populate watchpoints to newly-created
threads.  Solve this via copying the watchpoints from the current thread
when new thread is reported via TRAP_LWP.

Add a test that verifies that when the user does not have permissions
to set watchpoints on NetBSD, the 'watchpoint set' errors out gracefully
and thread monitoring does not crash on being unable to copy watchpoints
to new threads.

Differential Revision: https://reviews.llvm.org/D70023


  Commit: 7644d8ba4dc4e06b2db2bfdb7f4d76b9356cb288
      https://github.com/llvm/llvm-project/commit/7644d8ba4dc4e06b2db2bfdb7f4d76b9356cb288
  Author: Michał Górny <mgorny at gentoo.org>
  Date:   2019-11-25 (Mon, 25 Nov 2019)

  Changed paths:
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentManyWatchpoints.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentNWatchNBreak.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointThreads.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneBreakpoint.py
    M lldb/packages/Python/lldbsuite/test/functionalities/thread/concurrent_events/TestConcurrentTwoWatchpointsOneDelayBreakpoint.py
    M lldb/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py
    M lldb/source/Plugins/Process/NetBSD/NativeProcessNetBSD.cpp
    M lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD.h
    M lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.cpp
    M lldb/source/Plugins/Process/NetBSD/NativeRegisterContextNetBSD_x86_64.h

  Log Message:
  -----------
  [lldb] [Process/NetBSD] Fix handling concurrent watchpoint events

Fix handling concurrent watchpoint events so that they are reported
correctly in LLDB.

If multiple watchpoints are hit concurrently, the NetBSD kernel reports
them as series of SIGTRAPs with a thread specified, and the debugger
investigates DR6 in order to establish which watchpoint was hit.  This
is normally fine.

However, LLDB disables and reenables the watchpoint on all threads after
each hit, which results in the hit status from DR6 being wiped.
As a result, it can't establish which watchpoint was hit in successive
SIGTRAP processing.

In order to workaround this problem, clear DR6 only if the breakpoint
is overwritten with a new one.  More specifically, move cleaning DR6
from ClearHardwareWatchpoint() to SetHardwareWatchpointWithIndex(),
and do that only if the newly requested watchpoint is different
from the one being set previously.  This ensures that the disable-enable
logic of LLDB does not clear watchpoint hit status for the remaining
threads.

This also involves refactoring of watchpoint logic.  With the old logic,
clearing watchpoint involved wiping dr6 & dr7, and setting it setting
dr{0..3} & dr7.  With the new logic, only enable bit is cleared
from dr7, and the remaining bits are cleared/overwritten while setting
new watchpoint.

Differential Revision: https://reviews.llvm.org/D70025


Compare: https://github.com/llvm/llvm-project/compare/d018b556c755...7644d8ba4dc4


More information about the All-commits mailing list