Quotes should be printed before private prefix; some code clean up.
[llvm/msp430.git] / lib / Debugger / RuntimeInfo.cpp
blob2f0ff72a771e90f3a268db74a95958d833a0c09e
1 //===-- RuntimeInfo.cpp - Compute and cache info about running program ----===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements the RuntimeInfo and related classes, by querying and
11 // cachine information from the running inferior process.
13 //===----------------------------------------------------------------------===//
15 #include "llvm/Debugger/InferiorProcess.h"
16 #include "llvm/Debugger/ProgramInfo.h"
17 #include "llvm/Debugger/RuntimeInfo.h"
18 using namespace llvm;
20 //===----------------------------------------------------------------------===//
21 // StackFrame class implementation
23 StackFrame::StackFrame(RuntimeInfo &ri, void *ParentFrameID)
24 : RI(ri), SourceInfo(0) {
25 FrameID = RI.getInferiorProcess().getPreviousFrame(ParentFrameID);
26 if (FrameID == 0) throw "Stack frame does not exist!";
28 // Compute lazily as needed.
29 FunctionDesc = 0;
32 const GlobalVariable *StackFrame::getFunctionDesc() {
33 if (FunctionDesc == 0)
34 FunctionDesc = RI.getInferiorProcess().getSubprogramDesc(FrameID);
35 return FunctionDesc;
38 /// getSourceLocation - Return the source location that this stack frame is
39 /// sitting at.
40 void StackFrame::getSourceLocation(unsigned &lineNo, unsigned &colNo,
41 const SourceFileInfo *&sourceInfo) {
42 if (SourceInfo == 0) {
43 const GlobalVariable *SourceDesc = 0;
44 RI.getInferiorProcess().getFrameLocation(FrameID, LineNo,ColNo, SourceDesc);
45 SourceInfo = &RI.getProgramInfo().getSourceFile(SourceDesc);
48 lineNo = LineNo;
49 colNo = ColNo;
50 sourceInfo = SourceInfo;
53 //===----------------------------------------------------------------------===//
54 // RuntimeInfo class implementation
56 /// materializeFrame - Create and process all frames up to and including the
57 /// specified frame number. This throws an exception if the specified frame
58 /// ID is nonexistant.
59 void RuntimeInfo::materializeFrame(unsigned ID) {
60 assert(ID >= CallStack.size() && "no need to materialize this frame!");
61 void *CurFrame = 0;
62 if (!CallStack.empty())
63 CurFrame = CallStack.back().getFrameID();
65 while (CallStack.size() <= ID) {
66 CallStack.push_back(StackFrame(*this, CurFrame));
67 CurFrame = CallStack.back().getFrameID();