viabtc / viabtc_exchange_server

A trading engine with high-speed performance and real-time notification
MIT License
2.67k stars 1.49k forks source link

Debugging matchengine #224

Closed dim4egster closed 4 years ago

dim4egster commented 4 years ago

Hello! I need to debugging a matchengine.exe service on my host. I was build and run it in debug mode from clion ide. How can i configure a network, ports for interaction with another services that still run in a docker. Or, maybe, have someones an instructions howto run all services on host for debugging matchengine?

dim4egster commented 4 years ago

Solved for me! host build command: gcc -g -rdynamic -o matchengine.exe me_operlog.o me_persist.o me_cli.o me_load.o me_balance.o me_dump.o me_main.o me_server.o me_trade.o me_config.o me_update.o me_message.o me_history.o me_market.o -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -ldl -L ../utils -lutils -L ../network -lnetwork -Wl,-Bstatic -lev -ljansson -lmpdec -lmysqlclient -lz -lrdkafka -lssl -lcrypto -lhiredis -Wl,-Bdynamic -lm -lpthread -ldl

Host build in clion: install compiledb https://blog.jetbrains.com/clion/2018/08/working-with-makefiles-in-clion-using-compilation-db/ apply for all projects: run from each folder with makefile and sources: compiledb -n make https://www.jetbrains.com/help/clion/managing-makefile-projects.html add plugin for makefile in clion https://www.felix021.com/blog/read.php?2187 Assotiate makefile in CLion with GNU Makefile from right click context menu in project explorer.

              Detailed guide to compile viabtc_exchange_server on Ubuntu 16.04

DEPENDENCIES

$ sudo apt install -y libev-dev libjansson-dev libmpdec-dev libmysqlclient-dev libcurl4-gnutls-dev libldap2-dev libgss-dev librtmp-dev libsasl2-dev

librdkafka: 0.11.3+; DO NOT INSTALL BY APT: version too old (0.8.x); if you do, remove them by: sudo apt remove librdkafka1 librdkafka-dev $ wget https://github.com/edenhill/librdkafka/archive/v0.11.3.tar.gz -O librdkafka-0.11.3.tar.gz $ tar zxf librdkafka-0.11.3.tar.gz $ cd librdkafka-0.11.3 $ ./configure $ make $ sudo make install

COMPILATION

$ git clone https://github.com/viabtc/viabtc_exchange_server.git $ cd viabtc_exchange_server

$ make -C depends/hiredis $ make -C network

$ vi utils/makefile #modify INCS INCS = -I ../network -I ../depends $ make -C utils

$ vi accesshttp/makefile #modify INCS & LIBS INCS = -I ../network -I ../utils -I ../depends LIBS = -L ../utils -lutils -L ../network -lnetwork -L ../depends/hiredis -Wl,-Bstatic -lev -ljansson -lmpdec -lrdkafka -lz -lssl -lcrypto -lhiredis -lcurl -Wl,-Bdynamic -lm -lpthread -ldl -lssl -lldap -llber -lgss -lgnutls -lidn -lnettle -lrtmp -lsasl2 -lmysqlclient $ make -C accesshttp

$ vi accessws/makefile {modify INCS and LIBS like accesshttp/makefile} $ make -C accessws

vi alertcenter/makefile {modify INCS and LIBS like accesshttp/makefile} $ make -C alertcenter

$ vi marketprice/makefile {modify INCS and LIBS like accesshttp/makefile} $ make -C marketprice

$ vi matchengine/makefile {modify INCS and LIBS like accesshttp/makefile} $ make -C matchengine

$ vi readhistory/makefile {modify INCS and LIBS like accesshttp/makefile} $ make -C readhistory

IMPORTANT

If build failed ld errors add lib -llz4 in makefile

Debug in clion

install compilation db (dependencies may be required, install them also based on errors) pip install compiledb

from project dir run: compiledb -n make OR /home//.local/bin/compiledb -n make

configure custom build target from clion https://www.jetbrains.com/help/clion/custom-build-targets.html#custom-rundebug