Skip to content

Commit bdea8dd

Browse files
committedApr 8, 2016
Reset continue_after_async only if neither SIGINIT nor SIGSTOP received.
http://reviews.llvm.org/D18886 llvm-svn: 265843
1 parent 3232dbb commit bdea8dd

File tree

4 files changed

+66
-4
lines changed

4 files changed

+66
-4
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
LEVEL = ../../../make
2+
3+
CXX_SOURCES := main.cpp
4+
5+
include $(LEVEL)/Makefile.rules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
Test inferior restart when breakpoint is set on running target.
3+
"""
4+
5+
import os
6+
import lldb
7+
from lldbsuite.test.lldbtest import *
8+
from lldbsuite.test import lldbutil
9+
10+
class BreakpointSetRestart(TestBase):
11+
12+
mydir = TestBase.compute_mydir(__file__)
13+
BREAKPOINT_TEXT = 'Set a breakpoint here'
14+
15+
def test_breakpoint_set_restart(self):
16+
self.build()
17+
18+
cwd = self.get_process_working_directory()
19+
exe = os.path.join(cwd, "a.out")
20+
target = self.dbg.CreateTarget(exe)
21+
22+
self.dbg.SetAsync(True)
23+
process = target.LaunchSimple(None, None, cwd)
24+
25+
lldbutil.expect_state_changes(self, self.dbg.GetListener(), [lldb.eStateRunning])
26+
bp = target.BreakpointCreateBySourceRegex(self.BREAKPOINT_TEXT,
27+
lldb.SBFileSpec(os.path.join(cwd, 'main.cpp')))
28+
self.assertTrue(bp.IsValid() and bp.GetNumLocations() == 1, VALID_BREAKPOINT)
29+
30+
event = lldb.SBEvent()
31+
while self.dbg.GetListener().WaitForEvent(2, event):
32+
if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateStopped and lldb.SBProcess.GetRestartedFromEvent(event):
33+
continue
34+
if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning:
35+
continue
36+
self.fail("Setting a breakpoint generated an unexpected event: %s" % lldb.SBDebugger.StateAsCString(lldb.SBProcess.GetStateFromEvent(event)))
37+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//===-- main.cpp ------------------------------------------------*- C++ -*-===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#include <iostream>
11+
#include <stdio.h>
12+
13+
int main(int argc, char const *argv[])
14+
{
15+
getchar();
16+
printf("Set a breakpoint here.\n");
17+
return 0;
18+
}
19+

‎lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -1165,12 +1165,13 @@ GDBRemoteCommunicationClient::SendContinuePacketAndWaitForResponse
11651165
// binaries that would send two stop replies anytime the process
11661166
// was interrupted, so we need to also check for an extra
11671167
// stop reply packet if we interrupted the process
1168-
if (m_interrupt_sent || (signo != sigint_signo && signo != sigstop_signo))
1168+
const bool received_nonstop_signal = signo != sigint_signo && signo != sigstop_signo;
1169+
if (m_interrupt_sent || received_nonstop_signal)
11691170
{
1170-
continue_after_async = false;
1171+
if (received_nonstop_signal)
1172+
continue_after_async = false;
11711173

1172-
// We didn't get a SIGINT or SIGSTOP, so try for a
1173-
// very brief time (0.1s) to get another stop reply
1174+
// Try for a very brief time (0.1s) to get another stop reply
11741175
// packet to make sure it doesn't get in the way
11751176
StringExtractorGDBRemote extra_stop_reply_packet;
11761177
uint32_t timeout_usec = 100000;

0 commit comments

Comments
 (0)
Please sign in to comment.