Background technology
Embedded system is normally towards application-specific, and it requires very strict to the execution sequence and the execution time of logic.Embedded system is applicable to function, reliability, cost, volume, the strict dedicated system of power consumption.Software development for embedded system also is different from general application software, the former requires the developer that the hardware of embedded system is had enough understandings, the software of a good embedded system of exploitation is difficulty very, therefore is necessary very much the debugger of suitable embedded system.
Existing embedded type debugging mode mainly contains dual mode: a kind of is on-line debugging, and another is the off-line debugging.
The scheme of the on-line debugging of embedded system is as follows usually: dispose the debugger service end on embedded board (that is: Target Board), dispose the debugger client at PC(personal computer, personal computer) on, client is connected by passages such as network interface or serial ports with service end.Service end be responsible for visiting or controlling embedded system resource (such as, internal memory, register etc.), client on the PC is responsible for accepting user's order input, carries out real-time/non real-time analysis of command analysis, Debugging message parsing and debugged program, and the output of debugging analysis result etc.
On-line debugging comprises non real-time debud mode (that is: stop debud mode) again, real-time debug mode (that is: non-stop debud mode).The Stop debud mode needs earlier debugged program to be stopped, then the information of routine analyzer and state.The non-stop debud mode then can obtain the correlation behavior information of program etc. in real time.All there is defective in these two kinds of on-line debugging modes, and are specific as follows:
(1) if certain constantly client and the Target Board of debugger service end be connected interruptions, then the program appearance is unusually.At this moment because the client of debugger can't be obtained the real-time condition of debugged program, also the state of uncontrollable debugged program causes the on-line debugging mode to lose efficacy.
(2), because program unusual common has randomness and non-reproducibility, cause the reproduction difficulty of such problem greatlyyer, the inefficacy of on-line debugging will cause the efficient reduction of positioning problems and analysis.
Because test process finishes at Target Board, there be not being connected between Target Board and the debugger in the scheme of off-line test; Therefore can avoid above-mentioned technological deficiency, the scheme of off-line debugging is as follows usually: Target Board will comprise the dump file of backup, and the dump file of backup includes register information, memory information and operation system information etc.; The dump file that obtains Debugging message and above-mentioned backup of Target Board off-line on debugger is analyzed the program exception reason then.But also there is following defective in the off-line debugging:
Because the platform of Target Board operation is of a great variety, comprises operating system and the relevant information of Target Board platform in the dump file of backup, therefore the dump file of backup there are differences on form.In addition, in the systemic software development stage of Target Board, the edition upgrading of this system software is very fast usually, yet the dump file form of different editions system software correspondence be there are differences again.Therefore, the debugger client is at the dump file of realizing supporting different platform, or the dump file of support same platform different editions, then needs the debugger client is changed in a large number.Like this,, still need to revise the debugger client, need great amount of manpower and time and often revise debugger in order to solve debugger client and the platform contradiction on file layout is supported.
In sum, off-line debugging is owing to need constantly to revise the debugger client and bring in and realize the off-line debugging, causes realizing that the difficulty of off-line analysis is big, cost is higher, the time is long.In addition, the debugging acid of on-line debugging and off-line debugging needs exploitation respectively, has the problem of overlapping development.
Summary of the invention
The embodiment of the invention provides a kind of adjustment method, debugging conversion equipment and system of embedded system, is used to increase the usable range of online debugging acid, shortens the development time of off-line debugging acid, reduces cost of development.
The embodiment of the invention provides a kind of adjustment method of embedded system on the one hand, comprising:
Obtain the transformation rule of the on-line debugging order of customization to the off-line debug command;
Behind the source code that receives the on-line debugging order,, the source code of described on-line debugging order is converted to the code of support off-line debugging according to described transformation rule;
The code of described support off-line debugging is sent to Target Board.
In conjunction with implementation on the one hand, in first kind of optional implementation, described source code with described on-line debugging order converts the code of supporting the off-line debugging to, the code of described support off-line debugging is sent to Target Board comprise:
The source code of described on-line debugging order is converted to the source code of off-line debug command; With the off-line order source code that obtains and current debugger client, carry out the secondary compiling and generate the debugger client of supporting the off-line debugging, the debugger client of described support off-line debugging is sent to Target Board; Perhaps,
The source code of described on-line debugging order is converted to the code of off-line debug command and is linked as dynamic base, described dynamic base is sent to Target Board.
In conjunction with first kind of optional implementation, in second kind of optional implementation, the source code that described source code with described on-line debugging order converts the off-line debug command to comprises:
Use compiler the source code of described on-line debugging order to be converted to the source code of off-line order; Perhaps, by client utility the source code of described on-line debugging order is converted to the source code of off-line order.
In conjunction with second kind of optional implementation, in the third optional implementation, described use compiler comprises the source code that the source code of described on-line debugging order converts the off-line order to:
Read in the source code of described on-line debugging order, carry out the rule match of character string,, then call the conversion process interface and generate morphology or the syntactic units that compiler can be discerned, export the source code of off-line debug command then if the match is successful according to described transformation rule.
In conjunction with one side, first kind, second kind or the third optional implementation, in the 4th kind of optional implementation, described transformation rule comprises:
At least one item in symbol table information transformation rule, register and call stack rule, debugging output interface transformation rule, the internal memory distribution rule;
Described symbol table information transformation rule is: the rule of the symbolic information that the map addresses information translation of professional related symbol of on-line debugging order or globak symbol can be discerned to in-circuit debugger;
Described register and call stack rule are: general-purpose register number, function return address, the register configuration of stack pointer or personal computer PC pointer, and function call stack information;
Described debugging output interface transformation rule is: the command interface of on-line debugging is transformed into the rule of off-line debug command interface;
Described internal memory distribution rule is: determine the size of privately owned internal memory or shared drive and the rule that distributes.
The embodiment of the invention two aspects provide a kind of debugging conversion equipment of embedded system, comprising:
The rule acquiring unit is used to obtain the transformation rule of the on-line debugging order of customization to the off-line debug command;
The source code receiving element is used to receive the source code of online debug command;
Converting unit is used for after described source code receiving element receives the source code of on-line debugging order, according to the transformation rule that described regular acquiring unit gets access to, the source code of described on-line debugging order is converted to the code of support off-line debugging;
Transmitting element, the code that the support off-line that is used for that described converting unit is obtained is debugged sends to Target Board.
In conjunction with the implementation of two aspects, in first kind of optional implementation, described converting unit specifically is used for the source code of described on-line debugging order is converted to the source code of off-line debug command; The off-line order source code and the current debugger client that obtain are carried out the debugger client that the secondary compiling generates the debugging of support off-line; Perhaps, the source code with described on-line debugging order converts the code of off-line debug command to and is linked as dynamic base;
Described transmitting element, the debugger client that the support off-line that is used for that specifically described converting unit is obtained is debugged sends to Target Board; Perhaps the dynamic base that described converting unit is obtained sends to Target Board.
In conjunction with the implementation of two aspects, in second kind of optional implementation, described converting unit specifically is used to use compiler the source code of described on-line debugging order to be converted to the source code of off-line order; Perhaps, by client utility the source code of described on-line debugging order is converted to the source code of off-line order.
In conjunction with second kind implementation, in the third optional implementation, described converting unit comprises:
Reading unit is used to read in the source code of the on-line debugging order that described source code receiving element receives;
Matching unit is used for carrying out according to the transformation rule that described regular acquiring unit obtains the rule match of character string;
The source code generation unit is used for that the match is successful as if described matching unit, then calls the conversion process interface and generates morphology or the syntactic units that compiler can be discerned, and exports the source code of off-line debug command then.
In conjunction with one side, first kind, second kind or the third optional implementation, in the 4th kind of optional implementation, described regular acquiring unit, the transformation rule that obtains comprises: at least one item in symbol table information transformation rule, register and call stack rule, debugging output interface transformation rule, the internal memory distribution rule;
Described symbol table information transformation rule is: the rule of the symbolic information that the map addresses information translation of professional related symbol of on-line debugging order or globak symbol can be discerned to in-circuit debugger;
Described register and call stack rule are: general-purpose register number, function return address, the register configuration of stack pointer or personal computer PC pointer, and function call stack information;
Described debugging output interface transformation rule is: the command interface of on-line debugging is transformed into the rule of off-line debug command interface;
Described internal memory distribution rule is: determine the size of privately owned internal memory or shared drive and the rule that distributes.
The embodiment of the invention three aspects provide a kind of debug system of embedded system, comprise, debugger, Target Board also comprise: any one debugging conversion equipment that the embodiment of the invention provides;
Described debugging conversion equipment receives the source code of online debug command from the client of described debugger, and will support the code of off-line debugging to export to the service end of described Target Board.
As can be seen from the above technical solutions, the embodiment of the invention has the following advantages: by the on-line debugging order being carried out the conversion of the code of debugging from the source code of on-line debugging order to off-line, realize the off-line debugging of online debug command, can solve the on-line debugging of built-in system software and the overlapping development problem of off-line debugging, avoid different Platform Implementation off-line debugging, or all need to revise the problem of debugger client during to the debugging of the off-line of identical Platform Implementation different editions, therefore, can increase the usable range of online debugging acid, shorten the development time of off-line debugging acid, reduced cost of development.
Embodiment
In order to make the purpose, technical solutions and advantages of the present invention clearer, the present invention is described in further detail below in conjunction with accompanying drawing, and obviously, described embodiment only is a part of embodiment of the present invention, rather than whole embodiment.Based on the embodiment among the present invention, those of ordinary skills belong to the scope of protection of the invention not making all other embodiment that obtained under the creative work prerequisite.
The embodiment of the invention provides a kind of adjustment method of embedded system, as shown in Figure 1, comprising:
101: obtain the transformation rule of the on-line debugging order of customization to the off-line debug command;
Above-mentioned on-line debugging order is to the transformation rule of off-line debug command, can be to set up the rule of online debug command arbitrarily to off-line debug command corresponding relation, transformation rule can increase or reduce according to actual needs, the concrete form embodiment of the invention has provided following giving an example: alternatively, above-mentioned transformation rule comprises: at least one item in symbol table information transformation rule, register and call stack rule, debugging output interface transformation rule, the internal memory distribution rule; Above-mentioned symbol table information transformation rule is: the rule of the symbolic information that the map addresses information translation of professional related symbol of on-line debugging order or globak symbol can be discerned to in-circuit debugger; Above-mentioned register and call stack rule are: general-purpose register number, function return address, the register configuration of stack pointer or personal computer PC pointer, and function call stack information; Above-mentioned debugging output interface transformation rule is: the command interface of on-line debugging is transformed into the rule of off-line debug command interface; Above-mentioned internal memory distribution rule is: determine the size of privately owned internal memory or shared drive and the rule that distributes.Need to prove that the rule of code conversion can have many types, more than should not be construed as qualification for example to the embodiment of the invention.
102: behind the source code that receives the on-line debugging order,, the source code of above-mentioned on-line debugging order is converted to the code of support off-line debugging according to above-mentioned transformation rule;
Alternatively, the embodiment of the invention has provided two kinds of schemes of optionally supporting the code of off-line debugging, and is as follows: above-mentioned source code with above-mentioned on-line debugging order converts to supports the code of off-line debugging to comprise: the source code that the source code of above-mentioned on-line debugging order is converted to the off-line debug command; With the off-line order source code that obtains and current debugger client, carry out the secondary compiling and generate the debugger client of supporting the off-line debugging; Perhaps, the source code with above-mentioned on-line debugging order converts the code of off-line debug command to and is linked as dynamic base.
Alternatively, the embodiment of the invention gives two kinds of on-line debugging orders and arrives the conversion implementation of the source code of off-line debug command to source code, and particularly: the source code that above-mentioned source code with above-mentioned on-line debugging order converts the off-line debug command to comprises: use compiler the source code of above-mentioned on-line debugging order to be converted to the source code of off-line order; Perhaps, by client utility the source code of above-mentioned on-line debugging order is converted to the source code of off-line order.
Alternatively, the embodiment of the invention gives uses compiler to realize the specific implementation of source code to the conversion of source code, as follows: above-mentioned use compiler comprises the source code that the source code of above-mentioned on-line debugging order converts the off-line order to: the source code that reads in above-mentioned on-line debugging order, carry out the rule match of character string according to above-mentioned transformation rule, if the match is successful, then call the conversion process interface and generate morphology or the syntactic units that compiler can be discerned, export the source code of off-line debug command then.
103: the code of above-mentioned support off-line debugging is sent to Target Board.
Above scheme, by the on-line debugging order being carried out the conversion of the code of debugging from the source code of on-line debugging order to off-line, realize the off-line debugging of online debug command, can solve the on-line debugging of built-in system software and the overlapping development problem of off-line debugging, avoid different Platform Implementation off-line debugging, or all need to revise the problem of debugger client during to the debugging of the off-line of identical Platform Implementation different editions, therefore, can increase the usable range of online debugging acid, shorten the development time of off-line debugging acid, reduced cost of development.
Alternatively, corresponding to two kinds of schemes of optionally supporting the code of off-line debugging of front embodiment, above-mentioned code with above-mentioned support off-line debugging sends to Target Board and comprises: the debugger client of above-mentioned support off-line debugging is sent to Target Board; Perhaps, above-mentioned dynamic base is sent to Target Board.
Following examples respectively with regard to structure form, the angle of debugging networking, source code conversion and example illustrates in more detail to the scheme of above embodiment.
One, structure is formed
See also and Figure 2 shows that: by the source-to-source conversion, generate the modular structure synoptic diagram of off-line order, wherein the direction of arrow is data flow.
Can use C as programming language for the online and off-line debugger of embedded system development in this example.On-line debugging order source code (mainly being .c and .h file) is as the input source of off-line command converter.
The off-line command converter mainly contains three parts: symbol resolution module, dump file parsing module and source-to-source modular converter.
The symbol resolution module is obtained the definition and the address mapping table of globak symbol from input source, and the denotational description information relevant with business, after carrying out symbol resolution and handling, outputs to the source-to-source modular converter.
Another input of source-to-source modular converter is from the dump file parsing module, the dump file parsing module is mainly finished analysis and the processing to off-line files register and call stack rule, this part ISA(Industrial Standard Architecture common and embedded system, industrial standard architecture bus) strong correlation.
Just can finish the output of last off-line debug command source code (mainly being .c and .h file) after getting access to the information that needs when the source-to-source modular converter by the rule that inside defines.The off-line debugger of this moment has had professional related symbol table information and address information that the in-circuit debugger module has, uses the printing interface of off-line debugger just can obtain the product service related information.
Two, debugging networking
Typical debugger networking synoptic diagram as shown in Figure 3,
Under the on-line debugging scene, be positioned at PC(personal computer, personal computer) the debugger client of end and be positioned at debugging services end on the Target Board (Board) by ETH(Ethernet, network interface) or passage such as serial ports communicate.Wherein also include IDE(Integrated Development Environment, Integrated Development Environment in the PC side), also include application program, system and internal memory/register in the Board side.
Under the off-line debugging scene, the debugger client is obtained needed register/memory information, operation system information or product business information by file I/O from the dump file (Core File on PC) of PC.
Three, source code conversion
Seeing also Fig. 4 is: online command conversion becomes the schematic flow sheet of off-line order.
401: formulate the transformation rule that the on-line debugging order smooths to the off-line debug command;
The on-line debugging order has the complete rule of a cover to the conversion of off-line order.The customization of rule mainly can comprise following a few part: symbol table information transformation rule, the main rule of formulating the symbolic information that the map addresses information translation of professional related symbol of on-line debugging order or globak symbol can be discerned to in-circuit debugger.Register and call stack rule comprise the general-purpose register number, the function return address, and register configuration such as stack pointer and PC pointer, and function call stack information etc.Debugging output interface transformation rule, the command interface of formulating on-line debugging is transformed into off-line debug command interface.The internal memory distribution rule is determined the size of privately owned internal memory or shared drive and distribution etc.Can be according to the demand of practical business, add or delete some rule.
402: use source code conversion compiler the source code of on-line debugging order to be converted to the source code of off-line debug command;
The ultimate principle of the conversion of this step can for: read in the source code of online debug command, carry out the rule match of character string according to the transformation rule of above-mentioned formulation.If the match is successful, then call the conversion process interface and generate morphology or the syntactic units that compiler can be discerned, export the source code of last off-line debug command again by compiler.
403: the source code by the off-line debug command that will generate in 402 is compiled in and can generates new off-line debugger client together together with the source code of the irrelevant off-line debugging of framework and conversion.
Above scheme step 402 and 403 all can adopt other modes to replace, and is specific as follows:
In the above-mentioned schematic flow sheet 4 402 is to have adopted source code conversion compiler the source code of on-line debugging order to be converted to the source code of off-line debug command.Replacement scheme can not rely on compiler, realizes that separately a source code with the on-line debugging order converts the conversion client instrument of the source code of off-line debug command to.That is to say that crossover tool can break away from compiler, client utility possesses the process of analysis rule map, generates the function of final source code.
402 another kind of replacement schemes in the schematic flow sheet 4 are by compiler, and the code (mainly being .c and .h file) of changing the off-line order of coming out is linked into a dynamic base (.dll or .so form).The compiling of secondary in 403 just can be omitted so, and the debugger client of off-line only needs the dynamic base of generation in the dynamic load 402 just can finish corresponding debug function.
Four, example
Below be a kind of enforcement scene:
See also and Figure 5 shows that a source-to-source transfer process example, this example is to inquire about the CPU(Central Processing Unit of current system, central processing unit) load factor is an example, Fig. 5 adopts the C language compilation, can be with reference to the related specifications of C language compilation, left side one source code of classifying the on-line debugging order as wherein, right side arrow is pointed to is the source code of corresponding with it off-line debug command, this example converts the source code of on-line debugging order to the process of the source code of off-line debug command.Mainly be divided into three steps:
1, identifies this order global variable in realizing.This is the relevant global variable of a business, at first is the transformation rule that will have this service symbol of identification.Rule is very simple, the character string of identification in the quotation marks (be among Fig. 5, most going up a boldface letter content frame of broken lines in the top big frame).
The off-line command converter is constantly read in input file (being Fig. 5 left side side code), (this is the calling interface of a service inquiry symbolic address when recognizing the DSP_LkAddr key word, in Rulemaking, can be configured in this interface interchange in the rule, the coupling that is used for character string), the off-line command converter matches the character string that brackets with double quotation marks of this key word back, is exactly gstruCpuLoad in this example.Subsidiary implicit transformation rule is original structure body member to be called be converted to that the member of identification string calls, as struCpuLoad.uwCurLoad----〉gstruCpuLoad.uwCurLoad, this transformation result will be as the input of following function call translation interface.Conversion corresponding relation shown in the arrow as shown in Figure 5.
2, obtain the function call of global variable value, replace to the function call in the off-line debug client end.
In Fig. 5, converting the calling interface DSP_CommRead of the professional address of variable of online query to corresponding off-line calling interface getSymAddrSize, simultaneously top struCpuLoad.uwCurLoad----〉the gstruCpuLoad.uwCurLoad transformation result imports into as interface parameters.
3, the function call of order return results output replaces to the function call of off-line debug client end.
After globak symbol and the interface conversion of obtaining overall situation amount are finished, just can realize the conversion of final step platform printout interface, this has changed the function that has realized last debug results output switching.Be transformed into off-line printing interface printf such as the on-line debugging interface LBB_DSP_Printf in this example.
Adopt above scheme, debugging is applied to different scenes because the on-line debugging of built-in system software is with off-line, and the debud mode that all is absolutely necessary.The embodiment of the invention realizes the off-line debugging of online debug command, can solve the on-line debugging of built-in system software and the overlapping development problem of off-line debugging, by the on-line debugging order being carried out the conversion of the code of debugging from the source code of on-line debugging order to off-line, convert the off-line debug command that on PC, to use to, and the product business information that will relate in will ordering uses the symbol resolution function to convert address and length to, and the off-line order promptly can be obtained system related information by inquiry corresponding memory addresses interval.Realize that the off-line debugging of online debug command can avoid different Platform Implementation off-line debugging, or all need to revise the problem of debugger client during to the debugging of the off-line of identical Platform Implementation different editions, therefore, the inventive method can increase the usable range of online debugging acid, shorten the development time of off-line debugging acid, reduced cost of development.
The embodiment of the invention also provides a kind of debugging conversion equipment of embedded system, as shown in Figure 6, comprising:
Rule acquiring unit 601 is used to obtain the transformation rule of the on-line debugging order of customization to the off-line debug command;
Source code receiving element 602 is used to receive the source code of online debug command;
Converting unit 603 is used for after above-mentioned source code receiving element 602 receives the source code of on-line debugging order, according to the transformation rule that above-mentioned regular acquiring unit 601 gets access to, the source code of above-mentioned on-line debugging order is converted to the code of support off-line debugging;
Transmitting element 604, the code that the support off-line that is used for that above-mentioned converting unit 603 is obtained is debugged sends to Target Board.
Above scheme, by the on-line debugging order being carried out the conversion of the code of debugging from the source code of on-line debugging order to off-line, realize the off-line debugging of online debug command, can solve the on-line debugging of built-in system software and the overlapping development problem of off-line debugging, avoid different Platform Implementation off-line debugging, or all need to revise the problem of debugger client during to the debugging of the off-line of identical Platform Implementation different editions, therefore, can increase the usable range of online debugging acid, shorten the development time of off-line debugging acid, reduced cost of development.
Alternatively, above-mentioned converting unit 603 specifically is used for the source code of above-mentioned on-line debugging order is converted to the source code of off-line debug command; The off-line order source code and the current debugger client that obtain are carried out the debugger client that the secondary compiling generates the debugging of support off-line; Perhaps, the source code with above-mentioned on-line debugging order converts the code of off-line debug command to and is linked as dynamic base;
Above-mentioned transmitting element 604, the debugger client that the support off-line that is used for that specifically above-mentioned converting unit 603 is obtained is debugged sends to Target Board; Perhaps the dynamic base that above-mentioned converting unit 603 is obtained sends to Target Board.
Alternatively, above-mentioned converting unit 603 specifically is used to use compiler the source code of above-mentioned on-line debugging order to be converted to the source code of off-line order; Perhaps, by client utility the source code of above-mentioned on-line debugging order is converted to the source code of off-line order.
Alternatively, as shown in Figure 7, above-mentioned converting unit 603 comprises:
Reading unit 701 is used to read in the source code of the on-line debugging order that above-mentioned source code receiving element 602 receives;
Matching unit 702 is used for carrying out according to the transformation rule that above-mentioned regular acquiring unit 601 obtains the rule match of character string;
Source code generation unit 704 is used for that the match is successful as if above-mentioned matching unit 702, then calls the conversion process interface and generates morphology or the syntactic units that compiler can be discerned, and exports the source code of off-line debug command then.
Alternatively, above-mentioned regular acquiring unit 601, the transformation rule that obtains comprises: at least one item in symbol table information transformation rule, register and call stack rule, debugging output interface transformation rule, the internal memory distribution rule;
Above-mentioned symbol table information transformation rule is: the rule of the symbolic information that the map addresses information translation of professional related symbol of on-line debugging order or globak symbol can be discerned to in-circuit debugger;
Above-mentioned register and call stack rule are: general-purpose register number, function return address, the register configuration of stack pointer or personal computer PC pointer, and function call stack information;
Above-mentioned debugging output interface transformation rule is: the command interface of on-line debugging is transformed into the rule of off-line debug command interface;
Above-mentioned internal memory distribution rule is: determine the size of privately owned internal memory or shared drive and the rule that distributes.
The embodiment of the invention also provides a kind of debug system of embedded system, as shown in Figure 8, comprises, debugger 801, Target Board 803 also comprise: any one debugging conversion equipment 802 that the embodiment of the invention provides; Above-mentioned debugging conversion equipment 802 receives the source code of online debug command from the client of above-mentioned debugger 801, and will support the code of off-line debugging to export to the service end of above-mentioned Target Board 803.
It should be noted that among the above-mentioned debugging conversion equipment embodiment that each included unit is just divided according to function logic, but is not limited to above-mentioned division, as long as can realize function corresponding; In addition, the concrete title of each functional unit also just for the ease of mutual differentiation, is not limited to protection scope of the present invention.
In addition, one of ordinary skill in the art will appreciate that all or part of step that realizes among above-mentioned each method embodiment is to instruct relevant hardware to finish by program, corresponding program can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium of mentioning can be a ROM (read-only memory), disk or CD etc.
Below only be the preferable embodiment of the present invention; but protection scope of the present invention is not limited thereto; anyly be familiar with those skilled in the art in the technical scope that the embodiment of the invention discloses, the variation that can expect easily or replacement all should be encompassed within protection scope of the present invention.Therefore, protection scope of the present invention should be as the criterion with the protection domain of claim.