cpp策略调试过程

[root@localhost cpp_build]# gdb ./kungfu_strategy_demo 
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-80.el7
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /kungfu/wingchun/strategy/cpp_demo/cpp_build/kungfu_strategy_demo...done.
(gdb) i b
No breakpoints or watchpoints.
(gdb) b main
Breakpoint 1 at 0x434407: file /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp, line 204.
(gdb) r   
Starting program: /kungfu/wingchun/strategy/cpp_demo/cpp_build/./kungfu_strategy_demo 
b 83
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7ffff3685700 (LWP 1026)]
[New Thread 0x7ffff2e84700 (LWP 1027)]

Breakpoint 1, main (argc=1, argv=0x7fffffffe6c8)
    at /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp:204
204	    Strategy str(string("cpp_test"));
Missing separate debuginfos, use: debuginfo-install glibc-2.17-105.el7.x86_64 libgcc-4.8.5-4.el7.x86_64 libstdc++-4.8.5-4.el7.x86_64 python-libs-2.7.5-34.el7.x86_64
(gdb) b 83
Breakpoint 2 at 0x4333de: file /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp, line 83.
(gdb) c
Continuing.
[New Thread 0x7fffea683700 (LWP 1028)]
18-05-16 09:36:38.685 INFO  cpp_test %% - [start] data started 
18-05-16 09:36:40.336 DEBUG cpp_test %% - [td_login] (source)1 (ready)1 (pos){"Cost":{"rb1806":[0.0,0.0,0.0,23.466,38800.0,74.146]},"FeeSetup":{"future":{"ctr_multi":200,"fee_multi":[2.3e-05,0.00069,2.3e-05],"min_fee":0.0,"type":"amount"},"future_exotic":{"c":{"ctr_multi":10,"fee_multi":1.2,"min_fee":0.0,"type":"volume"},"c1803":{"ctr_multi":10,"fee_multi":0.2,"min_fee":0.0,"type":"volume"},"ic":{"ctr_multi":200,"fee_multi":[2.3e-05,0.00069,2.3e-05],"min_fee":0.0,"type":"amount"},"rb":{"ctr_multi":10,"fee_multi":0.0001,"min_fee":0.0,"type":"amount"},"rb1806":{"ctr_multi":10,"fee_multi":[0.0001,0.0005,0.0001],"min_fee":0.0,"type":"amount"}},"stock":{"ctr_multi":1,"fee_multi":0.0003,"min_fee":0.0,"type":"amount"}},"Pos":{"rb1806":[0,0,0,0,1,1]},"Source":1,"name":"cpp_test","nano":1526372295139313265,"ok":true} 
[Switching to Thread 0x7fffea683700 (LWP 1028)]

Breakpoint 2, Strategy::on_rsp_position (this=0x7fffffffe4f0, posMap=..., 
    request_id=-1, source=1, rcv_time=1526434600630851024)
    at /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp:83
