New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reenable callback on |break| instruction #216
Merged
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e015114
Reenable IPluginContext::SetDebugBreak
peace-maker d937d75
Use a versioned struct in debug break callback
peace-maker e66fe8d
Add functions to iterate source file names to IPluginDebugInfo
peace-maker c53f52b
Remove unnecassary info from VM state struct
peace-maker ca3eb9a
Add functions to lookup the address of a function or line in a file
peace-maker 799d51d
Fix disabling VM watchdog during debug callback
peace-maker 5dbd114
Support RTTI tables
peace-maker ab9e10c
Fix nits
peace-maker 34ddb67
Align stack before calling the debug handler
peace-maker e40096f
Use a single debug break handler instead of one per context
peace-maker 7e9ae3e
Only call the debug handler if debugging was enabled globally
peace-maker 632169f
Fix style nits
peace-maker 9c8a1c0
Move IsDebugBreakEnabled check into interpreter
peace-maker File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// vim: set sts=2 ts=8 sw=2 tw=99 et: | ||
// | ||
// Copyright (C) 2016-2018 AlliedModders LLC | ||
// | ||
// This file is part of SourcePawn. SourcePawn is free software: you can | ||
// redistribute it and/or modify it under the terms of the GNU General Public | ||
// License as published by the Free Software Foundation, either version 3 of | ||
// the License, or (at your option) any later version. | ||
// | ||
// You should have received a copy of the GNU General Public License along with | ||
// SourcePawn. If not, see http://www.gnu.org/licenses/. | ||
// | ||
#include "debugging.h" | ||
#include "stack-frames.h" | ||
#include "environment.h" | ||
#include "watchdog_timer.h" | ||
#include <amtl/am-raii.h> | ||
|
||
namespace sp { | ||
|
||
void InvokeDebugger(PluginContext* ctx, const IErrorReport* report) | ||
{ | ||
// Continue normal execution, if this plugin isn't being debugged. | ||
if (!ctx->debugbreak()) | ||
return; | ||
|
||
if (!ctx->IsDebugging()) { | ||
ctx->ReportErrorNumber(SP_ERROR_NOTDEBUGGING); | ||
return; | ||
} | ||
|
||
cell_t cip = 0; | ||
|
||
// Find first scripted frame on the stack to get the cip from. | ||
// There might be some native or helper frames beforehand. | ||
{ | ||
FrameIterator iter; | ||
for (; !iter.Done(); iter.Next()) { | ||
if (iter.IsScriptedFrame()) { | ||
cip = iter.cip(); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
// Tell the watchdog to take a break. | ||
// We might stay in the debugger callback for a while, | ||
// so don't let the watchdog hit immediately after | ||
// continueing with execution. | ||
ke::SaveAndSet<bool> disableWatchdog(&Environment::get()->watchdog()->ignore_timeout_, true); | ||
|
||
// Fill in the debug info struct. | ||
sp_debug_break_info_t dbginfo; | ||
dbginfo.version = DEBUG_BREAK_INFO_VERSION; | ||
dbginfo.cip = cip; | ||
dbginfo.frm = ctx->frm(); | ||
|
||
// Call debug callback. | ||
ctx->debugbreak()(ctx, dbginfo, report); | ||
} | ||
|
||
} // namespace sp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// vim: set ts=8 sts=2 sw=2 tw=99 et: | ||
// | ||
// This file is part of SourcePawn. | ||
// | ||
// SourcePawn is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// SourcePawn is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with SourcePawn. If not, see <http://www.gnu.org/licenses/>. | ||
// | ||
#ifndef _include_sourcepawn_vm_debugging_h_ | ||
#define _include_sourcepawn_vm_debugging_h_ | ||
|
||
#include "plugin-context.h" | ||
|
||
namespace sp { | ||
|
||
void InvokeDebugger(PluginContext* ctx, const IErrorReport* report); | ||
|
||
} // namespace sp | ||
|
||
#endif // _include_sourcepawn_vm_debugging_h_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this version field supposed to be used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To know whether new fields are available. When adding more info to the struct, like maybe a pointer to the smx in memory to parse the debug symbols manually, allow extensions know which fields they can use.
Probably could get rid of this seperate version field and just increase the whole vm api version if it's changed. Extensions just don't have access to
SOURCEPAWN_API_VERSION
.