[llvm-commits] [TV] r79241 - in /television/trunk: ./ lib/Snapshot/ tools/llvm-tv/
Misha Brukman
brukman+llvm at gmail.com
Mon Aug 17 08:26:32 PDT 2009
Author: brukman
Date: Mon Aug 17 10:26:31 2009
New Revision: 79241
URL: http://llvm.org/viewvc/llvm-project?rev=79241&view=rev
Log:
* Added a couple wxString utility functions
* Updated usage of LLVM and wxWidgets APIs to fix the build
Added:
television/trunk/tools/llvm-tv/wxUtils.cpp
television/trunk/tools/llvm-tv/wxUtils.h
Modified:
television/trunk/Makefile.common
television/trunk/Makefile.config.in
television/trunk/lib/Snapshot/Makefile
television/trunk/tools/llvm-tv/CodeViewer.cpp
television/trunk/tools/llvm-tv/GraphPrinters.cpp
television/trunk/tools/llvm-tv/Makefile
television/trunk/tools/llvm-tv/PictureFrame.cpp
television/trunk/tools/llvm-tv/PictureFrame.h
television/trunk/tools/llvm-tv/TVApplication.cpp
television/trunk/tools/llvm-tv/TVApplication.h
television/trunk/tools/llvm-tv/TVFrame.cpp
television/trunk/tools/llvm-tv/TVSnapshot.cpp
television/trunk/tools/llvm-tv/TVSnapshot.h
television/trunk/tools/llvm-tv/TVSnapshotList.cpp
television/trunk/tools/llvm-tv/TVSnapshotList.h
television/trunk/tools/llvm-tv/TVTextCtrl.h
television/trunk/tools/llvm-tv/TVTreeItem.cpp
Modified: television/trunk/Makefile.common
URL: http://llvm.org/viewvc/llvm-project/television/trunk/Makefile.common?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/Makefile.common (original)
+++ television/trunk/Makefile.common Mon Aug 17 10:26:31 2009
@@ -16,3 +16,18 @@
# Include LLVM's Master Makefile.
#
include $(LLVM_SRC_ROOT)/Makefile.rules
+
+# Make sure we can access PoolAlloc's headers and libraries
+PALibDir = $(POOLALLOC_OBJ_ROOT)/$(BuildMode)/lib
+CPP.Flags += -I$(POOLALLOC_SRC_ROOT)/include
+LD.Flags += -L$(PALibDir)
+
+# Link in PoolAlloc libraries
+ifdef PALIBS
+PALibsOptions := $(patsubst %.a.o, -l%, $(addsuffix .o, $(PALIBS)))
+PALibsOptions := $(patsubst %.o, $(PALibDir)/%.o, $(PALibsOptions))
+PAUsedLibs := $(patsubst %.a.o, lib%.a, $(addsuffix .o, $(PALIBS)))
+PALibsPaths := $(addprefix $(PALibDir)/,$(PAUsedLibs))
+
+ExtraLibs += $(PALibsPaths)
+endif
Modified: television/trunk/Makefile.config.in
URL: http://llvm.org/viewvc/llvm-project/television/trunk/Makefile.config.in?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/Makefile.config.in (original)
+++ television/trunk/Makefile.config.in Mon Aug 17 10:26:31 2009
@@ -10,17 +10,17 @@
PROJECT_NAME = @PACKAGE_NAME@
PROJ_VERSION = @PACKAGE_VERSION@
-#
# Set this variable to the top of the LLVM source tree.
-#
LLVM_SRC_ROOT = @LLVM_SRC@
-#
# Set this variable to the top level directory where LLVM was built
# (this is *not* the same as OBJ_ROOT as defined in LLVM's Makefile.config).
-#
LLVM_OBJ_ROOT = @LLVM_OBJ@
+# PoolAlloc source and object directories.
+POOLALLOC_SRC_ROOT = @POOLALLOC_SRC@
+POOLALLOC_OBJ_ROOT = @POOLALLOC_OBJ@
+
# Set the directory root of this project's source files
PROJ_SRC_ROOT := $(subst //,/, at abs_top_srcdir@)
@@ -33,7 +33,7 @@
# Include LLVM's Master Makefile.
include $(LLVM_OBJ_ROOT)/Makefile.config
-#Set SourceDir for backwards compatbility.
+# Set SourceDir for backwards compatbility.
ifndef SourceDir
SourceDir=$(PROJ_SRC_DIR)
endif
Modified: television/trunk/lib/Snapshot/Makefile
URL: http://llvm.org/viewvc/llvm-project/television/trunk/lib/Snapshot/Makefile?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/lib/Snapshot/Makefile (original)
+++ television/trunk/lib/Snapshot/Makefile Mon Aug 17 10:26:31 2009
@@ -1,5 +1,6 @@
LEVEL = ../..
LIBRARYNAME = LLVMTVSnapshot
+BUILD_ARCHIVE = 1
SHARED_LIBRARY = 1
include $(LEVEL)/Makefile.common
Modified: television/trunk/tools/llvm-tv/CodeViewer.cpp
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/CodeViewer.cpp?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/CodeViewer.cpp (original)
+++ television/trunk/tools/llvm-tv/CodeViewer.cpp Mon Aug 17 10:26:31 2009
@@ -6,6 +6,7 @@
#include "llvm/Instruction.h"
#include "llvm/Value.h"
#include "llvm/ADT/StringExtras.h"
+#include <wx/string.h>
#include <wx/listctrl.h>
#include <map>
#include <sstream>
Modified: television/trunk/tools/llvm-tv/GraphPrinters.cpp
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/GraphPrinters.cpp?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/GraphPrinters.cpp (original)
+++ television/trunk/tools/llvm-tv/GraphPrinters.cpp Mon Aug 17 10:26:31 2009
@@ -14,12 +14,12 @@
//
//===----------------------------------------------------------------------===//
+#include "dsa/DSGraph.h"
+#include "dsa/DataStructure.h"
+#include "llvm/Analysis/CallGraph.h"
#include "llvm/Function.h"
#include "llvm/Pass.h"
#include "llvm/Value.h"
-#include "llvm/Analysis/CallGraph.h"
-#include "llvm/Analysis/DataStructure/DataStructure.h"
-#include "llvm/Analysis/DataStructure/DSGraph.h"
#include "llvm/Support/GraphWriter.h"
#include "llvm/Support/raw_ostream.h"
#include <fstream>
@@ -51,7 +51,9 @@
return "Call Graph";
}
- static std::string getNodeLabel(CallGraphNode *Node, CallGraph *Graph) {
+ static std::string getNodeLabel(CallGraphNode *Node,
+ CallGraph *Graph,
+ bool ShortName) {
if (Node->getFunction())
return ((Value*)Node->getFunction())->getName();
else
@@ -62,21 +64,27 @@
namespace {
struct CallGraphPrinter : public ModulePass {
+ CallGraphPrinter() : ModulePass(&ID) {}
+
virtual bool runOnModule(Module &M) {
WriteGraphToFile(std::cerr, "callgraph", &getAnalysis<CallGraph>());
return false;
}
- void print(std::ostream &OS) const {}
+ //void print(std::ostream &OS) const {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<CallGraph>();
AU.setPreservesAll();
}
+
+ static const char ID;
};
- RegisterAnalysis<CallGraphPrinter> P2("print-callgraph",
- "Print Call Graph to 'dot' file");
+ const char CallGraphPrinter::ID = 0;
+
+ RegisterPass<CallGraphPrinter> P2("print-callgraph",
+ "Print Call Graph to 'dot' file");
}
//===----------------------------------------------------------------------===//
@@ -91,58 +99,70 @@
virtual std::string getFilename() = 0;
public:
+ DSModulePrinter() : ModulePass(&ID) {}
+
bool runOnModule(Module &M) {
DSType *DS = &getAnalysis<DSType>();
std::string File = getFilename();
std::ofstream of(File.c_str());
if (of.good()) {
- DS->getGlobalsGraph().print(of);
+ DS->getGlobalsGraph()->print(of);
of.close();
} else
errs() << "Error writing to " << File << "!\n";
return false;
}
- void print(std::ostream &os) const {}
+ //void print(std::ostream &os) const {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.template addRequired<DSType>();
AU.setPreservesAll();
}
+
+ static char ID;
};
template<class DSType>
+ char DSModulePrinter<DSType>::ID;
+
+ template<class DSType>
class DSFunctionPrinter : public ModulePass {
protected:
Function *F;
virtual std::string getFilename(Function &F) = 0;
public:
- DSFunctionPrinter(Function *_F) : F(_F) {}
+ DSFunctionPrinter(Function *_F) : ModulePass(&ID), F(_F) {}
bool runOnModule(Module &M) {
DSType *DS = &getAnalysis<DSType>();
std::string File = getFilename(*F);
std::ofstream of(File.c_str());
if (of.good()) {
- if (DS->hasGraph(*F)) {
- DS->getDSGraph(*F).print(of);
+ if (DS->hasDSGraph(*F)) {
+ DS->getDSGraph(*F)->print(of);
of.close();
} else
// Can be more creative and print the analysis name here
- std::cerr << "No DSGraph for: " << F->getName() << "\n";
+ errs() << "No DSGraph for: " << F->getName() << "\n";
} else
- std::cerr << "Error writing to " << File << "!\n";
+ errs() << "Error writing to " << File << "!\n";
return false;
}
- void print(std::ostream &os) const {}
+ //void print(std::ostream &os) const {}
void getAnalysisUsage(AnalysisUsage &AU) const {
AU.template addRequired<DSType>();
AU.setPreservesAll();
}
+
+ static const char ID;
};
+
+ template<class DSType>
+ const char DSFunctionPrinter<DSType>::ID = 0;
}
//===----------------------------------------------------------------------===//
@@ -156,7 +176,7 @@
struct BUFunctionPrinter : public DSFunctionPrinter<BUDataStructures> {
BUFunctionPrinter(Function *F) : DSFunctionPrinter<BUDataStructures>(F) {}
std::string getFilename(Function &F) {
- return "buds." + F.getName() + ".dot";
+ return "buds." + F.getName().str() + ".dot";
}
};
}
@@ -172,7 +192,7 @@
struct TDFunctionPrinter : public DSFunctionPrinter<TDDataStructures> {
TDFunctionPrinter(Function *F) : DSFunctionPrinter<TDDataStructures>(F) {}
std::string getFilename(Function &F) {
- return "tdds." + F.getName() + ".dot";
+ return "tdds." + F.getName().str() + ".dot";
}
};
}
@@ -189,7 +209,7 @@
LocalFunctionPrinter(Function *F)
: DSFunctionPrinter<LocalDataStructures>(F) {}
std::string getFilename(Function &F) {
- return "localds." + F.getName() + ".dot";
+ return "localds." + F.getName().str() + ".dot";
}
};
}
Modified: television/trunk/tools/llvm-tv/Makefile
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/Makefile?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/Makefile (original)
+++ television/trunk/tools/llvm-tv/Makefile Mon Aug 17 10:26:31 2009
@@ -1,14 +1,16 @@
LEVEL = ../..
TOOLNAME = llvm-tv
-LLVMLIBS = LLVMAnalysis.a LLVMBCReader LLVMBCWriter LLVMDataStructure \
- LLVMipa.a LLVMSupport.a LLVMTarget.a LLVMCore LLVMTransformUtils.a \
- LLVMSystem.a LLVMbzip2
+LLVMLIBS = LLVMAnalysis.a LLVMBitReader.a LLVMBitWriter.a \
+ LLVMipa.a LLVMSupport.a LLVMTarget.a LLVMCore.a \
+ LLVMTransformUtils.a LLVMSupport.a LLVMSystem.a
-# note: delete when FileUtils is assimilated into libsupport
-USEDLIBS = LLVMTVSnapshot
+USEDLIBS = LLVMTVSnapshot.a
-CPPFLAGS = $(shell wx-config --cflags)
-TOOLLINKOPTSB = $(shell wx-config --libs)
+# LLVMDataStructure.a comes from PoolAlloc, not LLVM proper.
+PALIBS = LLVMDataStructure.a
+
+CPPFLAGS = $(shell wx-config --cxxflags) -fno-strict-aliasing
+TOOLLINKOPTSB = $(shell wx-config --debug=yes --libs)
WXDIR = $(shell wx-config --prefix)
WXLIB = $(WXDIR)/lib
@@ -17,14 +19,16 @@
all :: $(LLVMToolDir)/llvm-tv.exe \
$(LLVMToolDir)/opt-snap
-LLVMTV = $(PROJ_OBJ_ROOT)/Debug/bin/llvm-tv
+LLVMTV = $(PROJ_OBJ_ROOT)/$(BuildMode)/bin/llvm-tv
$(LLVMToolDir)/llvm-tv.exe: Makefile
- echo exec env LD_LIBRARY_PATH=$(WXLIB):\$$LD_LIBRARY_PATH $(LLVMTV) \
- "2&>1 > /dev/null" > $@
+ echo "Creating llvm-tv.exe script"
+ echo exec env LD_LIBRARY_PATH=$(WXLIB):$(LibDir):\$$LD_LIBRARY_PATH $(LLVMTV) \
+ > $@
chmod u+x $@
$(LLVMToolDir)/opt-snap: Makefile
+ echo "Creating opt-snap script"
echo exec env LD_LIBRARY_PATH=$(WXLIB):\$$LD_LIBRARY_PATH \
OPTPASSES=\"$$\*\" opt -load=$(LibDir)/libLLVMTVSnapshot.so $$\* > $@
chmod u+x $@
Modified: television/trunk/tools/llvm-tv/PictureFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/PictureFrame.cpp?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/PictureFrame.cpp (original)
+++ television/trunk/tools/llvm-tv/PictureFrame.cpp Mon Aug 17 10:26:31 2009
@@ -3,12 +3,11 @@
// PictureFrame implementation
-bool PictureFrame::OnClose (wxCloseEvent &event) {
+void PictureFrame::OnClose(wxCloseEvent &event) {
myApp->GoodbyeFrom (this);
- Destroy ();
- return true;
+ Destroy();
}
-BEGIN_EVENT_TABLE (PictureFrame, wxFrame)
- EVT_CLOSE (PictureFrame::OnClose)
-END_EVENT_TABLE ()
+BEGIN_EVENT_TABLE(PictureFrame, wxFrame)
+ EVT_CLOSE(PictureFrame::OnClose)
+END_EVENT_TABLE()
Modified: television/trunk/tools/llvm-tv/PictureFrame.h
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/PictureFrame.h?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/PictureFrame.h (original)
+++ television/trunk/tools/llvm-tv/PictureFrame.h Mon Aug 17 10:26:31 2009
@@ -1,10 +1,10 @@
//===-- PictureFrame.h - Window containing PictureCanvas ---------*- C++ -*-==//
-//
+//
// The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
-//
+//
//===----------------------------------------------------------------------===//
//
// Window container for PictureCanvas objects.
@@ -23,17 +23,18 @@
///
class PictureFrame : public wxFrame {
TVApplication *myApp;
- void setupAppearance () {
- SetSize (wxRect (200, 200, 300, 300));
- Show (TRUE);
+ void setupAppearance() {
+ SetSize(wxRect(200, 200, 300, 300));
+ Show(TRUE);
}
public:
- PictureFrame (TVApplication *app, const char *windowTitle = "")
- : wxFrame (NULL, -1, windowTitle), myApp (app) {
+ PictureFrame(TVApplication *app, const char *windowTitle = "")
+ : wxFrame (NULL, -1, wxString(windowTitle, wxConvUTF8)), myApp (app) {
setupAppearance ();
}
- bool OnClose (wxCloseEvent &event);
- DECLARE_EVENT_TABLE ()
+ void OnClose(wxCloseEvent &event);
+
+ DECLARE_EVENT_TABLE()
};
#endif // PICTUREFRAME_H
Modified: television/trunk/tools/llvm-tv/TVApplication.cpp
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/TVApplication.cpp?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/TVApplication.cpp (original)
+++ television/trunk/tools/llvm-tv/TVApplication.cpp Mon Aug 17 10:26:31 2009
@@ -5,10 +5,13 @@
//===----------------------------------------------------------------------===//
#include "CodeViewer.h"
-#include "TVApplication.h"
#include "TVFrame.h"
#include "llvm-tv/Support/FileUtils.h"
#include "llvm-tv/Config.h"
+#undef _DEBUG
+#undef __WXDEBUG__
+#include "TVApplication.h"
+#include "wxUtils.h"
#include <wx/image.h>
#include <cerrno>
#include <iostream>
@@ -35,32 +38,32 @@
/// FatalErrorBox - pop up an error message and quit.
///
void FatalErrorBox (const std::string msg) {
- wxMessageBox(msg.c_str (), "Fatal Error", wxOK | wxICON_ERROR);
+ wxMessageBox(wxS(msg), wxT("Fatal Error"), wxOK | wxICON_ERROR);
exit (1);
}
static void setUpMenus (wxFrame *frame) {
wxMenuBar *menuBar = new wxMenuBar ();
- wxMenu *fileMenu = new wxMenu ("", 0);
- fileMenu->Append (wxID_OPEN, "Add module...");
- fileMenu->Append (LLVM_TV_REFRESH, "Refresh list");
- fileMenu->Append (wxID_EXIT, "Quit");
- menuBar->Append (fileMenu, "File");
-
- wxMenu *viewMenu = new wxMenu ("", 0);
- viewMenu->Append (LLVM_TV_CALLGRAPHVIEW, "View call graph");
- viewMenu->Append (LLVM_TV_CFGVIEW, "View control-flow graph");
- viewMenu->Append (LLVM_TV_BUDS_VIEW, "View BU datastructure graph");
- viewMenu->Append (LLVM_TV_TDDS_VIEW, "View TD datastructure graph");
- viewMenu->Append (LLVM_TV_LOCALDS_VIEW, "View Local datastructure graph");
- viewMenu->Append (LLVM_TV_CODEVIEW, "View code (interactive)");
- menuBar->Append (viewMenu, "View");
-
- wxMenu *helpMenu = new wxMenu ("", 0);
- helpMenu->Append (wxID_HELP_CONTENTS, "Help with LLVM-TV");
- helpMenu->Append (wxID_ABOUT, "About LLVM-TV");
- menuBar->Append (helpMenu, "Help");
+ wxMenu *fileMenu = new wxMenu (wxT(""), 0);
+ fileMenu->Append (wxID_OPEN, wxT("Add module..."));
+ fileMenu->Append (LLVM_TV_REFRESH, wxT("Refresh list"));
+ fileMenu->Append (wxID_EXIT, wxT("Quit"));
+ menuBar->Append (fileMenu, wxT("File"));
+
+ wxMenu *viewMenu = new wxMenu (wxT(""), 0);
+ viewMenu->Append (LLVM_TV_CALLGRAPHVIEW, wxT("View call graph"));
+ viewMenu->Append (LLVM_TV_CFGVIEW, wxT("View control-flow graph"));
+ viewMenu->Append (LLVM_TV_BUDS_VIEW, wxT("View BU datastructure graph"));
+ viewMenu->Append (LLVM_TV_TDDS_VIEW, wxT("View TD datastructure graph"));
+ viewMenu->Append (LLVM_TV_LOCALDS_VIEW, wxT("View Local datastructure graph"));
+ viewMenu->Append (LLVM_TV_CODEVIEW, wxT("View code (interactive)"));
+ menuBar->Append (viewMenu, wxT("View"));
+
+ wxMenu *helpMenu = new wxMenu (wxT(""), 0);
+ helpMenu->Append (wxID_HELP_CONTENTS, wxT("Help with LLVM-TV"));
+ helpMenu->Append (wxID_ABOUT, wxT("About LLVM-TV"));
+ menuBar->Append (helpMenu, wxT("Help"));
frame->SetMenuBar (menuBar);
}
Modified: television/trunk/tools/llvm-tv/TVApplication.h
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/TVApplication.h?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/TVApplication.h (original)
+++ television/trunk/tools/llvm-tv/TVApplication.h Mon Aug 17 10:26:31 2009
@@ -8,7 +8,7 @@
#define TVAPPLICATION_H
#include "TVSnapshotList.h"
-#include "wx/wx.h"
+#include <wx/wx.h>
#include <string>
#include <vector>
Modified: television/trunk/tools/llvm-tv/TVFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/TVFrame.cpp?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/TVFrame.cpp (original)
+++ television/trunk/tools/llvm-tv/TVFrame.cpp Mon Aug 17 10:26:31 2009
@@ -10,10 +10,14 @@
#include "DSAGraphDrawer.h"
#include "PictureFrame.h"
#include "TVApplication.h"
-#include "TVFrame.h"
#include "TVTextCtrl.h"
#include "TVTreeItem.h"
+#undef _DEBUG
+#undef __WXDEBUG__
+#include "TVFrame.h"
+#include "wxUtils.h"
#include "llvm-tv/Config.h"
+#include "llvm/System/Path.h"
#include <cassert>
#include <dirent.h>
#include <errno.h>
@@ -25,7 +29,7 @@
const wxPoint& pos, const wxSize& size,
long style)
: wxTreeCtrl(parent, id, pos, size, style), myFrame (frame) {
- wxTreeItemId rootId = AddRoot("Snapshots", -1, -1,TVTreeRootItem::instance());
+ AddRoot(wxT("Snapshots"), -1, -1, TVTreeRootItem::instance());
}
/// AddSnapshotsToTree - Given a list of snapshots the tree is populated
@@ -35,19 +39,19 @@
for (TVSnapshotList::iterator I = list->begin(), E = list->end();
I != E; ++I) {
// Get the Module associated with this snapshot and add it to the tree
- Module *M = I->getModule();
- wxTreeItemId id = AppendItem(rootId, I->label(), -1, -1,
- new TVTreeModuleItem(I->label(), M));
+ Module *M = (*I)->getModule();
+ wxTreeItemId id = AppendItem(rootId, wxS((*I)->label()), -1, -1,
+ new TVTreeModuleItem(wxS((*I)->label()), M));
// Loop over functions in the module and add them to the tree as children
for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
Function *F = I;
- if (!F->isExternal()) {
- const char *FuncName = F->getName().c_str();
+ if (!F->isDeclaration()) {
+ wxString FuncName = wxS(F->getName().str());
AppendItem(id, FuncName, -1, -1, new TVTreeFunctionItem(FuncName, I));
}
}
- }
+ }
}
/// updateSnapshotList - Update the tree with the current snapshot list
@@ -80,8 +84,8 @@
void TVTextCtrl::displayItem (TVTreeItemData *item) {
std::ostringstream Out;
item->print (Out);
- myTextCtrl->SetValue ("");
- myTextCtrl->AppendText (Out.str ().c_str ());
+ myTextCtrl->SetValue (wxT(""));
+ myTextCtrl->AppendText (wxS(Out.str ()));
myTextCtrl->ShowPosition (0);
myTextCtrl->SetInsertionPoint (0);
}
@@ -100,17 +104,17 @@
}
void TVFrame::refreshSnapshotList () {
-
if (!myApp->getSnapshotList()->refreshList())
- FatalErrorBox ("trying to open directory " + myApp->getSnapshotList()->getSnapshotDirName() + ": "
- + strerror(errno));
+ FatalErrorBox ("trying to open directory " +
+ myApp->getSnapshotList()->getSnapshotDirName() + ": " +
+ strerror(errno));
if (myTreeCtrl != 0)
myTreeCtrl->updateSnapshotList(myApp->getSnapshotList());
}
void TVFrame::initializeSnapshotListAndView () {
refreshSnapshotList ();
- SetStatusText ("Snapshot list has been loaded.");
+ SetStatusText (wxT("Snapshot list has been loaded."));
}
//==------------------------------------------------------------------------==//
@@ -130,7 +134,7 @@
displayers.resize (1 + pageIndex);
displayers[pageIndex] = displayer;
return AddPage (displayer->getWindow (),
- displayer->getDisplayTitle (0).c_str (), true);
+ wxS(displayer->getDisplayTitle (0)), true);
}
void TVNotebook::OnSelChanged (wxNotebookEvent &event) {
@@ -146,16 +150,17 @@
//==------------------------------------------------------------------------==//
-static const wxString Explanation
- ("Click on a Module or Function in the left-hand pane\n"
- "to display its code in the right-hand pane. Then, you\n"
- "can choose from the View menu to see graphical code views.\n");
+static const wxString Explanation(
+ "Click on a Module or Function in the left-hand pane\n"
+ "to display its code in the right-hand pane. Then, you\n"
+ "can choose from the View menu to see graphical code views.\n",
+ wxConvUTF8);
/// TVFrame constructor - used to set up typical appearance of visualizer's
/// top-level window.
///
TVFrame::TVFrame (TVApplication *app, const char *title)
- : wxFrame (NULL, -1, title), myApp (app) {
+ : wxFrame (NULL, -1, wxS(title)), myApp (app) {
// Set up appearance
CreateStatusBar ();
SetSize (wxRect (100, 100, 500, 200));
@@ -184,7 +189,7 @@
/// OnHelp - display the help dialog
///
void TVFrame::OnHelp (wxCommandEvent &event) {
- wxMessageBox (Explanation, "Help with LLVM-TV");
+ wxMessageBox (Explanation, wxT("Help with LLVM-TV"));
}
/// OnExit - respond to a request to exit the program.
@@ -196,10 +201,11 @@
/// OnExit - respond to a request to display the About box.
///
void TVFrame::OnAbout (wxCommandEvent &event) {
- wxMessageBox("LLVM Visualization Tool\n\n"
- "By Misha Brukman, Tanya Brethour, and Brian Gaeke\n"
- "Copyright (C) 2004 University of Illinois at Urbana-Champaign\n"
- "http://llvm.cs.uiuc.edu", "About LLVM-TV");
+ wxMessageBox(wxT("LLVM Visualization Tool\n\n"
+ "By Misha Brukman, Tanya Brethour, and Brian Gaeke\n"
+ "Copyright (C) 2004 University of Illinois at Urbana-Champaign\n"
+ "http://llvm.cs.uiuc.edu"),
+ wxT("About LLVM-TV"));
}
/// OnRefresh - respond to a request to refresh the list
@@ -209,13 +215,20 @@
}
void TVFrame::OnOpen (wxCommandEvent &event) {
- wxFileDialog d (this, "Choose a bytecode file to display");
+ wxFileDialog d (this, wxT("Choose a bytecode file to display"));
int result = d.ShowModal ();
if (result == wxID_CANCEL) return;
// FIXME: the rest of this method can be moved into the "snapshots
// list" object
- std::string command = std::string("cp ") + std::string(d.GetPath ().c_str ()) + " " + snapshotsPath;
- system (command.c_str ());
+ llvm::sys::Path source(std::string(d.GetPath().mb_str()));
+ llvm::sys::Path dest(snapshotsPath);
+ dest.appendComponent(source.getLast());
+ std::string ErrMsg;
+ llvm::sys::CopyFile(dest, source, &ErrMsg);
+ if (!ErrMsg.empty()) {
+ errs() << "Error copying bitcode file to snapshots dir: " << ErrMsg << "\n";
+ return;
+ }
refreshSnapshotList ();
}
@@ -231,7 +244,7 @@
PictureFrame *wind = new PictureFrame (this);
allMyWindows.push_back (wind);
ItemDisplayer *drawer = new Grapher (wind);
- wind->SetTitle (drawer->getDisplayTitle (item).c_str ());
+ wind->SetTitle (wxS(drawer->getDisplayTitle (item)));
allMyDisplayers.push_back (drawer);
drawer->displayItem (item);
}
Modified: television/trunk/tools/llvm-tv/TVSnapshot.cpp
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/TVSnapshot.cpp?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/TVSnapshot.cpp (original)
+++ television/trunk/tools/llvm-tv/TVSnapshot.cpp Mon Aug 17 10:26:31 2009
@@ -1,13 +1,38 @@
+//===- TVSnapshots.cpp - Read bytecode file -------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+//
+//===----------------------------------------------------------------------===//
+
#include "TVSnapshot.h"
-#include "llvm/Bytecode/Reader.h"
+#include "llvm/Bitcode/ReaderWriter.h"
+#include "llvm/Support/MemoryBuffer.h"
#include "llvm-tv/Config.h"
+#include "llvm/Support/raw_ostream.h"
+#include <string>
using namespace llvm;
void TVSnapshot::readBytecodeFile () {
- std::string errorStr;
- M = ParseBytecodeFile (filename, &errorStr);
- if (!M)
- throw std::string ("Error reading bytecode from '" + filename + "': "
- + errorStr);
-}
+ LLVMContext &Context = getGlobalContext();
+ std::string ErrorMsg;
+ std::auto_ptr<MemoryBuffer> Buffer(MemoryBuffer::getFile(filename.c_str(),
+ &ErrorMsg));
+ if (Buffer.get()) {
+ M = ParseBitcodeFile(Buffer.get(), Context, &ErrorMsg);
+ } else {
+ errs() << filename << ": could not load into memory.\n";
+ errs() << "Reason: " << ErrorMsg << "\n";
+ return;
+ }
+ if (0 == M) {
+ errs() << filename << ": bitcode didn't read correctly.\n";
+ errs() << "Reason: " << ErrorMsg << "\n";
+ }
+}
Modified: television/trunk/tools/llvm-tv/TVSnapshot.h
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/TVSnapshot.h?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/TVSnapshot.h (original)
+++ television/trunk/tools/llvm-tv/TVSnapshot.h Mon Aug 17 10:26:31 2009
@@ -23,10 +23,13 @@
void readBytecodeFile ();
void fixLabel () { myLabel = basename ((char*)myLabel.c_str ()) ; }
public:
- //TVSnapshot () : M (0), filename (), myLabel (filename) { }
- TVSnapshot (const std::string &_name) : M (0), filename (_name), myLabel (filename) { fixLabel(); }
- TVSnapshot (const char *_name) : M (0), filename (_name), myLabel (filename) { fixLabel(); }
- const char *label () const { return myLabel.c_str (); }
+ explicit TVSnapshot (const std::string &_name)
+ : M (0), filename (_name), myLabel (filename) { fixLabel(); }
+ explicit TVSnapshot (const char *_name)
+ : M (0), filename (_name), myLabel (filename) { fixLabel(); }
+ ~TVSnapshot() { delete M; }
+
+ const char *label () const { return myLabel.c_str (); }
unsigned getTimestamp () const { return (unsigned) strtol (label(), 0, 0); }
bool operator < (const TVSnapshot &s) const {
return getTimestamp () < s.getTimestamp ();
Modified: television/trunk/tools/llvm-tv/TVSnapshotList.cpp
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/TVSnapshotList.cpp?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/TVSnapshotList.cpp (original)
+++ television/trunk/tools/llvm-tv/TVSnapshotList.cpp Mon Aug 17 10:26:31 2009
@@ -5,37 +5,53 @@
//===----------------------------------------------------------------------===//
#include "TVSnapshotList.h"
+#include "llvm/System/Path.h"
+#include "llvm/Support/raw_ostream.h"
#include <dirent.h>
+#include <string>
+#include <vector>
+TVSnapshotList::~TVSnapshotList() {
+ for (std::vector<TVSnapshot*>::iterator i = mySnapshotList.begin(),
+ e = mySnapshotList.end(); i != e; ++i) {
+ delete *i;
+ }
+ mySnapshotList.clear();
+}
-//Each time this function is called the directory is rescanned
-//for any new snapshots
+// Each time this function is called the directory is rescanned
+// for any new snapshots.
bool TVSnapshotList::refreshList() {
- // re-load the list of snapshots
- const char *directoryName = mySnapshotDirName.c_str();
- clearList();
- DIR *d = opendir(directoryName);
- if (!d)
- return false;
-
- while (struct dirent *de = readdir (d))
- if (memcmp(de->d_name, ".", 2) && memcmp(de->d_name, "..", 3))
- addSnapshot(mySnapshotDirName + "/" + de->d_name);
-
- sortList();
-
- closedir (d);
- return true;
+ clearList();
+ llvm::sys::Path path(mySnapshotDirName);
+ std::set<llvm::sys::Path> contents;
+ std::string ErrMsg;
+ path.getDirectoryContents(contents, &ErrMsg);
+
+ if (!ErrMsg.empty()) {
+ errs() << "Error getting contents of dir: " << mySnapshotDirName
+ << " : " << ErrMsg << "\n";
+ return false;
+ }
+
+ for (std::set<llvm::sys::Path>::const_iterator i = contents.begin(),
+ e = contents.end(); i != e; ++i) {
+ if (!(*i).isDirectory() && (*i).canRead()) {
+ errs() << "Processing: " << (*i).toString() << "\n";
+ addSnapshot((*i).toString());
+ }
+ }
+
+ sortList();
+ return true;
}
-//Sort the snapshot list
+// Sort the snapshot list.
void TVSnapshotList::sortList() {
sort (mySnapshotList.begin (), mySnapshotList.end ());
}
-
-//Add a snapshot to our vector of snapshots
-void TVSnapshotList::addSnapshot(std::string snapshotName) {
- mySnapshotList.push_back(snapshotName);
+// Add a snapshot to our vector of snapshots.
+void TVSnapshotList::addSnapshot(const std::string &snapshotName) {
+ mySnapshotList.push_back(new TVSnapshot(snapshotName));
}
-
Modified: television/trunk/tools/llvm-tv/TVSnapshotList.h
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/TVSnapshotList.h?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/TVSnapshotList.h (original)
+++ television/trunk/tools/llvm-tv/TVSnapshotList.h Mon Aug 17 10:26:31 2009
@@ -7,31 +7,34 @@
#ifndef TVSNAPSHOTLIST_H
#define TVSNAPSHOTLIST_H
+#include "TVSnapshot.h"
#include <string>
#include <vector>
-#include "TVSnapshot.h"
/// Containts a list of snapshots and the directory they are in.
/// Put into a class to easily pass between the application and frame
///
class TVSnapshotList {
- std::vector<TVSnapshot> mySnapshotList;
+ std::vector<TVSnapshot*> mySnapshotList;
std::string mySnapshotDirName;
public:
- TVSnapshotList(std::string dir) : mySnapshotDirName(dir) {}
+ TVSnapshotList(const std::string &dir) : mySnapshotDirName(dir) {}
+ ~TVSnapshotList();
+
std::string getSnapshotDirName() { return mySnapshotDirName; }
- void setSnapshotDirName(std::string dir) { mySnapshotDirName = dir; }
- void addSnapshot(std::string snapshotName);
+ void setSnapshotDirName(const std::string &dir) {
+ mySnapshotDirName = dir;
+ }
+
+ void addSnapshot(const std::string &snapshotName);
void clearList() { mySnapshotList.clear(); }
void sortList();
bool refreshList();
- //Iterators
- typedef std::vector<TVSnapshot>::iterator iterator;
+ // Iterators
+ typedef std::vector<TVSnapshot*>::iterator iterator;
iterator begin() { return mySnapshotList.begin(); }
iterator end() { return mySnapshotList.end(); }
-
};
-
-#endif
+#endif
Modified: television/trunk/tools/llvm-tv/TVTextCtrl.h
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/TVTextCtrl.h?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/TVTextCtrl.h (original)
+++ television/trunk/tools/llvm-tv/TVTextCtrl.h Mon Aug 17 10:26:31 2009
@@ -3,12 +3,12 @@
#include "TVWindowIDs.h"
#include "ItemDisplayer.h"
-#include "wx/textctrl.h"
+#include <wx/textctrl.h>
class TVTextCtrl : public ItemDisplayer {
wxTextCtrl *myTextCtrl;
public:
- TVTextCtrl (wxWindow *_parent, const wxString &_value = "") {
+ TVTextCtrl (wxWindow *_parent, const wxString &_value = wxT("")) {
myTextCtrl = new wxTextCtrl (_parent, LLVM_TV_TEXT_CTRL, _value,
wxDefaultPosition, wxDefaultSize,
wxTE_READONLY | wxTE_MULTILINE | wxHSCROLL);
Modified: television/trunk/tools/llvm-tv/TVTreeItem.cpp
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/TVTreeItem.cpp?rev=79241&r1=79240&r2=79241&view=diff
==============================================================================
--- television/trunk/tools/llvm-tv/TVTreeItem.cpp (original)
+++ television/trunk/tools/llvm-tv/TVTreeItem.cpp Mon Aug 17 10:26:31 2009
@@ -1,24 +1,26 @@
#include "TVTreeItem.h"
#include "llvm/Module.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
static TVTreeRootItem* theInstance = 0;
TVTreeRootItem* TVTreeRootItem::instance() {
if (theInstance == 0) {
- theInstance = new TVTreeRootItem("Snapshot Root");
+ theInstance = new TVTreeRootItem(wxT("Snapshot Root"));
}
return theInstance;
}
void TVTreeModuleItem::print(std::ostream &os) {
- myModule->print(os);
+ // TODO: update to current LLVM API.
+ //myModule->print(os);
}
-void TVTreeFunctionItem::print(std::ostream &os) {
+void TVTreeFunctionItem::print(std::ostream &os) {
myFunc->print(os);
}
-std::string TVTreeFunctionItem::getTitle () {
- return myFunc->getName () + "()";
+std::string TVTreeFunctionItem::getTitle() {
+ return myFunc->getName().str() + "()";
}
Added: television/trunk/tools/llvm-tv/wxUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/wxUtils.cpp?rev=79241&view=auto
==============================================================================
--- television/trunk/tools/llvm-tv/wxUtils.cpp (added)
+++ television/trunk/tools/llvm-tv/wxUtils.cpp Mon Aug 17 10:26:31 2009
@@ -0,0 +1,12 @@
+
+#include "wxUtils.h"
+#include <wx/string.h>
+#include <string>
+
+wxString wxS(const char* str) {
+ return wxString(str, wxConvUTF8);
+}
+
+wxString wxS(const std::string &str) {
+ return wxString(str.c_str(), wxConvUTF8);
+}
Added: television/trunk/tools/llvm-tv/wxUtils.h
URL: http://llvm.org/viewvc/llvm-project/television/trunk/tools/llvm-tv/wxUtils.h?rev=79241&view=auto
==============================================================================
--- television/trunk/tools/llvm-tv/wxUtils.h (added)
+++ television/trunk/tools/llvm-tv/wxUtils.h Mon Aug 17 10:26:31 2009
@@ -0,0 +1,12 @@
+
+#ifndef WX_UTILS_H
+#define WX_UTILS_H
+
+#include <wx/string.h>
+#include <string>
+
+wxString wxS(const char* str);
+
+wxString wxS(const std::string &str);
+
+#endif
More information about the llvm-commits
mailing list