Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.

Implement hardware breakpoint support for Linux-x86 #243

Closed
wants to merge 3 commits into from

Conversation

fjricci
Copy link
Contributor

@fjricci fjricci commented Mar 31, 2016

No description provided.

@facebook-github-bot
Copy link

By analyzing the blame information on this pull request, we identified @sas, @fjricci and @a20012251 to be potential reviewers.

@fjricci fjricci changed the title Add breakpoint mode to breakpoint manager api Progress toward supporting hardware breakpoints Apr 1, 2016
@fjricci fjricci force-pushed the x86_impl branch 8 times, most recently from eaec15d to 5e8356f Compare April 4, 2016 20:30
@@ -35,7 +35,10 @@ void SoftwareBreakpointManager::clear() {
}

ErrorCode SoftwareBreakpointManager::add(Address const &address, Type type,
size_t size) {
size_t size, Mode mode) {
if (mode != kModeExec)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can make this a DS2ASSERT, given that we don't pass user data directly here, and that all callers of ::add will always call it with kModeExec.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the issue with doing that is that you could theoretically have software watchpoints (gdb does), and so I'm not sure that it's really an assertion-level failure to try to create one, even if we don't support them currently?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's a good point.

On Mon, Apr 4, 2016 at 3:54 PM, Francis Ricci notifications@github.com
wrote:

In Sources/Architecture/ARM/SoftwareBreakpointManager.cpp
#243 (comment):

@@ -35,7 +35,10 @@ void SoftwareBreakpointManager::clear() {
}

ErrorCode SoftwareBreakpointManager::add(Address const &address, Type type,

  •                                     size_t size) {
    
  •                                     size_t size, Mode mode) {
    
  • if (mode != kModeExec)

I think the issue with doing that is that you could theoretically have
software watchpoints (gdb does), and so I'm not sure that it's really an
assertion-level failure to try to create one, even if we don't support them
currently?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/facebook/ds2/pull/243/files/2b7add545bce75bd539f7f39cb938aa59689d8ae#r58462758

Stephane Sezer

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can move this check in super::add() and avoid having to duplicate it in the x86 counterpart of this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I looked at software watchpoints a little bit, and they are handled by the client directly. The debug server has nothing to do with them, and the protocol doesn't support setting "software watchpoints". PR#268 should make us safe to put an assertion there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no SoftwareBreakpointManager superclass, "super" here is BreakpointManager, and I can't put it there, or it will break hardware breakpoints. But I can change it to an assert.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah true.

On Friday, April 8, 2016, Francis Ricci notifications@github.com wrote:

In Sources/Architecture/ARM/SoftwareBreakpointManager.cpp
#243 (comment):

@@ -35,7 +35,10 @@ void SoftwareBreakpointManager::clear() {
}

ErrorCode SoftwareBreakpointManager::add(Address const &address, Type type,

  •                                     size_t size) {
    
  •                                     size_t size, Mode mode) {
    
  • if (mode != kModeExec)

There is no SoftwareBreakpointManager superclass, "super" here is
BreakpointManager, and I can't put it there, or it will break hardware
breakpoints. But I can change it to an assert.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/facebook/ds2/pull/243/files/2b7add545bce75bd539f7f39cb938aa59689d8ae#r59102598

Stephane Sezer

@fjricci fjricci force-pushed the x86_impl branch 5 times, most recently from 2b454aa to 523f690 Compare April 7, 2016 00:05
@facebook-github-bot
Copy link

@fjricci updated the pull request.

@fjricci fjricci closed this Jul 5, 2016
@fjricci fjricci reopened this Jul 5, 2016
@fjricci fjricci force-pushed the x86_impl branch 4 times, most recently from 25b0271 to 0ef37b1 Compare July 7, 2016 13:50
@ghost ghost added the CLA Signed label Jul 12, 2016
@sas
Copy link
Contributor

sas commented Aug 9, 2016

Committed some more patches as 3ccacba..6b668bd.


ErrorCode ThreadBase::beforeResume() {
if (!_process->isAlive())
return kErrorProcessNotFound;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Braces and stuff :p

@fjricci fjricci force-pushed the x86_impl branch 2 times, most recently from 0ee677d to dbb0683 Compare August 9, 2016 17:11
@@ -1004,6 +1004,10 @@ DebugSessionImplBase::onResume(Session &session,
#endif

case StopInfo::kReasonThreadEntry:
error = _process->currentThread()->beforeResume();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pro-tip: You can use a fancy macro here.

@fjricci fjricci force-pushed the x86_impl branch 4 times, most recently from 10ba488 to 0123613 Compare August 16, 2016 21:58
@sas
Copy link
Contributor

sas commented Aug 16, 2016

Committed the CHK patch as 9d0f300.

}

bool SoftwareBreakpointManager::enabled(Target::Thread *thread) const {
if (thread != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a DS2_ASSERT.

}

void SoftwareBreakpointManager::disable(Target::Thread *thread) {
super::disable(thread);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to pass thread here? Can't we just DS2_ASSERT(thread == nullptr) and call supper::disable()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this was to unify the api with hardware breakpoints.

ErrorCode error;
ByteVector old = _insns[site.address];

if (thread != nullptr) {
DS2LOG(Warning, "thread-specific software breakpoints are unsupported");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a DS2_ASSERT as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We had a conversation with this one, and I think the conclusion was that since gdb supports these, we should leave the option available.

@sas
Copy link
Contributor

sas commented Sep 23, 2016

Merged as fc285ce..3471878.

🎉 🎉 🎉 🎉 🎉

@sas sas closed this Sep 23, 2016
@fjricci fjricci deleted the x86_impl branch September 23, 2016 21:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants