{"push_id":2370319309,"size":1,"distinct_size":1,"ref":"refs/heads/develop","head":"3eb87d443c217ee1fbbc84567dbbf06c1189588a","before":"3ac9b5234fd204c0590fd115430ca2ba36adb04e","commits":[{"sha":"3eb87d443c217ee1fbbc84567dbbf06c1189588a","author":{"name":"zenglong","email":"7b2e9f54cdff413fcde01f330af6896c3cd7e6cd@zengl.com"},"message":"v0.9.0 pydebugger 远程调试\n\n根目录中新建pydebugger目录，在该目录内新增TCPServer.py的python脚本，需要通过python3来运行本脚本。该脚本在运行时，默认会监听9999端口(可以通过修改脚本来改变绑定的端口号)，当python脚本接收到zenglServer的调试连接时，就会等待用户输入调试命令，并将这些命令发送给zenglServer，再由zenglServer执行调试命令和返回调试结果，最后python会将结果显示到用户终端上。\n\nconfig.zl中新增和远程调试相关的配置：\n\ndef TRUE 1;\ndef FALSE 0;\n\n.................................\n\nremote_debug_enable = FALSE; // 是否开启远程调试，默认为FALSE即不开启，设置为TRUE可以开启远程调试\nremote_debugger_ip = '127.0.0.1'; // 远程调试器的ip地址\nremote_debugger_port = 9999; // 远程调试器的端口号\n\n通过将remote_debug_enable设置为TRUE即可开启远程调试，如果开启了远程调试，那么当运行zengl脚本时，zenglServer就会根据remote_debugger_ip(IP地址)和remote_debugger_port(端口号)去连接远程调试器(目前远程调试器是使用python编写的，即上面提到的TCPServer.py)。连接上调试器后，调试器会接收用户输入的调试命令，并将命令发给zenglServer，由zenglServer执行命令并返回结果。\n\nzenglServer中处理调试命令的调试模块，对应的源码为debug.c和debug.h，该调试模块会根据需要发起调试连接，并在接收到调试命令后，处理这些命令，以及返回命令的执行结果。\n\n在python远程调试器中，可以通过h命令来查看调试命令的帮助信息：\n\nzengl@zengl-ubuntu:~/zenglServer$ python3 pydebugger/TCPServer.py\nlisten connection...\n127.0.0.1 connected:\nfile:my_webroot/v0_8_0/test.zl,line:1,breakIndex:0\n1    use builtin;\n\nzl debug >>> h\n p 调试变量信息 usage:p express\n b 设置断点 usage:b filename lineNumber[ count] | b lineNumber[ count]\n B 查看断点列表 usage:B\n T 查看脚本函数的堆栈调用信息 usage:T\n d 删除某断点 usage:d breakIndex\n D 禁用某断点 usage:D breakIndex\n C 设置条件断点 usage:C breakIndex condition-express\n L 设置日志断点 usage:L breakIndex log-express\n N 设置断点次数 usage:N breakIndex count\n s 单步步入 usage:s\n S 单步步过 usage:S\n r 执行到返回 usage:r\n c 继续执行 usage:c\n l 显示源码 usage:l filename [lineNumber[ offset]] | l [lineNumber[ offset]]\n u 执行到指定的行 usage:u filename lineNumber | u lineNumber\n h 显示帮助信息\n\nzl debug >>> l 9 10\ncurrent run line:1 [my_webroot/v0_8_0/test.zl]\n1    use builtin;    <<<---[ current line] ***\n2\n3    def TRUE 1;\n4    def FALSE 0;\n5    def MD5_LOWER_CASE 1;\n6    def MD5_UPPER_CASE 0;\n7    def MD5_32BIT 1;\n8    def MD5_16BIT 0;\n9\n10    print '<!Doctype html>\n11    <html>\n12    <head><meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />\n13    <title>json编解码测试</title>\n14    </head>\n15    <body>';\n16\n17    json = '{\"hello\": \"world!!\", \"name\": \"zengl\", \"val\": \"programmer\", \"arr\":[1,2,3]}';\n18\n19    json = bltJsonDecode(json);\n\nzl debug >>> u 19\nfile:my_webroot/v0_8_0/test.zl,line:19,breakIndex:1\n19    json = bltJsonDecode(json);\n\nzl debug >>> p json\njson :string:{\"hello\": \"world!!\", \"name\": \"zengl\", \"val\": \"programmer\", \"arr\":[1,2,3]}\n\nzl debug >>> c\nlisten connection...\n^Cexcept...\nzengl@zengl-ubuntu:~/zenglServer$\n\n在zenglServer的logfile日志中也会记录下用户输入的调试命令：\n\n-----------------------------------\nThu Mar  1 09:21:33 2018\nrecv [client_socket_fd:9] [lst_idx:0] [pid:4664] [tid:4667]:\n\nrequest header: Host: 127.0.0.1:8083 | User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0 | Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 | Accept-Language: zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3 | Accept-Encoding: gzip, deflate | Cookie: __uvt=; uvts=6l2bv2GQOomwZIup | Connection: keep-alive | Upgrade-Insecure-Requests: 1 | Cache-Control: max-age=0 |\n\nurl: /v0_8_0/test.zl\nurl_path: /v0_8_0/test.zl\nfull_path: my_webroot/v0_8_0/test.zl\nzl debug info: Socket created [12]\nzl debug info: connecting to 127.0.0.1:9999... connected\nzl debug info: debugger command: l test.zl\nzl debug info: debugger command: h\nzl debug info: debugger command: u 19\nzl debug info: debugger command: p json\nzl debug info: debugger command: c\nzl debug info: close socket [12]\nstatus: 200, content length: 917\nresponse header: HTTP/1.1 200 OK\n\nContent-Type: text/html\n\nContent-Length: 917\n\nConnection: Closed\n\nServer: zenglServer\n\nfree socket_list[0]/list_cnt:0 epoll_fd_add_count:0 pid:4664 tid:4667\nTermination signal received! Killing children..\nAll children reaped, shutting down.\nclosed accept_sem\nshutdowned server socket\nclosed server socket\n===================================\n\n这些调试命令的具体执行过程，请参考debug.c文件","distinct":true,"url":"https://api.github.com/repos/zenglongtest/zenglServerTest/commits/3eb87d443c217ee1fbbc84567dbbf06c1189588a"}]}
{"actor":{"display_login":"zenglongtest"}}