CN108363661A - A kind of output implementation method by all kinds of means of application layer code Debugging message - Google Patents
A kind of output implementation method by all kinds of means of application layer code Debugging message Download PDFInfo
- Publication number
- CN108363661A CN108363661A CN201810008178.9A CN201810008178A CN108363661A CN 108363661 A CN108363661 A CN 108363661A CN 201810008178 A CN201810008178 A CN 201810008178A CN 108363661 A CN108363661 A CN 108363661A
- Authority
- CN
- China
- Prior art keywords
- debug
- debugging message
- manager
- kinds
- application layer
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/362—Software debugging
- G06F11/3624—Software debugging by performing operations on the source code, e.g. via a compiler
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/362—Software debugging
Abstract
The present invention is more particularly directed to a kind of output implementation methods by all kinds of means of application layer code Debugging message.The output implementation method by all kinds of means of the application layer code Debugging message supports that the multiple channel of Debugging message exports and telecommunication network printing, developer can obtain scene log daily records in real time nonlocal using debug_manager.c programs as core layer;The debug_manager.c programs provide practical interface encapsulation for user upwards, are downwards specific printing channel abstract package structure, and provide the registration function of the structure.The output implementation method by all kinds of means of the application layer code Debugging message, support multiple channel output and the telecommunication network printing of Debugging message, developer can obtain scene log daily records in real time nonlocal, debug time can be saved, debugging efficiency is improved, the cost of labor and time cost of remote debugging are thereby reduced.
Description
Technical field
The present invention relates to Debugging message technical field, more particularly to a kind of output by all kinds of means of application layer code Debugging message
Implementation method.
Background technology
Debugging message plays key player, the debugging of program in the program development stage(debug), Performance tuning and auxiliary
Property information printing all be unable to do without Debugging message help.Traditional Debugging message be all by standard input and output come with research and development people
Member interacts, and in local if code, the presentation of this Debugging message is preferred naturally.But if needs check tune
The research staff of examination information and code solve personnel and exist or not the machine hung machines in same place, such as foreign customers
The country, then traditional Debugging message interactive mode just cannot be satisfied demand.
The problem of based on above-mentioned physical presence, research staff proposes a solution:In Glibc(GNU publications
The libraries libc)The standard library function of encapsulation similar printf, scanf, these functions are all based on the encapsulation of standard input and output, directly
It is connected on calling use in code.But the program still has following defect:The standard input-output function of Glibc encapsulation
The local printing that can only realize Debugging message, for the scene of the accident and solve personnel strange land the case where it is helpless.
Based on the above issues, the present invention proposes a kind of output implementation method by all kinds of means of application layer code Debugging message.
Invention content
In order to compensate for the shortcomings of the prior art, the present invention provides a kind of application layer code Debugging message being simple and efficient
Implementation method is exported by all kinds of means.
The present invention is achieved through the following technical solutions:
A kind of output implementation method by all kinds of means of application layer code Debugging message, it is characterised in that:With debug_manager.c journeys
Sequence is core layer, supports that the multiple channel of Debugging message exports and telecommunication network printing, developer can in real time obtain in other places
The log daily records of enchashment field;The debug_manager.c programs provide practical interface encapsulation for user upwards, are downwards tool
The printing channel abstract package structure of body, and the registration function of the structure is provided.
The debug_manager.c programs provide external unified printing interface encapsulation, and Debugging message only needs when exporting
The interface for calling debug_manager.c programs to provide, does not need specific implementation of the concerned interface in bottom;Each tool
The printing channel of body is abstract to one structure of debug_manager.c program registrations respectively, while in debug_manager.c
The chained list of a printing channel for preserving all registrations is safeguarded in program.
When new daily record output channel, which is added, to be supported, only need to debug_manager.c programs /debug/ catalogues under
It adds a bottom document and completes registration upwards.
Specific printing channel includes the stdout.c standard I/O interfaces for supporting locally to export and support telecommunication network output
Netprintf submodules.
The netprintf submodules are mounted as UDP server on the target machine, when having on remote computer
When client-side program logs in UDP server, print data is sent to corresponding client by netprintf submodules, with distal end
Client realize the network transmission functions of log daily records together.
The beneficial effects of the invention are as follows:The output implementation method by all kinds of means of the application layer code Debugging message supports debugging
The multiple channel output and telecommunication network printing of information, developer can obtain scene log daily records, Neng Goujie in real time nonlocal
About debug time improves debugging efficiency, thereby reduces the cost of labor and time cost of remote debugging.
Description of the drawings
Attached drawing 1 is the implementation method schematic diagram of output by all kinds of means of application layer code Debugging message of the present invention.
Specific implementation mode
In order to make technical problems, technical solutions and advantages to be solved be more clearly understood, tie below
Embodiment is closed, the present invention will be described in detail.It should be noted that specific embodiment described herein is only explaining
The present invention is not intended to limit the present invention.
The output implementation method by all kinds of means of the application layer code Debugging message, using debug_manager.c programs as core
Layer supports that the multiple channel of Debugging message exports and telecommunication network printing, developer can obtain scene log in real time nonlocal
Daily record;The debug_manager.c programs provide practical interface encapsulation for user upwards, are downwards specific printing canal
Road abstract package structure, and the registration function of the structure is provided.
The debug_manager.c programs provide external unified printing interface encapsulation, and Debugging message only needs when exporting
The interface for calling debug_manager.c programs to provide, does not need specific implementation of the concerned interface in bottom;Each tool
The printing channel of body is abstract to one structure of debug_manager.c program registrations respectively, while in debug_manager.c
The chained list of a printing channel for preserving all registrations is safeguarded in program.
When new daily record output channel, which is added, to be supported, only need to debug_manager.c programs /debug/ catalogues under
It adds a bottom document and completes registration upwards.
Specific printing channel includes the stdout.c standard I/O interfaces for supporting locally to export and support telecommunication network output
Netprintf submodules.
The netprintf submodules are mounted as UDP server on the target machine, when having on remote computer
When client-side program logs in UDP server, print data is sent to corresponding client by netprintf submodules, with distal end
Client realize the network transmission functions of log daily records together.
Debug_manager.c is the core layer of software module, provides practical interface encapsulation for user upwards, downwards
Specifically to print channel module abstracts mounting structure, and provide the registration function of the structure.Specific to the work of bottom
Just become to specify very much, seek to the structure of instantiation debug_manager.c encapsulation and completes registration upwards.
One, the realization of core layer debug_manager.c programs
The structure encapsulation that the debug_manager.c programs are realized is as follows:
typedef struct DebugOpr {
char *name;
int isCanUse;
int (*DebugInit)(void);The initialization function * of/* debugging modules/
int (*DebugExit)(void);/ * exit function */
int (*DebugPrint)(char *strData);/ * output functions */
struct DebugOpr *ptNext;
}T_DebugOpr, *PT_DebugOpr;
The printing channel of bottom calls int RegisterDebugOpr (PT_DebugOpr ptDebugOpr);It will initialization
Good DebugOpr is registered to debug_manager.c.
Other, the encapsulation that debug_manager.c programs are realized is described as follows:
(1)void ShowDebugOpr(void);It shows " debugging channel " that this software module can be supported.
(2)PT_DebugOpr GetDebugOpr(char *pcName);Specified " debugging canal is taken out according to name
Road ".
(3)int SetDbgChanel(char *strBuf);Some debugging channel of ON/OFF.Parameter strBuf explanations are such as
Under:
stdout=0:Close stdout printings
stdout=1:Open stdout printings
netprint=0:Close netprint printings
netprint=1:Open netprint printings
(4)int DebugPrint(const char *pcFormat, ...);The main entrance function of type information.User
DBG_PRINTF is called to print, it is exactly DebugPrint, there is such macrodefinition in config.h:#define DBG_
PRINTF DebugPrint.Variable element, usage and printf are just the same.
(5)int SetDbgLevel(char *strBuf);Setting printing rank g_iDbgLevelLimit:Rank model
0 ~ 7 is enclosed, the smaller rank of number is higher, and the Debugging message greater than or equal to g_iDbgLevelLimit can just print.It is related
Macrodefinition is as follows:
The debugging level of/* information, the small higher * of rank of numerical value/
#define APP_EMERG "<0>" /* system is unusable */
#define APP_ALERT "<1>" /* action must be taken immediately */
#define APP_CRIT "<2>" /* critical conditions */
#define APP_ERR "<3>" /* error conditions */
#define APP_WARNING "<4>" /* warning conditions */
#define APP_NOTICE "<5>" /* normal but significant condition */
#define APP_INFO "<6>" /* informational */
#define APP_DEBUG "<7>" /* debug-level messages */
The acquiescence debugging level * of/* information/
#define DEFAULT_DBGLEVEL 4
Two, the realization of standard output
Standard output realization is fairly simple, directly invokes printf.The instantiation of DebugOpr structures is as follows:
static T_DebugOpr g_tStdoutDbgOpr = {
.name = "stdout",
=1 .isCanUse/* 1 indicate will using it come export Debugging message */
.DebugPrint=StdoutDebugPrint ,/* printfs */
};
After the completion of instantiation, registration function is called in entrance function, " standard output debugging channel " g_tStdoutDbgOpr
Structure is put into the chained list of debug_manager.c.
Three, the realization of telecommunication network printing netprint.c
It is as follows shown in the DebugOpr of Netprint submodules instantiation:
static T_DebugOpr g_tNetDbgOpr = {
.name = "netprint",
.isCanUse = 1,
.DebugInit = NetDbgInit,
.DebugExit = NetDbgExit,
.DebugPrint = NetDbgPrint,
};
Wherein, NetDbgInit completes two parts work:First, socket is initialized, second is that creating 2 sub-line journeys.
Netprint sends thread and is used for sending type information to client, usually suspend mode;Other thread dispatchings DBG_PRINTF functions
When, it will it calls and arrives g_tNetDbgOpr.DebugPrint, that is, NetDbgPrint here can wake up netprint hairs
Line sending journey;Subsequent netprint sends thread and the data of buffer circle can be taken out, and calls sendto function transmission datas
To client.Netprint receiving threads are used for receiving control information, such as modification printing rank, open/close printing.
NetDbgExit is used for closing socket, discharges resource.NetDbgPrint is used for keeping in user journal information to loop buffer
Area, and wake up transmission thread.
The buffering area that type information is preserved in netprint.c is not defined using array.Because the distribution of array memory is in journey
Sequence has carried out before executing, but network printing does not know also whether to be bound to use, so for the considerations of saving memory,
It is its storage allocation to use malloc dynamics in NetDbgInit after socket initialization.In this way buffering area only when
Hou Caihui removes storage allocation(It indicates to use it when NetDbgInit is called).
In view of being related to generating data and consumption data simultaneously, therefore buffer circle is used in netprint.c(First
Into the cyclic buffer first gone out, the exclusive reference to buffering area can be provided to signal procedure).
After tested, under LAN environment, UDP packet sizes are 1024*8, and speed reaches 2M/s, and packet drop is ideal;Outer net
Under environment, UDP packet sizes are 548, and speed is ideal, and packet drop is ideal.
Embodiment 1
Have defined in config.h:
//#define DBG_PRINTF(...)
#define DBG_PRINTF DebugPrint
It can open following macro when the code debugging stage, carry out the printing of Debugging message, when going out official release, open above
Macro, note, which falls down the macro of face, can remove type information.
Example code segment is as follows:
static int GetPixelDatasFrmBMP(PT_FileMap ptFileMap, PT_PixelDatas
ptPixelDatas)
{
……
iWidth = ptBITMAPINFOHEADER->biWidth;
iHeight = ptBITMAPINFOHEADER->biHeight;
iBMPBpp = ptBITMAPINFOHEADER->biBitCount;
if (iBMPBpp != 24)
{
DBG_PRINTF("iBMPBpp = %d\n", iBMPBpp);
DBG_PRINTF("sizeof(BITMAPFILEHEADER)=%d\n",sizeof
(BITMAPFILEHEADER));
return -1;
}
……
return 0;
}
Claims (5)
1. a kind of output implementation method by all kinds of means of application layer code Debugging message, it is characterised in that:With debug_manager.c
Program is core layer, supports that the multiple channel of Debugging message exports and telecommunication network printing, developer can be nonlocal real-time
Obtain scene log daily records;The debug_manager.c programs provide practical interface encapsulation for user upwards, are downwards
Specific printing channel abstract package structure, and the registration function of the structure is provided.
2. the output implementation method by all kinds of means of application layer code Debugging message according to claim 1, it is characterised in that:Institute
It states debug_manager.c programs and external unified printing interface encapsulation is provided, Debugging message only needs to call when exporting
The interface that debug_manager.c programs provide, does not need specific implementation of the concerned interface in bottom;It is each specifically to beat
It is abstract to one structure of debug_manager.c program registrations respectively to print channel, while in debug_manager.c programs
Safeguard the chained list of a printing channel for preserving all registrations.
3. the output implementation method by all kinds of means of application layer code Debugging message according to claim 1 or 2, feature exist
In:When new daily record output channel, which is added, to be supported, only need to debug_manager.c programs /debug/ catalogues under add
One bottom document simultaneously completes registration upwards.
4. the output implementation method by all kinds of means of application layer code Debugging message according to claim 1 or 2, feature exist
In:Specific printing channel includes supporting the stdout.c standard I/O interfaces locally exported and telecommunication network being supported to export
Netprintf submodules.
5. the output implementation method by all kinds of means of application layer code Debugging message according to claim 4, it is characterised in that:Institute
Netprintf submodules are stated to be mounted on the target machine, when there is the client-side program on remote computer as UDP server
When logging in UDP server, print data is sent to corresponding client by netprintf submodules, the client one with distal end
Act the network transmission function for realizing log daily records.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810008178.9A CN108363661A (en) | 2018-01-04 | 2018-01-04 | A kind of output implementation method by all kinds of means of application layer code Debugging message |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810008178.9A CN108363661A (en) | 2018-01-04 | 2018-01-04 | A kind of output implementation method by all kinds of means of application layer code Debugging message |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108363661A true CN108363661A (en) | 2018-08-03 |
Family
ID=63010825
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810008178.9A Pending CN108363661A (en) | 2018-01-04 | 2018-01-04 | A kind of output implementation method by all kinds of means of application layer code Debugging message |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108363661A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111538670A (en) * | 2020-04-29 | 2020-08-14 | 烽火通信科技股份有限公司 | U-Boot debugging method and system |
CN114338840A (en) * | 2021-11-08 | 2022-04-12 | 深圳英博达智能科技有限公司 | Socket-based remote debugging method |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2004078350A (en) * | 2002-08-12 | 2004-03-11 | Canon Inc | Printer debug system, terminal for printer debug, printers and method for controlling these and program |
CN104657277A (en) * | 2015-03-13 | 2015-05-27 | 浪潮集团有限公司 | Linux kernel debugging method based on log management |
CN105260315A (en) * | 2015-11-13 | 2016-01-20 | 上海斐讯数据通信技术有限公司 | Method for debugging log in embedded system process |
-
2018
- 2018-01-04 CN CN201810008178.9A patent/CN108363661A/en active Pending
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2004078350A (en) * | 2002-08-12 | 2004-03-11 | Canon Inc | Printer debug system, terminal for printer debug, printers and method for controlling these and program |
CN104657277A (en) * | 2015-03-13 | 2015-05-27 | 浪潮集团有限公司 | Linux kernel debugging method based on log management |
CN105260315A (en) * | 2015-11-13 | 2016-01-20 | 上海斐讯数据通信技术有限公司 | Method for debugging log in embedded system process |
Non-Patent Citations (3)
Title |
---|
BREAKSOFTWARE: "GoogleLog(GLog)源码分析", 《HTTPS://BLOG.CSDN.NET/BREAKSOFTWARE/ARTICLE/DETAILS/51363353》 * |
YING: "glog源码解析三:glog功能扩展:如何按天切割、自定义日志输出等", 《HTTPS://IZUALZHY.CN/GLOG-SOURCE-READING-NOTES-EXTENSION》 * |
格物志: "google-glog 开源库分析(三):glog核心类结构", 《HTTPS://WWW.CNBLOGS.COM/DAVIDYANG2415/P/3861118.HTML》 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111538670A (en) * | 2020-04-29 | 2020-08-14 | 烽火通信科技股份有限公司 | U-Boot debugging method and system |
CN114338840A (en) * | 2021-11-08 | 2022-04-12 | 深圳英博达智能科技有限公司 | Socket-based remote debugging method |
CN114338840B (en) * | 2021-11-08 | 2024-03-22 | 深圳英博达智能科技有限公司 | Socket-based remote debugging method |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111625452B (en) | Flow playback method and system | |
US20210141900A1 (en) | Methods and systems for troubleshooting applications using streaming anomaly detection | |
DE102020132078A1 (en) | RESOURCE ALLOCATION BASED ON APPLICABLE SERVICE LEVEL AGREEMENT | |
CN102739452A (en) | Method and system for monitoring resources | |
US20190163550A1 (en) | Automated methods and systems to classify and troubleshoot problems in information technology systems and services | |
CN109542011A (en) | A kind of standardized acquisition system of multi-source heterogeneous monitoring data | |
CN107451147B (en) | Method and device for dynamically switching kafka clusters | |
CN104486255B (en) | Service resources dispatching method and device | |
CN111309409A (en) | API service call real-time statistical method | |
CN109862051A (en) | The realization method and system of multi-tenant under a kind of micro services framework | |
CN108089566B (en) | BMC stability parallel test method and system | |
CN102929769B (en) | Virtual machine internal-data acquisition method based on agency service | |
CN101277304A (en) | Management system and management method for Web service operational environment based on rules | |
CN111930365B (en) | Qt-based application program rapid development framework, development method and operation method | |
CN105183622B (en) | log processing method and device based on Android system | |
CN106487553A (en) | The processing method of VNF example, device and VNFM | |
CN102457578B (en) | A kind of distributed network monitoring method based on case mechanism | |
CN108363661A (en) | A kind of output implementation method by all kinds of means of application layer code Debugging message | |
CN109144661A (en) | A kind of deep learning management method based on docker | |
CN114189274A (en) | Satellite ground station monitoring system based on microservice | |
EP1410138B1 (en) | Method and apparatus for remote network management | |
CN109460307A (en) | Micro services a little, which are buried, based on log calls tracking and its system | |
WO2021218710A1 (en) | Information transmission method and apparatus, communication device and readable storage medium | |
US20190163404A1 (en) | Methods and systems that efficiently store metric data to enable period and peak detection | |
CN116775420A (en) | Information creation cloud platform resource display and early warning method and system based on Flink flow calculation |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20180803 |