#include "core/BasicBlock.hxx"
#include "core/InformationManager.hxx"
#include "core/events/RenameFunctionEvent.hxx"
+
+#include "widgets/FridaDock.hxx"
+#include "widgets/LogDock.hxx"
#include "widgets/ScriptingDock.hxx"
#include "widgets/CFGScene.hxx"
#include "widgets/FunctionWidget.hxx"
if (!loader->load())
LOG4CXX_ERROR(logger, "Loading plugin failed: " << loader->errorString().toStdString());
interpreter["GUILE"] = qobject_cast<Interpreter*>(loader->instance());
- scripting = new ScriptingDock(interpreter["GUILE"], tr("Scripting"), this);
- scripting->setAllowedAreas(Qt::BottomDockWidgetArea);
- addDockWidget(Qt::BottomDockWidgetArea, scripting);
+ fdock = new FridaDock(tr("Frida Dock"), this);
+
+ fdock->addTab(new LogDock(fdock), "Log");
+
+ fdock->addTab(new ScriptingDock(interpreter["GUILE"], fdock), "guile");
+ fdock->setAllowedAreas(Qt::BottomDockWidgetArea);
+ addDockWidget(Qt::BottomDockWidgetArea, fdock);
QAction* guileLoad = new QAction(tr("&GUILE"), this);
interpretermenu->addAction(guileLoad);
connect(guileLoad, &QAction::triggered,
class InformationManager;
class FunctionWidget;
class BasicBlockWidget;
-class ScriptingDock;
+class FridaDock;
class Interpreter;
class Mainwindow : public QMainWindow {
QTreeWidget * listWidget;
QStackedWidget * stackedWidget;
QDockWidget * dockWidget;
- ScriptingDock * scripting;
+ FridaDock * fdock;
QAction *exitAction;
QAction *openAction;
--- /dev/null
+#include "FridaDock.hxx"
+
+FridaDock::FridaDock(const QString& title, QWidget * parent)
+ : QDockWidget(title, parent)
+ , tabWidget(new QTabWidget) {
+
+ setWidget(tabWidget);
+}
+
+void FridaDock::addTab(QWidget* widget, const QString& name) {
+ tabWidget->addTab(widget, name);
+}
--- /dev/null
+#ifndef INCLUDE__FridaDock_hxx_
+#define INCLUDE__FridaDock_hxx_
+
+#include "gui/qt.hxx"
+
+class FridaDock : public QDockWidget {
+ Q_OBJECT
+public:
+ FridaDock(const QString& title, QWidget * parent = 0);
+
+ void addTab(QWidget* widget, const QString& name);
+
+private:
+ QTabWidget* tabWidget;
+};
+
+#endif /* INCLUDE__FridaDock_hxx_ */
--- /dev/null
+#include "LogDock.hxx"
+#include "FridaDock.hxx"
+#include "LogDockAppender.hxx"
+
+#include "log4cxx/basicconfigurator.h"
+
+LogDock::LogDock(FridaDock* parent)
+ : QTableWidget(0, 3, parent) {
+ verticalHeader()->hide();
+ horizontalHeader()->hide();
+ horizontalHeader()->setStretchLastSection(true);
+ verticalHeader()->setDefaultSectionSize(18);
+ appender = new LogDockAppender;
+ appender->setTarget(this);
+ log4cxx::BasicConfigurator::configure(appender);
+}
+
+LogDock::~LogDock() {
+ delete appender;
+}
--- /dev/null
+#ifndef INCLUDE__LogDock_hxx_
+#define INCLUDE__LogDock_hxx_
+
+#include "gui/qt.hxx"
+#include <log4cxx/appenderskeleton.h>
+
+class FridaDock;
+class LogDockAppender;
+
+class LogDock : public QTableWidget {
+ Q_OBJECT
+public:
+ LogDock(FridaDock* parent);
+ virtual ~LogDock();
+ log4cxx::Appender* getAppender();
+private:
+ LogDockAppender* appender;
+ friend class LogDockAppender;
+};
+
+#endif /* INCLUDE__LogDock_hxx_ */
--- /dev/null
+#include "LogDockAppender.hxx"
+#include "LogDock.hxx"
+
+#include <log4cxx/patternlayout.h>
+
+using namespace log4cxx::helpers;
+
+IMPLEMENT_LOG4CXX_OBJECT(LogDockAppender)
+
+LogDockAppender::LogDockAppender()
+: timeformat("%T") {
+ layout = new PatternLayout("%d{MMM dd yyyy HH:mm:ss,SSS} - %m %n");
+}
+
+void LogDockAppender::append(const spi::LoggingEventPtr& event, Pool& p) {
+ log4cxx::LogString message, timestamp;
+
+ if ( this->layout == NULL ) {
+ LOG4CXX_ENCODE_CHAR(nameStr, name);
+ std::string msg("No Layout set for the appender named [ ");
+ msg.append(nameStr);
+ msg.append(" ].");
+
+ LOG4CXX_DECODE_CHAR(msgL, msg);
+ errorHandler->error(msgL);
+ return;
+ }
+
+ layout->format(message, event, p);
+ timeformat.format(timestamp, event->getTimeStamp(), p);
+ LOG4CXX_ENCODE_CHAR(messageencode, message);
+ LOG4CXX_ENCODE_CHAR(timestampencode, timestamp);
+
+ int rowcount = target->rowCount();
+ target->insertRow(rowcount);
+ target->setItem(rowcount, 0, new QTableWidgetItem(timestampencode.c_str()));
+ target->setItem(rowcount, 1, new QTableWidgetItem(event->getLevel()->toString().c_str()));
+ target->setItem(rowcount, 2, new QTableWidgetItem(messageencode.c_str()));
+ target->resizeColumnsToContents();
+}
+
+void LogDockAppender::setTarget(LogDock *target) {
+ this->target = target;
+}
+
+void LogDockAppender::close() {
+
+}
+
+bool LogDockAppender::requiresLayout() const {
+ return true;
+}
--- /dev/null
+#ifndef INCLUDE__LogDockAppender_hxx_
+#define INCLUDE__LogDockAppender_hxx_
+
+#include <log4cxx/appenderskeleton.h>
+#include <log4cxx/spi/loggingevent.h>
+#include <log4cxx/helpers/strftimedateformat.h>
+
+class LogDock;
+
+using namespace log4cxx;
+
+class LogDockAppender : public AppenderSkeleton {
+public:
+ LogDockAppender();
+
+ void setTarget(LogDock* target);
+ void append(const spi::LoggingEventPtr& event, helpers::Pool& p);
+ void close();
+ bool requiresLayout() const;
+
+ DECLARE_LOG4CXX_OBJECT(LogDockAppender)
+ BEGIN_LOG4CXX_CAST_MAP()
+ LOG4CXX_CAST_ENTRY(LogDockAppender)
+ LOG4CXX_CAST_ENTRY_CHAIN(AppenderSkeleton)
+ END_LOG4CXX_CAST_MAP()
+private:
+ LogDock* target;
+ helpers::StrftimeDateFormat timeformat;
+};
+
+LOG4CXX_PTR_DEF(LogDockAppender);
+
+#endif /* INCLUDE__LogDockAppender_hxx_ */
#include "ScriptingDock.hxx"
+#include "FridaDock.hxx"
+
#include "bindings/Interpreter.hxx"
#include <sstream>
-ScriptingDock::ScriptingDock(Interpreter* interpreter, const QString& title, QWidget * parent)
- : QDockWidget(title, parent)
+ScriptingDock::ScriptingDock(Interpreter* interpreter, FridaDock* parent)
+ : QWidget(parent)
, logger(log4cxx::Logger::getLogger("ScriptingDock"))
, interpreter(interpreter) {
- QTabWidget * tab = new QTabWidget;
- QWidget * widget = new QWidget;
- widget->setLayout(layout = new QGridLayout);
+ setLayout(layout = new QGridLayout);
layout->addWidget(browser = new QTextBrowser, 0, 0, 1, 0);
layout->addWidget(line = new QLineEdit, 1, 0);
layout->addWidget(button = new QPushButton(tr("Evaluate")), 1, 1);
- tab->addTab(widget, "GUILE");
- ((QDockWidget*)this)->setWidget(tab);
connect(button, SIGNAL(released()), this, SLOT(doEvaluate()));
connect(line, SIGNAL(returnPressed()), this, SLOT(doEvaluate()));
}
#include <log4cxx/logger.h>
class Interpreter;
+class FridaDock;
-class ScriptingDock : public QDockWidget {
+class ScriptingDock : public QWidget {
Q_OBJECT
public:
- ScriptingDock(Interpreter* interpreter, const QString& title, QWidget * parent = 0);
+ ScriptingDock(Interpreter* interpreter, FridaDock* parent);
private:
log4cxx::LoggerPtr logger;