83	        td_connected = true;
(gdb) list
78	
79	void Strategy::on_rsp_position(const PosHandlerPtr posMap, int request_id, short source, long rcv_time)
80	{
81	    if (request_id == -1 && source == SOURCE_INDEX)
82	    {
83	        td_connected = true;
84	        KF_LOG_INFO(logger, "td connected");
85	        if (posMap.get() == nullptr)
86	        {
87	            data->set_pos(PosHandlerPtr(new PosHandler(source)), source);
(gdb) n
84	        KF_LOG_INFO(logger, "td connected");
(gdb) n
18-05-16 10:19:35.650 INFO  cpp_test %% - td connected 
85	        if (posMap.get() == nullptr)
(gdb) list 111
106	        // ============ prepare data ============
107	        double rolling_min = 9999999;
108	        double rolling_max = 0;
109	        for (int i = 0; i < signal.param1; i++)
110	        {
111	            int idx = signal.look_back - 1 - signal.param2 - i; // delay
112	            double curPrice = signal.TickPrice[idx];
113	            rolling_max = (curPrice > rolling_max) ? curPrice: rolling_max;
114	            rolling_min = (curPrice < rolling_min) ? curPrice: rolling_min;
115	        }
(gdb) b 107
Breakpoint 3 at 0x433760: file /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp, line 107.
(gdb) i b
Num     Type           Disp Enb Address            What
1       breakpoint     keep y   0x0000000000434407 in main(int, char const**) 
                                                   at /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp:204
	breakpoint already hit 1 time
2       breakpoint     keep y   0x00000000004333de in Strategy::on_rsp_position(boost::shared_ptr<kungfu::yijinjing::PosHandler>, int, short, long) 
                                                   at /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp:83
	breakpoint already hit 1 time
3       breakpoint     keep y   0x0000000000433760 in Strategy::on_market_data(LFMarketDataField const*, short, long) 
                                                   at /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp:107
(gdb) c
Continuing.
b 101
^C
Program received signal SIGINT, Interrupt.
[Switching to Thread 0x7ffff7fe4740 (LWP 1022)]
0x00007ffff40bbef7 in pthread_join () from /lib64/libpthread.so.0
(gdb) b 101
Breakpoint 4 at 0x4336ec: file /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp, line 101.
(gdb) c
Continuing.
[Switching to Thread 0x7fffea683700 (LWP 1028)]

Breakpoint 4, Strategy::on_market_data (this=0x7fffffffe4f0, md=0x7fffdc2cbb63, 
    source=1, rcv_time=1526438265803142010)
    at /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp:101
101	        if (signal.TickPrice.size() > signal.look_back)
(gdb) c
Continuing.

Breakpoint 4, Strategy::on_market_data (this=0x7fffffffe4f0, md=0x7fffdc2cbd39, 
    source=1, rcv_time=1526438324422202350)
    at /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp:101
101	        if (signal.TickPrice.size() > signal.look_back)
(gdb) p signal.TickPrice.size()
$1 = 124
(gdb) c
Continuing.

Breakpoint 4, Strategy::on_market_data (this=0x7fffffffe4f0, md=0x7fffdc2cbf0f, 
    source=1, rcv_time=1526438546411625742)
    at /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp:101
101	        if (signal.TickPrice.size() > signal.look_back)
(gdb) clear 101
Deleted breakpoint 4 
(gdb) c
Continuing.
^C
Program received signal SIGINT, Interrupt.
[Switching to Thread 0x7ffff7fe4740 (LWP 1022)]
0x00007ffff40bbef7 in pthread_join () from /lib64/libpthread.so.0
(gdb) b 101
Breakpoint 5 at 0x4336ec: file /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp, line 101.
(gdb) c
Continuing.
^[[A^[[A[Switching to Thread 0x7fffea683700 (LWP 1028)]

Breakpoint 5, Strategy::on_market_data (this=0x7fffffffe4f0, md=0x7fffdc2cff51, 
    source=1, rcv_time=1526439920917250572)
    at /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp:101
101	        if (signal.TickPrice.size() > signal.look_back)
(gdb) p signal.TickPrice.size()
$2 = 160
(gdb) c                      
Continuing.

Breakpoint 5, Strategy::on_market_data (this=0x7fffffffe4f0, md=0x7fffdc2d0127, 
    source=1, rcv_time=1526439975914351684)
    at /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp:101
101	        if (signal.TickPrice.size() > signal.look_back)
(gdb) p signal.TickPrice.size()
$3 = 161
(gdb) clear 101
Deleted breakpoint 5 
(gdb) c
Continuing.
^[[A^[[A^[[A^C
Program received signal SIGINT, Interrupt.
[Switching to Thread 0x7ffff7fe4740 (LWP 1022)]
0x00007ffff40bbef7 in pthread_join () from /lib64/libpthread.so.0
(gdb) b 101
Breakpoint 6 at 0x4336ec: file /kungfu/wingchun/strategy/cpp_demo/kungfu_strategy_demo.cpp, line 101.
(gdb) clear 101
Deleted breakpoint 6 
(gdb) c
Continuing.

 

posted @ 2018-08-05 12:39  心媛意码  阅读(303)  评论(0编辑  收藏  举报