Initial commit
This commit is contained in:
commit
4fb58b4324
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
dist
|
||||||
|
build
|
9
.liccor.yml
Normal file
9
.liccor.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
source:
|
||||||
|
- src
|
||||||
|
copyright_notice: |-
|
||||||
|
Copyright 2018 gtalent2@gmail.com
|
||||||
|
|
||||||
|
This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
59
CMakeLists.txt
Normal file
59
CMakeLists.txt
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.8)
|
||||||
|
|
||||||
|
project(bullock)
|
||||||
|
|
||||||
|
set(QTDIR "" CACHE STRING "Path to Qt Libraries")
|
||||||
|
|
||||||
|
set(CMAKE_PREFIX_PATH ${QTDIR})
|
||||||
|
find_package(Qt5 COMPONENTS Core Network Widgets REQUIRED)
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
|
||||||
|
include(address_sanitizer)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
add_definitions(-DDEBUG)
|
||||||
|
else()
|
||||||
|
add_definitions(-DNDEBUG)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT MSVC)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare")
|
||||||
|
|
||||||
|
if (CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||||
|
# forces colored output when using ninja
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
set(CMAKE_MACOSX_RPATH OFF)
|
||||||
|
set(CMAKE_INSTALL_NAME_DIR "@executable_path/../Library/bullock")
|
||||||
|
set(BULLOCK_DIST_BIN bullock.app/Contents/MacOS)
|
||||||
|
set(BULLOCK_DIST_LIB bullock.app/Contents/Library)
|
||||||
|
set(BULLOCK_DIST_PLUGIN bullock.app/Contents/Plugins)
|
||||||
|
set(BULLOCK_DIST_RESOURCES bullock.app/Contents/Resources)
|
||||||
|
set(BULLOCK_DIST_MAC_APP_CONTENTS bullock.app/Contents)
|
||||||
|
else()
|
||||||
|
set(CMAKE_INSTALL_RPATH "$ORIGIN" "$ORIGIN/../lib/bullock")
|
||||||
|
if(NOT ${QTDIR} STREQUAL "")
|
||||||
|
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} "${QTDIR}/lib")
|
||||||
|
endif()
|
||||||
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
|
||||||
|
set(BULLOCK_DIST_BIN bin)
|
||||||
|
set(BULLOCK_DIST_LIB lib)
|
||||||
|
set(BULLOCK_DIST_RESOURCES share)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
82
Makefile
Normal file
82
Makefile
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
OS=$(shell uname | tr [:upper:] [:lower:])
|
||||||
|
HOST_ENV=${OS}-$(shell uname -m)
|
||||||
|
DEVENV=devenv$(shell pwd | sed 's/\//-/g')
|
||||||
|
DEVENV_IMAGE=bullock-devenv
|
||||||
|
ifneq ($(shell which gmake 2> /dev/null),)
|
||||||
|
MAKE=gmake -s
|
||||||
|
else
|
||||||
|
MAKE=make -s
|
||||||
|
endif
|
||||||
|
ifneq ($(shell which docker 2> /dev/null),)
|
||||||
|
ifeq ($(shell docker inspect --format="{{.State.Status}}" ${DEVENV} 2>&1),running)
|
||||||
|
ENV_RUN=docker exec -i -t --user $(shell id -u ${USER}) ${DEVENV}
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
make:
|
||||||
|
${ENV_RUN} ./scripts/run-make build
|
||||||
|
gba-pkg:
|
||||||
|
${ENV_RUN} ./scripts/run-make build install
|
||||||
|
${ENV_RUN} ./scripts/run-make build
|
||||||
|
${ENV_RUN} ./scripts/gba-pkg
|
||||||
|
preinstall:
|
||||||
|
${ENV_RUN} ./scripts/run-make build preinstall
|
||||||
|
install:
|
||||||
|
${ENV_RUN} ./scripts/run-make build install
|
||||||
|
clean:
|
||||||
|
${ENV_RUN} ./scripts/run-make build clean
|
||||||
|
purge:
|
||||||
|
${ENV_RUN} rm -rf build
|
||||||
|
test:
|
||||||
|
${ENV_RUN} ./scripts/run-make build test
|
||||||
|
|
||||||
|
run: install
|
||||||
|
./dist/current/bin/bullock
|
||||||
|
|
||||||
|
devenv-image:
|
||||||
|
docker build . -t ${DEVENV_IMAGE}
|
||||||
|
devenv-create:
|
||||||
|
docker run -d \
|
||||||
|
-e LOCAL_USER_ID=$(shell id -u ${USER}) \
|
||||||
|
-e DISPLAY=$(DISPLAY) \
|
||||||
|
-e QT_AUTO_SCREEN_SCALE_FACTOR=1 \
|
||||||
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
||||||
|
-v /run/dbus/:/run/dbus/ \
|
||||||
|
-v $(shell pwd):/usr/src/project \
|
||||||
|
-v /dev/shm:/dev/shm \
|
||||||
|
--restart=always \
|
||||||
|
--name ${DEVENV} \
|
||||||
|
-t ${DEVENV_IMAGE} bash
|
||||||
|
devenv-destroy:
|
||||||
|
docker rm -f ${DEVENV}
|
||||||
|
|
||||||
|
shell:
|
||||||
|
${ENV_RUN} bash
|
||||||
|
|
||||||
|
release:
|
||||||
|
${ENV_RUN} rm -rf build/${HOST_ENV}-release
|
||||||
|
${ENV_RUN} ./scripts/setup-build.ps1 ${HOST_ENV} release
|
||||||
|
|
||||||
|
debug:
|
||||||
|
${ENV_RUN} rm -rf build/${HOST_ENV}-debug
|
||||||
|
${ENV_RUN} ./scripts/setup-build.ps1 ${HOST_ENV} debug
|
||||||
|
|
||||||
|
asan:
|
||||||
|
${ENV_RUN} rm -rf build/${HOST_ENV}-asan
|
||||||
|
${ENV_RUN} ./scripts/setup-build.ps1 ${HOST_ENV} asan
|
||||||
|
|
||||||
|
windows:
|
||||||
|
${ENV_RUN} rm -rf build/windows
|
||||||
|
${ENV_RUN} ./scripts/setup-build.ps1 windows
|
||||||
|
|
||||||
|
windows-debug:
|
||||||
|
${ENV_RUN} rm -rf build/windows
|
||||||
|
${ENV_RUN} ./scripts/setup-build.ps1 windows debug
|
||||||
|
|
||||||
|
gba:
|
||||||
|
${ENV_RUN} rm -rf build/gba-release
|
||||||
|
${ENV_RUN} ./scripts/setup-build.ps1 gba release
|
||||||
|
|
||||||
|
gba-debug:
|
||||||
|
${ENV_RUN} rm -rf build/gba-debug
|
||||||
|
${ENV_RUN} ./scripts/setup-build.ps1 gba debug
|
52
cmake/modules/address_sanitizer.cmake
Normal file
52
cmake/modules/address_sanitizer.cmake
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
# This file belongs Nick Overdijk, and is from https://github.com/NickNick/wubwubcmake
|
||||||
|
# The MIT License (MIT)
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013 Nick Overdijk
|
||||||
|
#
|
||||||
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
# this software and associated documentation files (the "Software"), to deal in
|
||||||
|
# the Software without restriction, including without limitation the rights to
|
||||||
|
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||||
|
# the Software, and to permit persons to whom the Software is furnished to do so,
|
||||||
|
# subject to the following conditions:
|
||||||
|
#
|
||||||
|
# The above copyright notice and this permission notice shall be included in all
|
||||||
|
# copies or substantial portions of the Software.
|
||||||
|
#
|
||||||
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||||
|
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.option(USE_ASAN "Enable Address Sanitizer, if your compiler supports it" ON)
|
||||||
|
|
||||||
|
option(USE_ASAN "Enable Address Sanitizer, if your compiler supports it" OFF)
|
||||||
|
if(USE_ASAN)
|
||||||
|
include(CheckCXXSourceCompiles)
|
||||||
|
# If the compiler understands -fsanitize=address, add it to the flags (gcc since 4.8 & clang since version 3.2)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS_BAK "${CMAKE_REQUIRED_FLAGS}")
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fsanitize=address")
|
||||||
|
CHECK_CXX_SOURCE_COMPILES("int main() { return 0; }" FLAG_FSANA_SUPPORTED)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_BAK}")
|
||||||
|
|
||||||
|
if(FLAG_FSANA_SUPPORTED)
|
||||||
|
set(asan_flag "-fsanitize=address")
|
||||||
|
else(FLAG_FSANA_SUPPORTED)
|
||||||
|
# Alternatively, try if it understands -faddress-sanitizer (clang until version 3.2)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -faddress-sanitizer")
|
||||||
|
CHECK_CXX_SOURCE_COMPILES("int main() { return 0; }" FLAG_FASAN_SUPPORTED)
|
||||||
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS_BAK}")
|
||||||
|
|
||||||
|
if(FLAG_FASAN_SUPPORTED)
|
||||||
|
set(asan_flag "-faddress-sanitizer")
|
||||||
|
endif(FLAG_FASAN_SUPPORTED)
|
||||||
|
endif(FLAG_FSANA_SUPPORTED)
|
||||||
|
|
||||||
|
if(FLAG_FSANA_SUPPORTED OR FLAG_FASAN_SUPPORTED)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${asan_flag}")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${asan_flag}")
|
||||||
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${asan_flag}")
|
||||||
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${asan_flag}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endif(USE_ASAN)
|
8
scripts/run-make
Executable file
8
scripts/run-make
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#! /usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
for f in $(find $1 -maxdepth 1 -mindepth 1 -type d)
|
||||||
|
do
|
||||||
|
cmake --build "$f" --target $2
|
||||||
|
done
|
51
scripts/setup-build.ps1
Executable file
51
scripts/setup-build.ps1
Executable file
@ -0,0 +1,51 @@
|
|||||||
|
#! /usr/bin/env pwsh
|
||||||
|
|
||||||
|
Param(
|
||||||
|
[parameter(Mandatory=$true,Position=0)][String] ${target},
|
||||||
|
[parameter(Mandatory=$true,Position=1)][String] ${buildType}
|
||||||
|
)
|
||||||
|
|
||||||
|
$project=(Get-Location).Path
|
||||||
|
|
||||||
|
if (${target} -eq "windows") {
|
||||||
|
$toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/Mingw.cmake"
|
||||||
|
} elseif (${target} -eq "gba") {
|
||||||
|
$toolchain="-DCMAKE_TOOLCHAIN_FILE=cmake/Modules/GBA.cmake"
|
||||||
|
$oxUseStdLib="-DOX_USE_STDLIB=OFF"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (${buildType} -eq "asan") {
|
||||||
|
$buildTypeArgs="-DUSE_ASAN=ON -DCMAKE_BUILD_TYPE=Debug"
|
||||||
|
} elseif (${buildType} -eq "debug") {
|
||||||
|
$buildTypeArgs="-DCMAKE_BUILD_TYPE=Debug"
|
||||||
|
} elseif (${buildType} -eq "release") {
|
||||||
|
$buildTypeArgs="-DCMAKE_BUILD_TYPE=Release"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (${env:QTDIR} -ne "") {
|
||||||
|
$qtPath="-DQTDIR=${env:QTDIR}"
|
||||||
|
}
|
||||||
|
|
||||||
|
$buildDir="${project}/build/${target}-${buildType}"
|
||||||
|
$distDir="${project}/dist/${target}-${buildType}"
|
||||||
|
|
||||||
|
New-Item -ItemType Directory -Path $buildDir | Out-Null
|
||||||
|
Push-Location $buildDir
|
||||||
|
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON `
|
||||||
|
-DCMAKE_INSTALL_PREFIX="$distDir" `
|
||||||
|
-G Ninja `
|
||||||
|
$buildTool `
|
||||||
|
$nostalgiaBuildType `
|
||||||
|
$oxUseStdLib `
|
||||||
|
$buildTypeArgs `
|
||||||
|
$qtPath `
|
||||||
|
$toolchain `
|
||||||
|
$project
|
||||||
|
Pop-Location
|
||||||
|
|
||||||
|
rm -f build/current dist/current
|
||||||
|
if (!(Test-Path -Path dist)) {
|
||||||
|
New-Item -ItemType Directory -Path dist | Out-Null
|
||||||
|
}
|
||||||
|
ln -s ${target}-${buildType} build/current
|
||||||
|
ln -s ${target}-${buildType} dist/current
|
36
src/CMakeLists.txt
Normal file
36
src/CMakeLists.txt
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
project(bullock)
|
||||||
|
|
||||||
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||||
|
|
||||||
|
find_package(Qt5Widgets)
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
|
||||||
|
add_executable(
|
||||||
|
bullock MACOSX_BUNDLE
|
||||||
|
main.cpp
|
||||||
|
mainwindow.cpp
|
||||||
|
processdata.cpp
|
||||||
|
procselector.cpp
|
||||||
|
server.cpp
|
||||||
|
traceeventmodel.cpp
|
||||||
|
traceview.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(
|
||||||
|
bullock
|
||||||
|
Qt5::Core
|
||||||
|
Qt5::Network
|
||||||
|
Qt5::Widgets
|
||||||
|
)
|
||||||
|
|
||||||
|
if(APPLE)
|
||||||
|
set_target_properties(bullock PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/Info.plist)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
install(
|
||||||
|
TARGETS
|
||||||
|
bullock
|
||||||
|
RUNTIME DESTINATION
|
||||||
|
${BULLOCK_DIST_BIN}
|
||||||
|
BUNDLE DESTINATION .
|
||||||
|
)
|
29
src/Info.plist
Normal file
29
src/Info.plist
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleExecutable</key>
|
||||||
|
<string>nostalgia-studio</string>
|
||||||
|
<key>CFBundleGetInfoString</key>
|
||||||
|
<string>Nostalgia Studio</string>
|
||||||
|
<key>CFBundleIconFile</key>
|
||||||
|
<string></string>
|
||||||
|
<key>CFBundleIdentifier</key>
|
||||||
|
<string>net.drinkingtea.nostalgia.studio</string>
|
||||||
|
<key>CFBundlePackageType</key>
|
||||||
|
<string>APPL</string>
|
||||||
|
<key>CFBundleVersion</key>
|
||||||
|
<string>1.2.8</string>
|
||||||
|
<key>LSMinimumSystemVersion</key>
|
||||||
|
<string>10.13.0</string>
|
||||||
|
|
||||||
|
<!-- HiDPI -->
|
||||||
|
<key>NSPrincipalClass</key>
|
||||||
|
<string>NSApplication</string>
|
||||||
|
<key>NSHighResolutionCapable</key>
|
||||||
|
<string>True</string>
|
||||||
|
|
||||||
|
<key>NSHumanReadableCopyright</key>
|
||||||
|
<string>Copyright (c) 2016-2018 Gary Talent <gtalent2@gmail.com></string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
26
src/main.cpp
Normal file
26
src/main.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
#include "server.hpp"
|
||||||
|
#include "mainwindow.hpp"
|
||||||
|
|
||||||
|
int main(int argc, char **args) {
|
||||||
|
QApplication app(argc, args);
|
||||||
|
|
||||||
|
LogServer server;
|
||||||
|
|
||||||
|
MainWindow w;
|
||||||
|
app.setApplicationName(w.windowTitle());
|
||||||
|
w.show();
|
||||||
|
|
||||||
|
QObject::connect(&server, &LogServer::newDataFeed, &w, &MainWindow::addDataFeed);
|
||||||
|
|
||||||
|
return app.exec();
|
||||||
|
}
|
66
src/mainwindow.cpp
Normal file
66
src/mainwindow.cpp
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QDesktopWidget>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QMenuBar>
|
||||||
|
#include <QSplitter>
|
||||||
|
|
||||||
|
#include "traceview.hpp"
|
||||||
|
|
||||||
|
#include "mainwindow.hpp"
|
||||||
|
|
||||||
|
MainWindow::MainWindow() {
|
||||||
|
setWindowTitle(tr("Bullock"));
|
||||||
|
|
||||||
|
auto screenSize = QApplication::desktop()->screenGeometry();
|
||||||
|
constexpr auto sizePct = 0.85;
|
||||||
|
resize(screenSize.width() * sizePct, screenSize.height() * sizePct);
|
||||||
|
move(-x(), -y());
|
||||||
|
move(screenSize.width() * (1 - sizePct) / 2, screenSize.height() * (1 - sizePct) / 2);
|
||||||
|
|
||||||
|
auto central = new QWidget(this);
|
||||||
|
auto splitter = new QSplitter(central);
|
||||||
|
|
||||||
|
auto leftPane = new QWidget(this);
|
||||||
|
auto leftPaneSplitter = new QSplitter(Qt::Vertical, leftPane);
|
||||||
|
m_procSelector = new ProcessSelector(leftPaneSplitter);
|
||||||
|
leftPaneSplitter->addWidget(m_procSelector);
|
||||||
|
|
||||||
|
splitter->addWidget(leftPaneSplitter);
|
||||||
|
splitter->addWidget(new TraceView(splitter));
|
||||||
|
splitter->setStretchFactor(1, 3);
|
||||||
|
|
||||||
|
setCentralWidget(splitter);
|
||||||
|
setupMenu();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainWindow::~MainWindow() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::addDataFeed(DataFeed *feed) {
|
||||||
|
m_procData.push_back(feed->procData());
|
||||||
|
auto time = QDateTime::currentDateTime();
|
||||||
|
m_procSelector->addProcess(time.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::setupMenu() {
|
||||||
|
auto menu = menuBar();
|
||||||
|
auto fileMenu = menu->addMenu(tr("&File"));
|
||||||
|
auto helpMenu = menu->addMenu(tr("&Help"));
|
||||||
|
|
||||||
|
auto quit = fileMenu->addAction(tr("&Quit"));
|
||||||
|
quit->setShortcuts(QKeySequence::Quit);
|
||||||
|
quit->setStatusTip(tr("Quit application"));
|
||||||
|
connect(quit, &QAction::triggered, this, &MainWindow::close);
|
||||||
|
|
||||||
|
helpMenu->addAction(tr("&About"));
|
||||||
|
}
|
32
src/mainwindow.hpp
Normal file
32
src/mainwindow.hpp
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QMainWindow>
|
||||||
|
|
||||||
|
#include "procselector.hpp"
|
||||||
|
#include "server.hpp"
|
||||||
|
|
||||||
|
class MainWindow: public QMainWindow {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
QVector<QSharedPointer<ProcessData>> m_procData;
|
||||||
|
ProcessSelector *m_procSelector = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
MainWindow();
|
||||||
|
|
||||||
|
~MainWindow();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void addDataFeed(DataFeed*);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setupMenu();
|
||||||
|
|
||||||
|
};
|
40
src/processdata.cpp
Normal file
40
src/processdata.cpp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QJsonArray>
|
||||||
|
|
||||||
|
#include "processdata.hpp"
|
||||||
|
|
||||||
|
Field::Field(QJsonObject field) {
|
||||||
|
this->name = field["name"].toString();
|
||||||
|
this->type = field["field_type"].toString();
|
||||||
|
this->value = field["value"].toString();
|
||||||
|
auto fields = field["fields"].toArray();
|
||||||
|
for (auto field : fields) {
|
||||||
|
this->fields.push_back(field.toObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Frame::Frame(QJsonObject frame) {
|
||||||
|
this->arch = frame["arch"].toString();
|
||||||
|
this->file = frame["file"].toString();
|
||||||
|
this->line = frame["line"].toDouble();
|
||||||
|
auto fields = frame["fields"].toArray();
|
||||||
|
for (auto field : fields) {
|
||||||
|
this->fields.push_back(field.toObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TraceEvent::TraceEvent(QJsonObject tp) {
|
||||||
|
this->logMsg = tp["trace_msg"].toString();
|
||||||
|
auto frames = tp["frames"].toArray();
|
||||||
|
for (auto frame : frames) {
|
||||||
|
this->frames.push_back(frame.toObject());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
47
src/processdata.hpp
Normal file
47
src/processdata.hpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QJsonObject>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
|
struct Field {
|
||||||
|
QString name;
|
||||||
|
QString type;
|
||||||
|
QString value;
|
||||||
|
QVector<Field> fields;
|
||||||
|
|
||||||
|
Field(QJsonObject field = {});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Frame {
|
||||||
|
QString arch;
|
||||||
|
QString file;
|
||||||
|
int line = 0;
|
||||||
|
QVector<Field> fields;
|
||||||
|
|
||||||
|
Frame(QJsonObject frame = {});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TraceEvent {
|
||||||
|
QString channel;
|
||||||
|
QString logMsg;
|
||||||
|
QVector<Frame> frames;
|
||||||
|
|
||||||
|
TraceEvent(QJsonObject tp = {});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ProcessData {
|
||||||
|
QString cmd;
|
||||||
|
QVector<TraceEvent> traceEvents;
|
||||||
|
};
|
20
src/procselector.cpp
Normal file
20
src/procselector.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include "procselector.hpp"
|
||||||
|
|
||||||
|
ProcessSelector::ProcessSelector(QWidget *parent): QWidget(parent) {
|
||||||
|
auto lyt = new QVBoxLayout(this);
|
||||||
|
lyt->addWidget(new QLabel(tr("Processes"), this));
|
||||||
|
lyt->addWidget(m_list);
|
||||||
|
m_list->addItem(tr("Most Recent"));
|
||||||
|
m_list->setCurrentRow(RowLatest);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProcessSelector::addProcess(QString procKey) {
|
||||||
|
m_list->insertItem(1, procKey);
|
||||||
|
if (m_list->currentRow() == RowLatest) {
|
||||||
|
emit selectionChanged(procKey);
|
||||||
|
}
|
||||||
|
}
|
33
src/procselector.hpp
Normal file
33
src/procselector.hpp
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QListWidget>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class ProcessSelector: public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum Rows {
|
||||||
|
RowLatest = 0
|
||||||
|
};
|
||||||
|
|
||||||
|
QListWidget *m_list = new QListWidget(this);
|
||||||
|
|
||||||
|
public:
|
||||||
|
ProcessSelector(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void addProcess(QString procKey);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void selectionChanged(QString procKey);
|
||||||
|
|
||||||
|
};
|
53
src/server.cpp
Normal file
53
src/server.cpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "server.hpp"
|
||||||
|
|
||||||
|
DataFeed::DataFeed(QIODevice *dev): QObject(dev) {
|
||||||
|
m_dev = dev;
|
||||||
|
connect(m_dev, &QIODevice::readyRead, this, &DataFeed::handleInit);
|
||||||
|
}
|
||||||
|
|
||||||
|
QSharedPointer<ProcessData> DataFeed::procData() {
|
||||||
|
return m_procData;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataFeed::handleInit() {
|
||||||
|
auto doc = QJsonDocument::fromJson(m_dev->readLine());
|
||||||
|
if (doc.isObject()) {
|
||||||
|
auto msg = doc.object();
|
||||||
|
if (msg["type"].toString() == "Init") {
|
||||||
|
disconnect(m_dev, &QIODevice::readyRead, this, &DataFeed::handleInit);
|
||||||
|
connect(m_dev, &QIODevice::readyRead, this, &DataFeed::read);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataFeed::read() {
|
||||||
|
while (m_dev->bytesAvailable()) {
|
||||||
|
auto doc = QJsonDocument::fromJson(m_dev->readLine());
|
||||||
|
if (m_procData) {
|
||||||
|
m_procData->traceEvents.push_back(doc.object());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LogServer::LogServer() {
|
||||||
|
m_server->listen(QHostAddress::LocalHost, 5590);
|
||||||
|
connect(m_server, &QTcpServer::newConnection, this, &LogServer::handleConnection);
|
||||||
|
}
|
||||||
|
|
||||||
|
void LogServer::handleConnection() {
|
||||||
|
auto conn = m_server->nextPendingConnection();
|
||||||
|
connect(conn, &QAbstractSocket::disconnected, conn, &QObject::deleteLater);
|
||||||
|
connect(this, &QObject::destroyed, conn, &QObject::deleteLater);
|
||||||
|
emit newDataFeed(new DataFeed(conn));
|
||||||
|
}
|
53
src/server.hpp
Normal file
53
src/server.hpp
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QPointer>
|
||||||
|
#include <QSharedPointer>
|
||||||
|
#include <QTcpServer>
|
||||||
|
#include <QTcpSocket>
|
||||||
|
|
||||||
|
#include "processdata.hpp"
|
||||||
|
|
||||||
|
class DataFeed: public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSharedPointer<ProcessData> m_procData = QSharedPointer<ProcessData>(new ProcessData);
|
||||||
|
QIODevice *m_dev = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
DataFeed(QIODevice *dev);
|
||||||
|
|
||||||
|
QSharedPointer<ProcessData> procData();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void handleInit();
|
||||||
|
|
||||||
|
void read();
|
||||||
|
};
|
||||||
|
|
||||||
|
class LogServer: public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
QPointer<QTcpServer> m_server = new QTcpServer(this);
|
||||||
|
|
||||||
|
public:
|
||||||
|
LogServer();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void handleConnection();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void newDataFeed(DataFeed*);
|
||||||
|
};
|
25
src/traceeventmodel.cpp
Normal file
25
src/traceeventmodel.cpp
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "traceeventmodel.hpp"
|
||||||
|
|
||||||
|
int TraceEventModel::rowCount(const QModelIndex &parent) const {
|
||||||
|
if (m_procData) {
|
||||||
|
return m_procData->traceEvents.size();
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int TraceEventModel::columnCount(const QModelIndex &parent) const {
|
||||||
|
return Column::End;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant TraceEventModel::data(const QModelIndex &index, int role) const {
|
||||||
|
return {};
|
||||||
|
}
|
34
src/traceeventmodel.hpp
Normal file
34
src/traceeventmodel.hpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "processdata.hpp"
|
||||||
|
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
|
|
||||||
|
class TraceEventModel: public QAbstractItemModel {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
enum Column {
|
||||||
|
Channel,
|
||||||
|
Message,
|
||||||
|
End
|
||||||
|
};
|
||||||
|
|
||||||
|
ProcessData *m_procData = nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override ;
|
||||||
|
|
||||||
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
||||||
|
|
||||||
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
||||||
|
};
|
18
src/traceview.cpp
Normal file
18
src/traceview.cpp
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QTableView>
|
||||||
|
|
||||||
|
#include "traceview.hpp"
|
||||||
|
|
||||||
|
TraceView::TraceView(QWidget *parent): QWidget(parent) {
|
||||||
|
auto lyt = new QHBoxLayout;
|
||||||
|
setLayout(lyt);
|
||||||
|
lyt->addWidget(new QTableView(this));
|
||||||
|
}
|
19
src/traceview.hpp
Normal file
19
src/traceview.hpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 gtalent2@gmail.com
|
||||||
|
*
|
||||||
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class TraceView: public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TraceView(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user