Summary of the invention
Technical matters to be solved by this invention is, overcomes the deficiencies in the prior art, and a kind of debugging embedded software system and method that improves development and testing efficient is provided.
In order to address the above problem, the invention provides a kind of software debugging system, comprise continuous PC end and embedded system end, be used for that PC holds and the debugging software for the treatment of of embedded system end is debugged to operating in simultaneously; The described debugging software for the treatment of is divided into N function set, comprises one or more functions in each function set;
The PC end comprises: debugging control unit and debugging level decision device; The embedded system end comprises the embedded type debugging interface; Wherein:
Described debugging control unit is used to be provided with system operation level set, and the pairing operation class value of each function set is set;
Described debugging level decision device be used for debug process intercept i the function in the function set to the function calls in j the function set after, whether the operation class value of judging j function set is included in the described system operation level set, if then call the function that is called that operates in the PC end; Otherwise the sign of the described function that is called is included in sends to the embedded type debugging interface in the debug command;
Described embedded type debugging interface is used for after receiving debug command, according to the sign of the function that is called that wherein comprises the same functions that operates in the embedded system end is called;
Wherein, N〉1; 1≤i≤N, 1≤j≤N; And i ≠ j.
In addition, for each function set one debugging level decision device is set at the PC end, each debugging level decision device is used for intercepting and capturing the function calls of other function set to this function set; Or
At PC end one debugging level decision device is set, stores in each function set the sign of all functions that called by other function set in this debugging level decision device respectively; Or
For each function setup one debugging level decision device, be used for intercepting and capturing the function of other function set at the PC end to this function calls.
In addition, the PC end also comprises: PC holds debugging interface, is used to receive the debug command that described debugging level decision device sends, and this debug command is sent to described embedded type debugging interface.
In addition, if the described function that is called comprises rreturn value, then described PC end debugging interface also is used for after sending described debug command, receive the debugging that described embedded type debugging interface returns and reply, and the rreturn value that comprises during debugging replied returns to described debugging level decision device;
Described debugging level decision device returns to rreturn value the function that the described function initiation that is called is called.
In addition, described debugging control unit also comprises user interface, is used for resetting in debug process the operation class value of described system operation level set and/or function set.
The present invention also provides a kind of software debugging method, is used for the debugging software for the treatment of that operates in PC end and embedded system end is simultaneously debugged; This method comprises:
The function of debugging level decision device in intercepting i the function set that operates in the PC end that is arranged on PC end to the function calls in j the function set that operates in PC and hold after, whether the operation class value of judging j function set is included in the system operation level set that sets in advance, if then call the function that is called that operates in the PC end; Otherwise the sign of the described function that is called is included in sends to the embedded system end in the debug command;
The embedded system end calls the same functions that operates in the embedded system end according to the sign of the function that is called that wherein comprises after receiving debug command;
Wherein, the described debugging software for the treatment of is divided into N function set, comprises one or more functions in each function set; N〉1; 1≤i≤N, 1≤j≤N; And i ≠ j.
In addition, also comprise the function parameters that is called in the described debug command;
The embedded system end calls the same functions that operates in the embedded system end according to the sign and the parameter of the function that is called that wherein comprises after receiving described order.
In addition, if the described function that is called comprises rreturn value, after then embedded system is called the same functions that operates in the embedded system end, the sign of rreturn value and the described function that is called is included in debugging sends to the PC end debugging interface that is arranged on the PC end in replying;
Described PC end debugging interface is receiving after described debugging replys, and according to the sign of the function that is called rreturn value is returned to described debugging level decision device;
Described debugging level decision device returns to rreturn value the function that the described function initiation that is called is called.
In addition, described treating reduced the number of the operation class value that is comprised in the described system operation level set in the process that debugging software debugs gradually.
In addition, described treating reset the operation class value of one or more function sets in the process that debugging software debugs.
In sum, adopt system and method for the present invention that embedded software is debugged, can farthest utilize abundant debugging resource of PC end and powerful debugging capability, significantly improve the debugging efficiency of embedded software; And in debug process, can only make amendment to the mistake of finding, need not frequent compiling and download the program of embedded system end operation at the PC end.
Embodiment
In recent years, development along with Software Engineering, software systems all have gem-pure hierarchical structure and call relation usually, the function call of layer can not appear striding, and usually can be by the high layer functions of low layer function call (following layer functions " does not call " last layer functions and adopts last layer functions that the return parameters of lower floor's function call is realized usually) yet; For example, the application layer among Fig. 1 can directly not called the hardware writable layer, and only can call the hardware writable layer by Drive Layer carries out the hardware read-write operation; And the hardware writable layer can directly not call upper procedure such as Drive Layer yet.
Embedded software for this layering, can consider that layering debugs, promptly at PC end operation part software layer, simultaneously at operation for embedded system part software layer, and along with the progress of test job is increased in the program of moving in the embedded system (function) gradually, system all normally moves in embedded system until whole software.
For the ease of carrying out the layering debugging at PC end and embedded system, the present invention has defined two variablees: system debug rank (System Debug Level, be called for short SDL), software layer debugging level (Layer DebugLevel, be called for short LDL), and be software layer debugging level value of each software layer distribution.In the operation of PC end, all the other software layers are at operation for embedded system more than or equal to (or greater than) current other software layer of system debug level for the software layer debugging level.
Describe the present invention below in conjunction with drawings and Examples.
Fig. 3 is the structural representation of embodiment of the invention software debugging system.Software debugging of the present invention system is used for the debugging software for the treatment of that can run on PC end and embedded system is debugged, and present embodiment is being that present invention is described for example to the debugging software for the treatment of that comprises three software layers.
As shown in Figure 3, the software debugging system comprises: PC end and embedded system end; The PC end comprises: debugging control unit, the debugging level decision device, the PC that link to each other with the affiliated software layer that runs on the PC end hold debugging interface; The embedded system end comprises: with run on embedded system respectively treat the embedded type debugging interface that the debugging software layer links to each other.
The debugging control unit is used to be provided with the current system debug rank of PC end, and the software layer debugging level that runs on each software layer of PC end;
In addition, the debugging control unit further is used for sending debug command with Start-up and Adjustment to the highest software layer (promptly invoked at first software layer, the software layer A in the present embodiment).
Wherein, treat the debugging software layer for three that run on the PC end: software layer A (LDL=3), software layer B (LDL=2) and software layer C (LDL=1), with run on embedded system in three treat the debugging software layer: software layer A ', software layer B ' and software layer C ' are corresponding respectively, in actual performance history, each the corresponding software layer that runs on PC end and embedded system can pass through different precompile processing commands and precompile grand (for example, in the C language: #if, #ifdef etc.) generation with identical software code.That is to say that the debugging software layer of respectively treating of PC end is compared with corresponding software layer in the embedded system, basic function is identical, and difference only is the running environment difference.
Each software layer of holding for PC all disposes a debugging level decision device (debugging level decision device A, debugging level decision device B and debugging level decision device C), each debugging level decision device is used to intercept and capture the function call to affiliated software layer, and whether the software layer debugging level of judging this software layer is more than or equal to current system debug rank: if, then the respective function of this software layer is called, otherwise this function call is changed into corresponding debug command (carrying out corresponding debug command function calls in other words), be sent to the embedded type debugging interface by PC end debugging interface, and carry out the calling of corresponding software layer respective function in the embedded system by the embedded type debugging interface.
(when the debug command function that provides of PC end debugging interface is called by each debugging level decision device in other words) is provided when receiving the debug command that each debugging level decision device sends PC end debugging interface, sends corresponding debug command to the embedded type debugging interface; And the debugging that receives embedded type debugging interface feedback replys (rreturn value that is function call), and debugging replied sends to corresponding debugging level decision device.
The embedded type debugging interface is used to receive the debug command that PC end debugging interface sends, and according to the title (perhaps being called sign) and the parameter (if parameter is arranged) of debug command, call the respective function of moving in the embedded system, and the rreturn value of function call is sent to PC end debugging interface.
Can pass through hardware interface (not shown)s such as USB, UART between PC end debugging interface and the embedded interface and link to each other, carry out transmission/reception that above-mentioned debug command and debugging are replied.
How to illustrate by the debugging level decision device of PC end with two examples below and initiate each software layer function calls embedded system.
Example 1 (no rreturn value):
If comprise function: B1 (parameter 1, parameter 2) among the software layer B, the respective function of software layer B ' is in the embedded system: B1 ' (parameter 1, parameter 2); B1 and B1 ' do not have rreturn value.It should be noted that for convenience the respective function that is respectively in PC end and the embedded system has played different title (for example above-mentioned B1 and B1 ') herein, but in fact PC hold with embedded system in the respective function title normally identical.
When the function among the software layer A called B1, debugging level decision device B intercepted this function call, and was converted into following debug command (can be called no rreturn value function call request):
SetCommand (' B1 ', parameter 1, parameter 2);
Debugging level decision device B is sent to the embedded type debugging interface by PC end debugging interface with above-mentioned debug command.After the embedded type debugging interface receives this order, therefore first parameter ' B1 ' according to the SetCommand function is known the function B1 ' that need call among the software layer B ', second of the SetCommand function and the 3rd parameter is carried out function call as the input parameter of B1 '.
Example 2 (rreturn value is arranged):
If the rreturn value of function B1 in the example 1 and B1 ' is a round values;
When the function among the software layer A called B1, debugging level decision device B intercepted this function call, and was converted into following debug command (can be called the rreturn value function call request is arranged):
GetCommand (' B1 ', parameter 1, parameter 2);
Debugging level decision device B is sent to the embedded type debugging interface by PC end debugging interface with above-mentioned debug command.After the embedded type debugging interface receives this order, first parameter ' B1 ' according to the GetCommand function is known the function B1 ' that need call among the software layer B ', therefore second of the GetCommand function and the 3rd parameter are carried out function call as the input parameter of B1 ', obtain rreturn value RET1;
The embedded type debugging interface is replied (can be called function call replys) by following debugging rreturn value is sent to PC end debugging interface:
RetCommand(‘B1’,RET1);
After PC end debugging interface receives mentioned order, rreturn value RET1 is returned to debugging level decision device B according to first parameter ' B1 '.
During specific implementation, can hold the sending function of realizing above-mentioned no rreturn value function call request in the debugging interface and the rreturn value function call request being arranged at PC, promptly realize SetCommand function and GetCommand function at PC end debugging interface, call SetCommand function and GetCommand function by each debugging level decision device, realize each software layer function calls in the embedded system.Certainly, also can save PC end debugging interface, in each debugging level decision device, realize above-mentioned no rreturn value function call request and the sending function that the rreturn value function call request is arranged.
In addition, intercept and capture function, can adopt one of following dual mode that each the software layer program and the debugging level decision device of PC end are made amendment for the function call that realizes the debugging level decision device:
Mode one: for being generated unified calling interface by the function that other software layer calls in the software layer, in this calling interface, carry out the judgement of software layer debugging level and current system debug rank magnitude relationship, and call this software layer function, or send debug command to embedded system by PC end debugging interface according to judged result.When adopting this mode, need a debugging level decision device be set for each software layer, a certain function calls to software layer, be by the title (sign) of this function is called realization as parameter to the debugging level decision device of this software layer, so need to comprise in this software layer the identification list of all functions that can be called by other software layer in the debugging level decision device.
For example, the external input one calling interface function of debugging level decision device B, name is called: Debug_B, can adopt following form to call the function B1 of software layer B (parameter 1, parameter 2):
Debug_B (' B1 ', parameter 1, parameter 2).
Mode two: carry out the judgement of software layer debugging level and current system debug rank magnitude relationship in each function body inside of software layer, and carry out the normal flow of this function, or send debug command to embedded system by PC end debugging interface according to judged result.When adopting this mode, the debugging level decision device is included in each function of each software layer, promptly needs to be each function setup one debugging level decision device.But, do not comprise debugging level decision device function in the software layer function that moves in the embedded system through precompile processing command and the grand compiling generation of precompile.
Fig. 4 is an embodiment of the invention software debugging method flow diagram, and this flow process is that example is described adjustment method of the present invention with the debugging software for the treatment of that comprises three software layers equally.As shown in Figure 4, this method comprises the steps:
401: compiling is created on the executable program of PC end operation and at the executable program of operation for embedded system respectively, and the executable program of operation for embedded system is downloaded to embedded system.
The software layer debugging level LDL that the debugging control unit of 402:PC end is provided with current system debug rank SDL and runs on each software layer of PC end.
SDL can realize with a global variable, so that each debugging level decision device reads when intercepting function call at any time.
403: the function among the debugging control cell call software layer A, Start-up and Adjustment process.
In debug process, repeat following operation:
404: the debugging level decision device intercepts after this software layer function calls, and whether the software layer debugging level LDL that judges this software layer is less than SDL: if less than, then execution in step 405; Otherwise execution in step 406.
405: the debugging level decision device converts the function call that receives to debug command, is sent to embedded system by PC end debugging interface, and the embedded type debugging interface carries out corresponding function call according to the function name that comprises in the debug command that receives; Function has rreturn value if this is called, and then rreturn value is sent to PC end debugging interface, and PC end debugging interface sends to the debugging level decision device with rreturn value.
406: the debugging level decision device calls the function that is called of PC end operation, and function has rreturn value if this is called, and then rreturn value is returned to call function.
When adopting adjustment method of the present invention, the rank of system debug earlier is set to less value usually, so that make full use of the powerful debugging capability of PC end in the more program of PC end operation; For example in system shown in Figure 3, at first system debug rank is set to 2, and (if be set to 1 is exactly in all programs of PC end operation, not in the discussion scope of this paper), has only minimum software layer (the promptly last software layer that moves this moment, software layer C) move in embedded system, other each software layer is in the operation of PC end.
Carrying out along with debug process, when increasing software layer can reliability service in embedded system, system debug rank gradually is set to bigger value, promptly in the more program of operation for embedded system, all moves in embedded system until all programs.
In addition, if adopt system and method for the present invention, treat that debugging software need meet the following conditions:
(1) rreturn value of being striden the function that software layer calls can not be pointer value (for example: point to an integer pointer, point to the pointer of an array etc.); If pointer value, when this function itself operates in embedded system, and when being called by the PC end, the PC end can't obtain this pointer value actual value pointed or actual object.
(2) try not to use the global variable that can be modified and can be read and use by a plurality of software layers, to avoid the inconsistent of PC end and embedded system.
It should be noted that, this paper does not mention the debugging acid and the debugging acid of PC end and respectively treats the annexation of debugging software layer, this is because PC end debugging acid is of a great variety, and is also complicated and changeable with the relation for the treatment of the debugging software layer, even neither one boundary clearly.Most importantly PC holds the use and the debugging acid of debugging acid and treats that the relation of debugging software layer belongs to prior art, and the present invention does not make amendment, and does not carry out special qualification yet, does not therefore belong to discussion category of the present invention.
According to ultimate principle of the present invention, the foregoing description also has multiple mapping mode, for example:
(1) in the above-described embodiments according to software layer from high to low the order of (be invoked order by arrive first back) distribute descending LDL value successively; In other embodiments of the invention, also can be according to opposite order assignment LDL value, in this case, the judgment criterion of the debugging level decision device of each software layer should become:
The LDL value smaller or equal to the software layer of (or less than) current SDL value in the operation of PC end; All the other software layers are at operation for embedded system.
Can also further expand SDL, as a set, for example the PC end moves level set, or embedded operation level set (being referred to as system operation level set) with it again.For embodiment illustrated in fig. 3, when SDL=2, if adopt the notion of PC end operation level set, then the element that comprises in this set be 2,3}, if adopt the notion of embedded operation level set, then the element that comprises in this set is { 1}.
(2) be each software layer or each function setup one debugging level decision device that is called in the foregoing description; In other embodiments of the invention, also can a debugging level decision device be set for the whole debugging software for the treatment of, all function calls of striding software layer all need to be intercepted and captured by this debugging level decision device, and judge that through above-mentioned debugging level hold PC according to judged result the back or the respective function of embedded system is called at this debugging level decision device.
(3) can dynamically adjust owing to the system debug rank, therefore the debugging control unit can provide a user interface, make the commissioning staff can in debug process, dynamically arrange new system debug class value, to realize need not to suspend the quantity that debugging (more need not to recompilate) just can be adjusted at the software layer that moves in PC end and the embedded system.
Certainly, the commissioning staff can also achieve the above object by the software layer debugging level that the user interface of debugging control unit is dynamically adjusted each software layer.
(4) though in the above embodiment of the present invention, treat that debugging software has hierarchical relationship and call relation clearly, for example, can not stride software layer and carry out function call, following layer functions can not call layer functions; But this does not also mean that debug system of the present invention and method can not be applied to not satisfy above-mentioned condition software systems.
Therefore, we can be called function set with above-mentioned software layer, and each function set has different operation class value, therefore move class value and can be used as the function set sign.