This is an archive of the discontinued LLVM Phabricator instance.

MI Windows Ctrl-C Handling
ClosedPublic

Authored by EwanCrawford on Apr 24 2015, 3:28 AM.

Details

Reviewers
abidh
ki.stfu
Summary

Currently hitting Ctrl-C in Windows LLDB-MI just exits MI. But according to test_lldbmi_stopped_when_interrupt() in TestMiSignal.py Ctrl-C should send a SIGINT signal to the inferior.
Patch adds this functionality to Windows so SIGINT is sent on Ctrl-C.

Diff Detail

Repository
rL LLVM

Event Timeline

EwanCrawford retitled this revision from to MI Windows Ctrl-C Handling .
EwanCrawford updated this object.
EwanCrawford edited the test plan for this revision. (Show Details)
EwanCrawford added a reviewer: ki.stfu.
EwanCrawford set the repository for this revision to rL LLVM.
EwanCrawford added subscribers: deepak2427, Unknown Object (MLST).
ki.stfu requested changes to this revision.Apr 24 2015, 4:53 AM
ki.stfu edited edge metadata.
ki.stfu added a subscriber: abidh.
ki.stfu added inline comments.
tools/lldb-mi/MICmnStreamStdin.cpp
18–22

store it before "In-house headers" section

219

missing else? to follow if - else if - else if here?

tools/lldb-mi/Platform.cpp
26

we shouldn't use SIGxxx constants. See how it was made in tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp (look for m_SIGINT).

I'm not sure whether it should be 0 or not. AFAIK @abidh refactored this code, maybe he knows it?

This revision now requires changes to proceed.Apr 24 2015, 4:53 AM
abidh added inline comments.Apr 27 2015, 1:52 AM
tools/lldb-mi/MICmnStreamStdin.cpp
219

Why we need to check for this error type here anyway. Will not the ctrl-c handler be called without this change. I also like to avoid #ifdef code as much as possible.

tools/lldb-mi/Platform.cpp
26

This is certainly an oversight to use 0 here. We are still using SIGINT in a few places in lldb-mi. Greg suggested that it is better to not depend on hard coded values and instead get those values from process at run time. But we may have to use hard coded SIGINT here and in MIDriverMain.cpp as those values are needed before process is initialized.

If you want to fully accurate, it may be good to check the argument dwCtrlType value too.

EwanCrawford added inline comments.Apr 27 2015, 2:42 AM
tools/lldb-mi/MICmnStreamStdin.cpp
219

The ctrl-c handler will indeed be called regardless. The problem is that hitting ctrl-c on Windows sets the end of file indicator, so if (::feof(stdin)) on the following line evaluates to True and MI force exits. Modifying this condition would be an alternative solution to avoid the #ifdef, but I'll need to look into that further.

tools/lldb-mi/Platform.cpp
26

Thanks for the comments, I'll try out some alternatives to hardcoding.

abidh accepted this revision.Apr 27 2015, 3:00 AM
abidh edited edge metadata.
abidh added inline comments.
tools/lldb-mi/MICmnStreamStdin.cpp
219

In that case, this change is ok. Please rephrase the comments in the code to describe this.

tools/lldb-mi/Platform.cpp
26

I think hardcoding here may be ok.

EwanCrawford edited edge metadata.

Hardcoding the signal seems the best way for now, since the value ends up being compared directly against SIGINT in the driver. It might be easier to tidy up the SIG constants all at once.

I left the GetLastError() check wihout an 'else' condition, I'm not sure what it would include and the purpose of the #ifdef seems clearer this way,

ki.stfu accepted this revision.Apr 27 2015, 7:44 AM
ki.stfu edited edge metadata.
This revision is now accepted and ready to land.Apr 27 2015, 7:44 AM

Could you commit please, thanks. I'm requesting access so I don't need to keep asking you.

abidh added a comment.Apr 27 2015, 8:03 AM

Could you commit please, thanks. I'm requesting access so I don't need to keep asking you.

No Problem. I will commit it.

Thanks,
Abid

abidh closed this revision.Apr 27 2015, 8:08 AM

Committed in 235887.