From 49ad0141cf5600285f423e60a622eb9c4c7bc13a Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Sun, 21 Jun 2009 23:30:18 +0000 Subject: [PATCH] Added StatementAtAddress() returning the statement at a given target address. Needs optimization (iterates through all statements ATM). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31169 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/debugger/model/SourceCode.cpp | 13 +++++++++++++ src/apps/debugger/model/SourceCode.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/apps/debugger/model/SourceCode.cpp b/src/apps/debugger/model/SourceCode.cpp index d93fb2062b..f38bfe94e6 100644 --- a/src/apps/debugger/model/SourceCode.cpp +++ b/src/apps/debugger/model/SourceCode.cpp @@ -53,6 +53,19 @@ SourceCode::StatementAt(int32 index) const } +Statement* +SourceCode::StatementAtAddress(target_addr_t address) const +{ + // TODO: Optimize! + for (int32 i = 0; Statement* statement = fStatements.ItemAt(i); i++) { + if (statement->ContainsAddress(address)) + return statement; + } + + return NULL; +} + + bool SourceCode::AddLine(const char* _line) { diff --git a/src/apps/debugger/model/SourceCode.h b/src/apps/debugger/model/SourceCode.h index cd81ce27a8..c106283178 100644 --- a/src/apps/debugger/model/SourceCode.h +++ b/src/apps/debugger/model/SourceCode.h @@ -24,6 +24,7 @@ public: int32 CountStatements() const; Statement* StatementAt(int32 index) const; + Statement* StatementAtAddress(target_addr_t address) const; bool AddLine(const char* line); // clones