BreakpointProbe.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #include "RuntimeDebugPch.h"
  6. namespace Js
  7. {
  8. BreakpointProbe::BreakpointProbe(DebugDocument* debugDocument, StatementLocation& statement) :
  9. debugDocument(debugDocument),
  10. functionBody(statement.function),
  11. characterOffset(statement.statement.begin),
  12. byteOffset(statement.bytecodeSpan.begin)
  13. {
  14. }
  15. bool BreakpointProbe::Install(ScriptContext* pScriptContext)
  16. {
  17. Assert(this->functionBody);
  18. return functionBody->InstallProbe(byteOffset);
  19. }
  20. bool BreakpointProbe::Uninstall(ScriptContext* pScriptContext)
  21. {
  22. Assert(this->functionBody);
  23. if (this->functionBody)
  24. {
  25. Assert(this->debugDocument);
  26. this->debugDocument->RemoveBreakpointProbe(this);
  27. return functionBody->UninstallProbe(byteOffset);
  28. }
  29. return true;
  30. }
  31. bool BreakpointProbe::CanHalt(InterpreterHaltState* pHaltState)
  32. {
  33. Assert(this->functionBody);
  34. FunctionBody* pCurrentFuncBody = pHaltState->GetFunction();
  35. int offset = pHaltState->GetCurrentOffset();
  36. if (functionBody == pCurrentFuncBody && byteOffset == offset)
  37. {
  38. return true;
  39. }
  40. return false;
  41. }
  42. void BreakpointProbe::DispatchHalt(InterpreterHaltState* pHaltState)
  43. {
  44. Assert(false);
  45. }
  46. void BreakpointProbe::CleanupHalt()
  47. {
  48. Assert(this->functionBody);
  49. // Nothing to clean here
  50. }
  51. bool BreakpointProbe::Matches(FunctionBody* _pBody, int _characterOffset)
  52. {
  53. Assert(this->functionBody);
  54. return _pBody == functionBody && _characterOffset == characterOffset;
  55. }
  56. }