Skip to content

Commit

Permalink
breapoint management basics ok
Browse files Browse the repository at this point in the history
file+line breakpoints are now displayed in the source view gutter (very ugly for now)
  • Loading branch information
meeloo committed Jul 28, 2013
1 parent 4fadfd6 commit 7194947
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 10 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -974,11 +974,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "src/Xspray/DebugView.cpp"
timestampString = "396663056.948544"
timestampString = "396722679.133591"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "845"
endingLineNumber = "845"
startingLineNumber = "844"
endingLineNumber = "844"
landmarkName = "DebugView::OnCloseTab(const nuiEvent& event)"
landmarkType = "5">
</BreakpointContent>
Expand All @@ -990,11 +990,11 @@
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "src/Xspray/DebugView.cpp"
timestampString = "396663056.948544"
timestampString = "396722679.133591"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "800"
endingLineNumber = "800"
startingLineNumber = "799"
endingLineNumber = "799"
landmarkName = "DebugView::ShowSource(const nglPath&amp; rPath, int32 line, int32 col)"
landmarkType = "5">
</BreakpointContent>
Expand Down
5 changes: 5 additions & 0 deletions src/Xspray/Breakpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ Breakpoint::Breakpoint(lldb::SBBreakpoint breakpoint, lldb::LanguageType languag

}

bool Breakpoint::IsValid() const
{
return mBreakpoint.IsValid();
}

lldb::SBBreakpoint Breakpoint::GetBreakpoint() const
{
return mBreakpoint;
Expand Down
1 change: 1 addition & 0 deletions src/Xspray/Breakpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Breakpoint
};

lldb::SBBreakpoint GetBreakpoint() const;
bool IsValid() const;
Type GetType() const;
const nglPath& GetPath() const;
const nglString& GetSymbol() const;
Expand Down
7 changes: 3 additions & 4 deletions src/Xspray/DebugView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ void DebugView::OnStart(const nuiEvent& rEvent)
if (rContext.mTarget.IsValid())
{
//static SBBreakpoint breakpoint1 = rContext.mTarget.BreakpointCreateByName("TestXspray");
static SBBreakpoint breakpoint2 = rContext.mTarget.BreakpointCreateByLocation("Application.cpp", 67);
//static SBBreakpoint breakpoint2 = rContext.mTarget.BreakpointCreateByLocation("Application.cpp", 67);
Breakpoint* breakpoint = rContext.CreateBreakpointByLocation("/Users/meeloo/work/yalive/src/Application.cpp", 67, 0);
NGL_OUT("Breakpoint is valid: %s", YESNO(breakpoint->IsValid()));
//breakpoint.SetCallback(BPCallback, 0);

SBError error;
Expand Down Expand Up @@ -637,9 +639,6 @@ void DebugView::OnProcessConnected()
error);

NGL_OUT("Remote Launch result: %s\n", error.GetCString());
static SBBreakpoint breakpoint = rContext.mTarget.BreakpointCreateByName("TestXspray");
NGL_OUT("Breakpoint is valid: %s", YESNO(breakpoint.IsValid()));

}

void DebugView::OnProcessPaused()
Expand Down
21 changes: 21 additions & 0 deletions src/Xspray/DebuggerContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,27 @@ void DebuggerContext::GetBreakpointsForFile(const nglPath& rPath, std::vector<Br
}
}

void DebuggerContext::GetBreakpointsLinesForFile(const nglPath& rPath, std::set<int32>& rLines)
{
NGL_OUT("DebuggerContext::GetBreakpointsLinesForFile(%s) (among %d breakpoints)\n", rPath.GetChars(), mBreakpoints.size());
auto it = mBreakpoints.begin();
while (it != mBreakpoints.end())
{
Breakpoint* pBP = *it;
if (pBP->GetType() == Breakpoint::Location && pBP->GetPath() == rPath)
{
rLines.insert(pBP->GetLine());
NGL_OUT(" OK for %s %d\n", pBP->GetPath().GetChars(), pBP->GetLine());
}
else
{
NGL_OUT(" Skip %s %d\n", pBP->GetPath().GetChars(), pBP->GetLine());
}
++it;
}
}


void DebuggerContext::GetBreakpointsForFiles(std::vector<Breakpoint*>& rBreakpoints)
{
auto it = mBreakpoints.begin();
Expand Down
1 change: 1 addition & 0 deletions src/Xspray/DebuggerContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class DebuggerContext
Breakpoint* CreateBreakpointForException(lldb::LanguageType language, bool BreakOnCatch, bool BreakOnThrow);

void GetBreakpointsForFile(const nglPath& rPath, std::vector<Breakpoint*>& rBreakpoints);
void GetBreakpointsLinesForFile(const nglPath& rPath, std::set<int32>& rLines);
void GetBreakpointsForFiles(std::vector<Breakpoint*>& rBreakpoints);
void GetBreakpointsForExceptions(std::vector<Breakpoint*>& rBreakpoints);
void GetBreakpointsForSymbols(std::vector<Breakpoint*>& rBreakpoints);
Expand Down
12 changes: 12 additions & 0 deletions src/Xspray/SourceView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,9 @@ nuiRect SourceView::GetSelectionRect()

bool SourceView::Draw(nuiDrawContext* pContext)
{
std::set<int32> breakpoints;
GetDebuggerContext().GetBreakpointsLinesForFile(mPath, breakpoints);

if (mLine >= 0)
{
nuiRect rect = GetSelectionRect();
Expand All @@ -308,6 +311,15 @@ bool SourceView::Draw(nuiDrawContext* pContext)

y = ToAbove((float)(i+1) * h);

if (breakpoints.find(i+1) != breakpoints.end())
{
pContext->SetFillColor("blue");
pContext->SetStrokeColor("black");
nuiRect r(0.0, y - h, mGutterMargin, h);
r.Grow(-1, -1);
pContext->DrawRect(r, eStrokeAndFillShape);
}

nuiTextLayout* pLineNumber = line.first;
nuiRect rln = pLineNumber->GetRect();
pContext->DrawText(mGutterWidth - (rln.GetWidth() + mGutterMargin), y, *pLineNumber);
Expand Down
1 change: 1 addition & 0 deletions src/Xspray/SourceView.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class SourceLine : public nuiTextLayout

const nglString& GetText() const;
void Layout();

protected:
nglString mText;
int mOffset;
Expand Down

0 comments on commit 7194947

Please sign in to comment.