Background technology
Embedded system is normally towards application-specific, and it requires very strict to the execution sequence of logic and execution time.Embedded system is applicable to the strict dedicated system of function, reliability, cost, volume, power consumption requirements.Software development for embedded system is also different from general application software, the former requires that the hardware of developer to embedded system has enough understandings, the software developing a good embedded system is very difficult, is therefore necessary very much the debugger of applicable embedded system.
Existing embedded type debugging mode mainly contains two kinds of modes: one is on-line debugging, and another is off-line debugging.
The scheme of the on-line debugging of embedded system is usually as follows: dispose debugger service end on embedded board (that is: Target Board), dispose debugger client at PC(personalcomputer, personal computer) on, client and service end are by the expanding channels such as network interface or serial ports.Service end is responsible for the resource of access or control embedded system (such as, internal memory, register etc.), client on PC is responsible for accepting the order input of user, carries out command analysis, Debugging message resolves and the real-time/non-real time analysis of debugged program, and the output of Commissioning Analysis result etc.
On-line debugging comprises again non real-time debud mode (that is: stop debud mode), real-time debug mode (that is: non-stop debud mode).Stop debud mode needs first by debugged program stopped, then the information of routine analyzer and state.Non-stop debud mode then can the related status information etc. of Real-time Obtaining program.These two kinds of on-line debugging modes all existing defects, specific as follows:
(1) if the disconnecting of the client of certain moment debugger and the service end of Target Board, then program occurs abnormal.At this moment because the client of debugger cannot obtain the real-time condition of debugged program, the also state of uncontrollable debugged program, causes on-line debugging mode to lose efficacy.
(2), because the exception of program has randomness and non-reproducibility usually, cause the reproduction difficulty of such problem comparatively large, the inefficacy of on-line debugging reduces causing the efficiency of positioning problems and analysis.
, because test process completes at Target Board, there is not the connection between Target Board and debugger in the scheme of off-line test; Therefore can avoid above-mentioned technological deficiency, the scheme of off-line debugging is usually as follows: 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.; Target Board is the acquisition Debugging message of off-line and the dump file of above-mentioned backup on debugger, then analyzes program exception reason.But also there is following defect in off-line debugging:
The platform run due to Target Board is of a great variety, and comprise operating system and the relevant information of Target Board platform in the dump file of backup, the dump file therefore backed up there are differences on form.In addition, in the systemic software development stage of Target Board, the edition upgrading of this system software is usually very fast, but the dump file form corresponding to different editions system software there are differences again.Therefore, debugger client is realizing the dump file supporting different platform, or supports the dump file of same platform different editions, then need to change in a large number debugger client.Like this, in order to solve debugger client and the contradiction of platform on file layout is supported, still need amendment debugger client, and often revise debugger and need a large amount of manpowers and time.
In sum, off-line debugging constantly revises debugger client to realize off-line debugging due to needs, and the difficulty causing realizing off-line analysis is comparatively large, cost is higher, the time is long.In addition, the debugging acid of on-line debugging and off-line debugging needs to develop respectively, there is the problem of overlapping development.
Summary of the invention
Embodiments provide a kind of adjustment method of embedded system, debugging conversion equipment and system, for increasing the usable range of on-line debugging instrument, shorten the development time of off-line debugging acid, reduce cost of development.
The embodiment of the present invention provides a kind of adjustment method of embedded system on the one hand, comprising:
Obtain the transformation rule of on-line debugging order to off-line debug command of customization;
After the source code receiving on-line debugging order, according to described transformation rule, the source code of described on-line debugging order is converted to the code supporting off-line debugging;
The code of described support off-line debugging is sent to Target Board.
In conjunction with implementation on the one hand, in the first optional implementation, the described source code by described on-line debugging order converts the code supporting off-line debugging to, sends to Target Board to comprise the code of described support off-line debugging:
The source code of described on-line debugging order is converted to the source code of off-line debug command; By the off-line order source code that obtains and current debugger client, carry out secondary compiling and generate the debugger client supporting off-line debugging, the debugger client of described support off-line debugging is sent to Target Board; Or,
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 the first optional implementation, in the optional implementation of the second, the source code that the described source code by described on-line debugging order converts off-line debug command to comprises:
Compiler is used the source code of described on-line debugging order to be converted to the source code of off-line order; Or, 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 the optional implementation of the second, in the third optional implementation, the source code that the source code of described on-line debugging order converts off-line order to comprises by described use compiler:
Read in the source code of described on-line debugging order, carry out the rule match of character string according to described transformation rule, if the match is successful, then call conversion process interface and generate the compiler morphology that can identify or syntactic units, the source code of then output off-line debug command.
In conjunction with on the one hand, the first, the second 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, internal memory distribution rule;
Described symbol table information transformation rule is: the address mapping information of on-line debugging order business related symbol or globak symbol is transformed into the rule of the symbolic information that in-circuit debugger can identify;
Described register and call stack rule are: general-purpose register number, Function return addresses, 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 of distribution.
The embodiment of the present invention two aspect provides a kind of debugging conversion equipment of embedded system, comprising:
Rule unit, for the transformation rule of the on-line debugging order to off-line debug command that obtain customization;
Source code receiving element, for receiving the source code of online debug command;
Converting unit, for after described source code receiving element receives the source code of on-line debugging order, the transformation rule got according to described Rule unit, converts the code supporting off-line debugging to by the source code of described on-line debugging order;
Transmitting element, the code for the support off-line debugging described converting unit obtained sends to Target Board.
In conjunction with the implementation of two aspects, in the first optional implementation, described converting unit, specifically for converting the source code of off-line debug command to by the source code of described on-line debugging order; The off-line order source code obtained and current debugger client are carried out secondary compiling and generate the debugger client supporting off-line debugging; Or, 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 transmitting element, the debugger client specifically for the support off-line debugging described converting unit obtained sends to Target Board; Or the dynamic base that described converting unit obtains is sent to Target Board.
In conjunction with the implementation of two aspects, in the optional implementation of the second, described converting unit, converts the source code of off-line order to by the source code of described on-line debugging order specifically for use compiler; Or, 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 the implementation of the second, in the third optional implementation, described converting unit comprises:
Reading unit, for reading in the source code of the on-line debugging order that described source code receiving element receives;
Matching unit, the transformation rule for obtaining according to described Rule unit carries out the rule match of character string;
Source code generation unit, if the match is successful for described matching unit, then calls conversion process interface and generates the compiler morphology that can identify or syntactic units, the source code of then output off-line debug command.
In conjunction with on the one hand, the first, the second or the third optional implementation, in the 4th kind of optional implementation, described Rule unit, the transformation rule of acquisition comprises: at least one item in symbol table information transformation rule, register and call stack rule, debugging output interface transformation rule, internal memory distribution rule;
Described symbol table information transformation rule is: the address mapping information of on-line debugging order business related symbol or globak symbol is transformed into the rule of the symbolic information that in-circuit debugger can identify;
Described register and call stack rule are: general-purpose register number, Function return addresses, 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 of distribution.
The embodiment of the present invention three aspect provides a kind of debug system of embedded system, comprises, and debugger, Target Board, also comprise: the debugging conversion equipment of any one that the embodiment of the present invention provides;
Described debugging conversion equipment receives the source code of online debug command from the client of described debugger, and will support that the service end of described Target Board exported to by the code of off-line debugging.
As can be seen from the above technical solutions, the embodiment of the present invention has the following advantages: by the conversion of code on-line debugging order being carried out debugging from the source code of on-line debugging order to off-line, realize the off-line debugging of on-line debugging order, the on-line debugging of built-in system software and the overlapping development problem of off-line debugging can be solved, avoid realizing off-line debugging to different platforms, or when identical platform being realized to the off-line debugging of different editions, all need to revise the problem of debugger client, therefore, the usable range of online debugging acid can be increased, shorten the development time of off-line debugging acid, reduce cost of development.
Embodiment
In order to make the object, technical solutions and advantages of the present invention clearly, below in conjunction with accompanying drawing, the present invention is described in further detail, and obviously, described embodiment is only a part of embodiment of the present invention, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making other embodiments all obtained under creative work prerequisite, belong to the scope of protection of the invention.
Embodiments provide a kind of adjustment method of embedded system, as shown in Figure 1, comprising:
101: the transformation rule of on-line debugging order to off-line debug command obtaining customization;
Above-mentioned on-line debugging order is to the transformation rule of off-line debug command, can be to set up arbitrarily the rule of online debug command to off-line debug command corresponding relation, transformation rule can increase according to actual needs or reduce, the concrete form embodiment of the present invention gives following citing: alternatively, and 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, internal memory distribution rule; Above-mentioned symbol table information transformation rule is: the address mapping information of on-line debugging order business related symbol or globak symbol is transformed into the rule of the symbolic information that in-circuit debugger can identify; Above-mentioned register and call stack rule are: general-purpose register number, Function return addresses, 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 of distribution.It should be noted that, the rule of code conversion can have many types, and above citing should not be construed as the restriction to the embodiment of the present invention.
102: after the source code receiving on-line debugging order, according to above-mentioned transformation rule, the source code of above-mentioned on-line debugging order is converted to the code supporting off-line debugging;
Alternatively, the embodiment of the present invention gives the scheme that two kinds are optionally supported the code of off-line debugging, as follows: the above-mentioned source code by above-mentioned on-line debugging order converts to supports that the code of off-line debugging comprises: the source code source code of above-mentioned on-line debugging order being converted to off-line debug command; By the off-line order source code that obtains and current debugger client, carry out secondary compiling and generate the debugger client supporting off-line debugging; Or, the source code of above-mentioned on-line debugging order is converted to the code of off-line debug command and is linked as dynamic base.
Alternatively, the embodiment of the present invention gives two kinds of on-line debugging orders to the source code of off-line debug command to the conversion implementation of source code, particularly: the source code that the above-mentioned source code by above-mentioned on-line debugging order converts 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; Or, 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 present invention gives and uses compiler to realize the specific implementation of source code to the conversion of source code, as follows: the source code that the source code of above-mentioned on-line debugging order converts off-line order to comprises by above-mentioned use compiler: the source code reading in above-mentioned on-line debugging order, the rule match of character string is carried out according to above-mentioned transformation rule, if the match is successful, then call conversion process interface and generate the compiler morphology that can identify or syntactic units, the source code of then output off-line debug command.
103: the code of above-mentioned support off-line debugging is sent to Target Board.
Above scheme, by the conversion of code that on-line debugging order is carried out debugging from the source code of on-line debugging order to off-line, realize the off-line debugging of on-line debugging order, the on-line debugging of built-in system software and the overlapping development problem of off-line debugging can be solved, avoid realizing off-line debugging to different platforms, or when identical platform being realized to the off-line debugging of different editions, all need to revise the problem of debugger client, therefore, the usable range of online debugging acid can be increased, shorten the development time of off-line debugging acid, reduce cost of development.
Alternatively, corresponding to two kinds of optional schemes supporting the code of off-line debugging of preceding embodiment, the above-mentioned code by above-mentioned support off-line debugging sends to Target Board to comprise: the debugger client of above-mentioned support off-line debugging is sent to Target Board; Or, above-mentioned dynamic base is sent to Target Board.
Following examples form with regard to structure respectively, debug networking, source code changes and the scheme of angle to above embodiment of example illustrates in more detail.
One, structure composition
Refer to and Figure 2 shows that: by source-to-source translation, generate the modular structure schematic diagram of off-line order, wherein the direction of arrow is data flow.
For the online of embedded system development and off-line debugger can use C as programming language in this example.On-line debugging order source code (mainly .c and .h file) is as the input source of off-line command converter.
Off-line command converter mainly contains three parts: symbol resolution module, dump file parsing module and source-to-source translation module.
Symbol resolution module obtains definition and the address mapping table of globak symbol from input source, and the denotational description information relevant to business, after carrying out symbol resolution and processing, outputs to source-to-source translation module.
Another input of source-to-source translation module is from dump file parsing module, dump file parsing module mainly completes the analysis and treament to off-line files register and call stack rule, this part ISA(IndustrialStandardArchitecture that is usual and embedded system, industrial standard architecture bus) strong correlation.
Just can be completed the output of last off-line debug command source code (mainly .c and .h file) by the inner rule defined after source-to-source translation module gets the information of needs.Off-line debugger now has been provided with the business related symbol table information and address information that in-circuit debugger module has, and uses the printing interface of off-line debugger just can obtain product service related information.
Two, networking is debugged
Typical debugger networking schematic diagram as shown in Figure 3,
Under on-line debugging scene, be positioned at PC(personalcomputer, personal computer) the debugger client of holding and the debugging services end that is positioned on Target Board (Board) by ETH(Ethernet, network interface) or the passage such as serial ports communicate.Wherein also include IDE(IntegratedDevelopmentEnvironment in PC side, Integrated Development Environment), application program, system and internal memory/register is also included in Board side.
Under off-line debugging scenarios, register/memory information, operation system information or product business information required for debugger client is obtained from the dump file (CoreFileonPC) of PC by file I/O.
Three, source code conversion
Referring to Fig. 4 is: online order converts the schematic flow sheet of off-line order to.
401: formulate the transformation rule that on-line debugging order smooths to off-line debug command;
On-line debugging order has the rule of complete set to the conversion of off-line order.The customization of rule mainly can comprise following a few part: symbol table information transformation rule, main formulates the rule address mapping information of on-line debugging order business related symbol or globak symbol being transformed into the symbolic information that in-circuit debugger can identify.Register and call stack rule, comprise general-purpose register number, Function return addresses, the register configuration such as stack pointer and PC pointer, and function call stack information etc.Debugging output interface transformation rule, formulates and the command interface of on-line debugging is transformed into off-line debug command interface.Internal memory distribution rule, determines the size and distribution etc. of privately owned internal memory or shared drive.According to the demand of practical business, can 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 be: the source code reading in online debug command, carries out the rule match of character string according to the transformation rule of above-mentioned formulation.If the match is successful, then call conversion process interface and generate the compiler morphology that can identify or syntactic units, then exported the source code of last off-line debug command by compiler.
403: the source code of the off-line debugging had nothing to do together with framework and conversion by the source code of the off-line debug command that will generate in 402, is compiled in and can generates new off-line debugger client together.
Above protocol step 402 and 403 all can adopt other modes to replace, specific as follows:
In above-mentioned schematic flow sheet 4 402 is have employed the source code that the source code of on-line debugging order is converted to off-line debug command by source code conversion compiler.Replacement scheme can not rely on compiler, realizes separately the conversion client instrument that the source code of on-line debugging order is converted to the source code of off-line debug command by.That is crossover tool can depart from compiler, and client utility possesses process of analysis rule map, generates the function of final source code.
In schematic flow sheet 4 402 another kind of replacement schemes are by compiler, and the code (mainly .c and .h file) of the off-line order converted is linked into a dynamic base (.dll or .so form).Secondary compiling so in 403 just can be omitted, and the debugger client of off-line only needs the dynamic base of generation in dynamic load 402 just can complete corresponding debug function.
Four, example
Below a kind of enforcement scene:
Refer to and Figure 5 shows that a source-to-source translation process instance, this example is to inquire about the CPU(CentralProcessingUnit of current system, central processing unit) load factor is example, Fig. 5 adopts C language to write, the related specifications can write with reference to C language, wherein left side one source code that is classified as on-line debugging order, the source code of corresponding with it off-line debug command that what right side arrow was pointed to is, the source code of on-line debugging order is converted to the process of the source code of off-line debug command by this example.Mainly be divided into three steps:
1, the global variable in this order realization is identified.This is the global variable that a business is relevant, is first to have the transformation rule identifying this service symbol.Rule is very simple, identifies the character string (namely in Fig. 5, the boldface letter content gone up most in a dotted line frame in large frame above) in quotation marks.
Off-line command converter constantly reads in input file (i.e. side code on the left of Fig. 5), when recognizing DSP_LkAddr key word, (this is the calling interface of a service inquiry symbolic address, when Rulemaking, can this interface interchange be configured in rule, coupling for character string), off-line command converter matches this key word character string bracketed with double quotation marks below, is exactly gstruCpuLoad in this example.Subsidiary implicit transformation rule is Member call original structure body Member call being converted to recognized character string, as struCpuLoad.uwCurLoad---->gstruCpuLoad.uwC urLoad, this transformation result is using the input as function call translation interface below.Conversion corresponding relation shown in arrow as shown in Figure 5.
2, obtain the function call of global variable value, replace to the function call in off-line debug client end.
As in Fig. 5, convert the calling interface DSP_CommRead of online query business address of variable to corresponding off-line calling interface getSymAddrSize, struCpuLoad.uwCurLoad---->gstruCpuLoad.uwC urLoad transformation result is above imported into as interface parameters simultaneously.
3, the function call returning results output is ordered to replace to the function call of off-line debug client end.
After the interface conversion that globak symbol and the acquisition overall situation are measured completes, just can realize the conversion of final step platform printout interface, this converted the function achieving last debug results output switching.On-line debugging interface LBB_DSP_Printf in such as this example is transformed into off-line printing interface printf.
Adopt above scheme, because the on-line debugging of built-in system software and off-line debugging are applied to different scenes, and the debud mode that is all absolutely necessary.The embodiment of the present invention realizes the off-line debugging of on-line debugging order, the on-line debugging of built-in system software and the overlapping development problem of off-line debugging can be solved, by the conversion of code that on-line debugging order is carried out debugging from the source code of on-line debugging order to off-line, convert the off-line debug command that can use on PC to, and using symbol resolution power and energy to become address and length the product business information related in order, namely off-line order can obtain system related information by the corresponding memory address interval of inquiry.The off-line debugging realizing on-line debugging order can be avoided realizing off-line debugging to different platforms, or when identical platform being realized to the off-line debugging of different editions, all need to revise the problem of debugger client, therefore, the inventive method can increase the usable range of online debugging acid, shorten the development time of off-line debugging acid, reduce cost of development.
The embodiment of the present invention additionally provides a kind of debugging conversion equipment of embedded system, as shown in Figure 6, comprising:
Rule unit 601, for the transformation rule of the on-line debugging order to off-line debug command that obtain customization;
Source code receiving element 602, for receiving the source code of online debug command;
Converting unit 603, for after above-mentioned source code receiving element 602 receives the source code of on-line debugging order, the transformation rule got according to above-mentioned Rule unit 601, converts the code supporting off-line debugging to by the source code of above-mentioned on-line debugging order;
Transmitting element 604, the code for the support off-line debugging above-mentioned converting unit 603 obtained sends to Target Board.
Above scheme, by the conversion of code that on-line debugging order is carried out debugging from the source code of on-line debugging order to off-line, realize the off-line debugging of on-line debugging order, the on-line debugging of built-in system software and the overlapping development problem of off-line debugging can be solved, avoid realizing off-line debugging to different platforms, or when identical platform being realized to the off-line debugging of different editions, all need to revise the problem of debugger client, therefore, the usable range of online debugging acid can be increased, shorten the development time of off-line debugging acid, reduce cost of development.
Alternatively, above-mentioned converting unit 603, specifically for converting the source code of off-line debug command to by the source code of above-mentioned on-line debugging order; The off-line order source code obtained and current debugger client are carried out secondary compiling and generate the debugger client supporting off-line debugging; Or, the source code of above-mentioned on-line debugging order is converted to the code of off-line debug command and is linked as dynamic base;
Above-mentioned transmitting element 604, the debugger client specifically for the support off-line debugging above-mentioned converting unit 603 obtained sends to Target Board; Or the dynamic base that above-mentioned converting unit 603 obtains is sent to Target Board.
Alternatively, above-mentioned converting unit 603, converts the source code of off-line order to by the source code of above-mentioned on-line debugging order specifically for use compiler; Or, 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, for reading in the source code of the on-line debugging order that above-mentioned source code receiving element 602 receives;
Matching unit 702, the transformation rule for obtaining according to above-mentioned Rule unit 601 carries out the rule match of character string;
Source code generation unit 704, if the match is successful for above-mentioned matching unit 702, then calls conversion process interface and generates the compiler morphology that can identify or syntactic units, the source code of then output off-line debug command.
Alternatively, above-mentioned Rule unit 601, the transformation rule of acquisition comprises: at least one item in symbol table information transformation rule, register and call stack rule, debugging output interface transformation rule, internal memory distribution rule;
Above-mentioned symbol table information transformation rule is: the address mapping information of on-line debugging order business related symbol or globak symbol is transformed into the rule of the symbolic information that in-circuit debugger can identify;
Above-mentioned register and call stack rule are: general-purpose register number, Function return addresses, 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 of distribution.
The embodiment of the present invention additionally provides a kind of debug system of embedded system, as shown in Figure 8, comprises, and debugger 801, Target Board 803, also comprise: any one debugging conversion equipment 802 that the embodiment of the present 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 that the service end of above-mentioned Target Board 803 exported to by the code of off-line debugging.
It should be noted that in above-mentioned debugging conversion equipment embodiment, included unit is carry out dividing according to function logic, but is not limited to above-mentioned division, as long as can realize corresponding function; 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 realized in above-mentioned each embodiment of the method is that the hardware that can carry out instruction relevant by program completes, corresponding program can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium mentioned can be ROM (read-only memory), disk or CD etc.
These are only the present invention's preferably embodiment; 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 present invention discloses, the change 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.