CN108614704A - Code compiling method and device - Google Patents

Code compiling method and device Download PDF

Info

Publication number
CN108614704A
CN108614704A CN201710031295.2A CN201710031295A CN108614704A CN 108614704 A CN108614704 A CN 108614704A CN 201710031295 A CN201710031295 A CN 201710031295A CN 108614704 A CN108614704 A CN 108614704A
Authority
CN
China
Prior art keywords
code
debugging
program
source program
debugging code
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201710031295.2A
Other languages
Chinese (zh)
Other versions
CN108614704B (en
Inventor
周红轮
侯坤明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201710031295.2A priority Critical patent/CN108614704B/en
Publication of CN108614704A publication Critical patent/CN108614704A/en
Application granted granted Critical
Publication of CN108614704B publication Critical patent/CN108614704B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3624Software debugging by performing operations on the source code, e.g. via a compiler

Abstract

The present invention relates to a kind of code compiling methods, belong to technical field of software development.The method includes:The compiling received for source program instructs;If the target program that the compiling instruction instruction compiling obtains obtains debugging code setting rule for debugging;According to the debugging code, rule setting debugging code is set;The source program to being provided with the debugging code is compiled.This method pre-sets debugging code setting rule by developer, when developer needs to debug source program, debugging code is set automatically according to debugging code setting rule in the code of source program and is compiled, when developer needs to source program change and debug repeatedly, do not need developer's each round debugging before in source program manual setting debugging code, greatly simplify the debugging code setting steps of developer, reduce debug time, improves the debugging efficiency of software program.

Description

Code compiling method and device
Technical field
The present invention relates to technical field of software development, more particularly to a kind of code compiling method and device.
Background technology
Code compilation is by the code translation of the source program of high level language into the identifiable binary language of computer Code process.In the development process of one software program, it usually needs through excessive wheel modification, compiling and debugging.For example, opening After hair personnel write the source program for completing software program, first run modification, compiling and debugging are carried out to source program, first run debugging passes through Afterwards, tester will be submitted to by the source program of debugging to test, tester feeds back to out the problem of test discovery Hair personnel carry out the second wheel modification, compiling and debugging to source program by developer, and after the second wheel debugging passes through, will lead to The source program for crossing debugging is submitted to tester and is tested again, repeatedly with this, until passing through the test of tester.
It in the prior art, can be as follows to the modification of each round of software program, compiling and debugging process:Developer exists Debugging code is manually set in source program, obtains the source program for debugging, and by compiler to the source program for debugging It is compiled, obtains the target program for debugging, developer is by debugger operational objective program, and according to target program Operating condition check target program whether there is mistake, if there are mistakes for target program, developer is to for debugging The code of source program is modified, and to being debugged after the code compilation of the modified source program for debugging, until compiling Mistake is not present in the trial operation for translating the target program of acquisition, and epicycle modification and debugging terminate.Developer is last by epicycle later Debugging code in the code of the source program of modification is deleted, and is compiled, is obtained to the code of the source program after deletion debugging code It obtains and tests the target program used for tester.
In each round of software program is changed and debugged, developer is required for setting in the source program of software program Debugging code is set, and the process that debugging code is manually arranged needs to consume developer's a large amount of time, influences the exploitation of software Efficiency.
Invention content
In order to solve in each round modification and debugging to software program in the prior art, developer is required in software Debugging code is set in the source program of program, to consume developer's a large amount of time, influences asking for the development efficiency of software Topic, an embodiment of the present invention provides a kind of code compiling method and device, technical solution is as follows:
In a first aspect, a kind of code compiling method is provided, the method includes:
The compiling received for source program instructs, and whether the target program that the compiling instruction instruction compiling obtains is for adjusting Examination;
If the target program for compiling instruction instruction compiling acquisition is used to debug, debugging code setting rule is obtained, Include object code and debugging code in the debugging code setting rule;
Rule is set according to the debugging code, the object code setting debugging generation for including in the corresponding source program Code;
The source program to being provided with the debugging code is compiled, and obtains target program.
Second aspect, provides a kind of code compilation device, and described device includes:
Command reception module, for receiving the compiling instruction for source program, the compiling instruction instruction compiling acquisition Whether target program is for debugging;
Rule acquisition module, if the target program for the compiling instruction instruction compiling acquisition is obtained for debugging Debugging code setting rule includes object code and debugging code during the debugging code setting is regular;
Code setup module, for rule to be arranged according to the debugging code, include in the corresponding source program is described The debugging code is arranged in object code;
Collector obtains target program for being compiled to the source program for being provided with the debugging code.
Technical solution provided in an embodiment of the present invention can include the following benefits:
Debugging code setting rule is pre-set by developer, when developer needs to debug source program When, debugging code is set automatically according to debugging code setting rule in the code of source program and is compiled, when developer needs To source program carry out repeatedly change and debug when, do not need developer's each round debugging before in source program manual setting tune Code is tried, the debugging code setting steps of developer is greatly simplified, reduces debug time, improve the tune of software program Try efficiency.
It should be understood that above general description and following detailed description is only exemplary and explanatory, not It can the limitation present invention.
Description of the drawings
The drawings herein are incorporated into the specification and forms part of this specification, and shows the implementation for meeting the present invention Example, and be used to explain the principle of the present invention together with specification.
Fig. 1 is the implementation process schematic diagram of scheme shown in the embodiment of the present invention;
Fig. 2 is a kind of flow chart of code compiling method shown according to an exemplary embodiment;
Fig. 3 is a kind of setting interface schematic diagram that embodiment illustrated in fig. 2 is related to;
Fig. 4 is a kind of debugging code compiling schematic diagram that embodiment illustrated in fig. 2 is related to;
Fig. 5 is another debugging code compiling schematic diagram that embodiment illustrated in fig. 2 is related to;
Fig. 6 is a kind of flow chart of code compiling method shown according to an exemplary embodiment;
Fig. 7 is a kind of debugflag's schematic diagram that embodiment illustrated in fig. 6 is related to;
Fig. 8 is the implementation process schematic diagram for the scheme that embodiment illustrated in fig. 6 is related to;
Fig. 9 is a kind of block diagram of code compilation device shown according to an exemplary embodiment;
Figure 10 is the structural schematic diagram of the electronic equipment provided according to an exemplary embodiment.
Specific implementation mode
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment Described in embodiment do not represent and the consistent all embodiments of the present invention.On the contrary, they be only with it is such as appended The example of the consistent device and method of some aspects being described in detail in claims, of the invention.
Scheme shown in the present invention can be applied to be equipped in the electronic equipment of Software Development Tools.For example, the electronics Equipment can be the development equipments such as PC, laptop or work station.
In the scheme shown in the present invention, developer by Software Development Tools write complete some source program after, It may be based on whether that the target program after being compiled to source program is debugged to send out different compiling instructions, if software development work Have the compiling instruction instruction received to need to debug target program, then Software Development Tools can be in the code of source program In debugging code is set automatically, and the code of the source program to being provided with debugging code is compiled, so that developer is to compiling The target program for translating acquisition is debugged;Conversely, if the compiling instruction instruction that Software Development Tools receives is not to target program It is debugged, then Software Development Tools can not change the code of source program, directly be compiled.
Specifically, referring to FIG. 1, it illustrates the implementation process schematic diagrames of scheme shown in the present invention.As shown in Figure 1, opening Hair personnel can write or a series of debugging code setting rule is arranged in advance, and developer writes or changed source program After code, when being compiled to source program, Software Development Tools obtains compiling instruction, according to compiling instruction selection to source program Execute general compiled or debugging compiling.When executing general compiled, Software Development Tools is directly by the code of source program by advanced Language translation obtains object code 1 at binary language;When executing debugging compiling, Software Development Tools can obtain in advance The debugging code setting rule of setting, and debugging code is set in the code of source program according to debugging code setting rule, and The code of the source program of debugging code will be provided with by high-level language translation into binary language, obtain object code 2.
Scheme shown in the present invention can be pre-set debugging code setting rule, when needing to source by developer When program is debugged, debugging code is set automatically according to debugging code setting rule in the code of source program and is compiled, when When developer needs to source program change and debug repeatedly, do not need before developer's each round is debugged in source program Middle manual setting debugging code greatly simplifies the debugging code setting steps of developer, reduces debug time, improves The debugging efficiency of software program.
Fig. 2 is a kind of flow chart of code compiling method shown according to an exemplary embodiment, and this method can be used for Operation has in the electronic equipment of Software Development Tools.As shown in Fig. 2, the code compiling method may include the following steps:
Step 201, the debugging code setting rule of developer's setting is received.
Scheme shown in the embodiment of the present invention can be realized that the Software Development Tools can be similar by Software Development Tools In NPM (package manager of node package manager, node).Developer can the control by way of command prompt The startup and operation of Software Development Tools processed.
Wherein, debugging code can be divided into two kinds, one is the debugging code being directly inserted into the code of source program, than Such as it is used to show the alert sentences of the alert box with a specified message and an OK button, or for breakpoint to be arranged Debugger sentences etc., such debugging code are not usually required to change the code in source program, it is only necessary in source program The designated position of object code in code is inserted into;Another kind is that the object code in the code needed source program carries out The debugging code of displacement, for example, there are some parameter, such as a file address, this document addresses in the code of source program It is the address used in formal publication environment, and debugging process usually carries out offline, it can not be to this article in program debugging Part address accesses.In order to debugging when normally execute, need by this document address replace with one can debugging when visit The address asked, then the file address in the code of the source program is object code, and be used to replace can visit in debugging The address asked is then debugging code.In embodiments of the present invention, can include object code in above-mentioned debugging code setting rule And debugging code, and the set-up mode of debugging code may include being inserted into and replacing.
Optionally, above-mentioned debugging code setting rule can be arranged in developer in the configuration file of Software Development Tools It then, can be in the Software Development Tools for example, developer using Software Development Tools during developing a source program Configuration file in write manually debugging code setting rule and preserve.
Optionally, debugging code setting rule is write manually in the configuration file of Software Development Tools as developer When, debugging code setting rule can be write by way of regular expression.
For example, the debugging code setting rule when developer's setting is to be inserted into debugging generation in the designated position of object code When code, which is arranged rule can be as follows:
Wherein, above-mentioned designated position can be the position pre-set, for example, the designated position can be object code Before, alternatively, after the designated position can also be object code.
Alternatively, when the debugging code setting rule of developer's setting is that object code is replaced with debugging code, it should Rule is arranged in debugging code can be as follows:
Optionally, Software Development Tools can also provide the setting interface of debugging code setting rule, can by developer Above-mentioned debugging code setting rule to be arranged in the setting interface, Software Development Tools adds developer in configuration file The debugging code setting rule of setting.
For example, referring to FIG. 3, it illustrates the present embodiments relate to a kind of setting interface schematic diagram, wherein exploitation Personnel can start setting interface 30 by command prompt, alternatively, can also provide setting in the interface of Software Development Tools Entrance, developer open the setting interface 30 by clicking the inlet porting.As shown in figure 3, can be in the setting interface 30 Including 3 setting options or input frame, respectively set-up mode option 301, object code input frame 302 and debugging code input Frame 303.Wherein, developer can select " insertion " or " replacement " by set-up mode option 301, and defeated in object code Enter and input object code in frame 302, and input debugging code in debugging code input frame 303, developer clicks setting circle After confirming button 304 in face 30, Software Development Tools is that the content for being arranged or inputting according to developer automatically generates tune Code setting rule is tried, and is preserved into the configuration file of Software Development Tools.
Optionally, Software Development Tools can also show that regulation management interface, developer pass through the rule to developer Then administration interface sends out the management instruction to the debugging code setting rule preserved, for example deletes debugging code setting rule, Or modification debugging code setting rule etc..
It is each during developer carries out more wheel modifications, compiling and debugging to the code of the same software program The debugging code overwhelming majority being arranged in source program when wheel modification and debugging is identical, therefore, shown in the embodiment of the present invention Scheme in, when developer debugs some software program, it is only necessary to first time debug before set debugging code setting Rule, it is follow-up to take turns in debugging process if necessary to when doing small adjustment to debugging code, it is only necessary in the debugging generation set more It modifies in code setting rule, complete debugging code setting rule need not be all set when each round is changed and is debugged Then.
Step 202, the compiling received for source program instructs.
Wherein, whether the target program that compiling instruction instruction compiling obtains is for debugging.
In the embodiment of the present invention, developer can be sent to Software Development Tools by way of command prompt and be compiled Instruction.
For example, after developer writes or has changed a source program, if it is desired to the source program is debugged, it can be with The compiling instruction for sending out debugging compiling to Software Development Tools by command prompt " qbt b--dev ", if developer is not desired to The source program is debugged, then can send out the volume of general compiled to Software Development Tools by command prompt " qbt b " Translate instruction.
Step 203, if the target program that compiling instruction instruction compiling obtains is used to debug, debugging code setting is obtained Rule.
When the command prompt of developer's input is " qbt b--dev ", Software Development Tools can be determined to the source Program is compiled the target program of acquisition for debugging, at this point, Software Development Tools can be obtained from configuration file it is above-mentioned Debugging code setting rule.
Optionally, Software Development Tools can obtain the journey of the source program first when obtaining debugging code setting rule Sequence name, and debugging code setting rule corresponding with the program name is inquired from pre-set configuration file.
In practical applications, developer is possible to that multiple source programs can be developed simultaneously, and may in multiple source program Identical object code is existed simultaneously, and when being debugged to multiple source programs, to the same target in different source programs The processing mode of code may also be different.For example, in source program 1, need the object code replacing with debugging code, and In source program 2, it may be necessary to be inserted into debugging code in the designated position of the object code, in source program 3, and may not be needed Any processing is done to the object code, it, may if rule all is arranged using identical debugging code to all source programs It can cause debugging code that mistake is set.
In order to avoid said circumstances, in embodiments of the present invention, developer, can when debugging code setting rule is arranged To configure which source program is debugging code setting rule come into force to.Specifically, developer is in setting, some debugging code is set When setting rule, the program name of the corresponding source program of debugging code setting rule can be configured, for example, when developer is soft When writing debugging code setting rule in the configuration file of part developing instrument manually, it is opposite which can be arranged rule The program name for the source program answered directly is programmed in the configuration file, and regular phase is arranged by predetermined format and the debugging code Association.It can be with alternatively, when developer is when being arranged above-mentioned debugging code setting rule during interface is arranged, in the setting interface Including a program name setting options, developer can select or input the debugging code by program name setting route selection and set The corresponding program name of rule is set, debugging code setting rule and being associated between the program name are established by Software Development Tools System.When obtaining debugging code setting rule, Software Development Tools can obtain the program name of current source program to be compiled, and Corresponding debugging code setting rule is inquired according to the program name got.
Step 204, debugging code is arranged in the source program according to debugging code setting rule.
In embodiments of the present invention, it in debugging code setting rule can include object code and debugging code, software Rule can be arranged in developing instrument according to debugging code, the object code setting debugging code for including in corresponding source program.
Optionally, Software Development Tools can match the object code in the source program;If being successfully matched to the target The object code is then replaced with the debugging code by code, alternatively, corresponding be inserted into the debugging in the designated position of the object code Code.
When debugging code is arranged, Software Development Tools can match object code in the code of source program, if at Work(is matched to object code, then when the set-up mode of debugging code setting rule is to be inserted into, the target in the source program The specified location of code is inserted into debugging code, when the set-up mode of debugging code setting rule is to replace, by the target Code replaces with debugging code.
Optionally, debugging code is being arranged in the source program according to debugging code setting rule in Software Development Tools When, debugging code setting daily record can also be exported, to indicate specific installation position and setting result.For example, software development work The setting daily record of tool can be as follows:
Wherein, above-mentioned setting daily record indicates that Software Development Tools will be in the 62nd row of file app.xxcbd.index.js Object code 1 replaces with debugging code 1, and the object code 2 in the 81st row of file app.yycbd.index.js is replaced with Debugging code 2, and the object code 3 in the 143rd row of file app.yycbd.index.js is replaced with into debugging code 3.
Step 205, the source program for being provided with the debugging code is compiled, obtains target program.
Software Development Tools can at computer by high-level language translation by the code provided with the source program after debugging code The binary language of execution.
In the scheme shown in the present invention, Software Development Tools can complete above-mentioned steps 204 and then execution executing Above-mentioned steps 205.For example, Software Development Tools can match object code in source program, the object code that will match to replaces It is changed to debugging code, obtains the complete code of the source program provided with debugging code, then since the first row of the complete code, The complete code of the source program for being provided with debugging code is compiled line by line.
Optionally, Software Development Tools, which can also synchronize, executes step 204 and step 205.For example, Software Development Tools pair The code of source program is compiled line by line, while object code is matched in the code to be compiled of source program, and is being compiled into When object code, according to the set-up mode corresponding to debugging code setting rule, corresponding object code is inserted into debugging code, or Object code is replaced with debugging code, and is compiled to the debugging code for being inserted into or replacing by person.
Specifically, please referring to Fig.4 and Fig. 5, wherein Fig. 4 show the present embodiments relate to a kind of debugging code volume Translate schematic diagram, Fig. 5 show the present embodiments relate to another debugging code compile schematic diagram.In figures 4 and 5, Src.js is the code file (high-level language) of source program, and build.js is the code file (binary language) of target program. In Fig. 4, the set-up mode corresponding to debugging code setting rule is to replace, when executing debugging compiling, Software Development Tools When the object code being compiled into src.js, after object code is replaced with debugging code, debugging code is compiled, is compiled It include debugging code in build.js afterwards.In Figure 5, the set-up mode corresponding to debugging code setting rule is to be inserted into, When executing debugging compiling, when Software Development Tools is compiled into the object code in src.js, debugging is inserted into before object code Code, and the object code after the debugging code and debugging code of insertion is compiled, in the build.js after compiling Including debugging code and object code.
Step 206, if the target program that compiling instruction instruction is compiled the source program acquisition is not used in debugging, The source program is compiled, target program is obtained.
When the command prompt of developer's input is " qbt b ", Software Development Tools can be determined to the source program The target program for being compiled acquisition is not used in debugging, at this point, Software Development Tools can directly by the code of the source program by The binary language that high-level language translation can perform at computer.
In conclusion method shown in the embodiment of the present invention, debugging code setting rule is pre-set by developer, When developer needs to debug source program, it is arranged in the code of source program automatically according to debugging code setting rule Debugging code simultaneously compiles, and when developer needs to source program change and debug repeatedly, it is each not need developer Wheel debugging before in source program manual setting debugging code, greatly simplify the debugging code setting steps of developer, Reduce debug time, improves the debugging efficiency of software program.
Due to including above-mentioned debugging code in the target program for debugging, and debugging code is possible to meeting to target The normal operation of program impacts.For example, by taking the set-up mode of above-mentioned debugging code setting rule is to replace as an example, if source journey Object code in the code of sequence is the file address used in formal publication environment, and when debugging code is debugged accesses Address, then object code is replaced with debugging code and compile after, if directly will compiling obtain target program accidentally be packaged or It accidentally issues, then target program is continued to test based on formal publication environment in tester, or the target is used in user When program, the corresponding address of the debugging code possibly can not be accessed, and be malfunctioned so as to cause program.In order to avoid the above situation, In the scheme shown in the present invention, when target program is for when debugging, being packaged or being issued to the target program if receiving Instruction, then Software Development Tools prompt can be sent out to developer, specifically refer to embodiment shown in following FIG. 6.
Fig. 6 is a kind of flow chart of code compiling method shown according to an exemplary embodiment, and this method can be used for Operation has in the electronic equipment of Software Development Tools.As shown in fig. 6, the code compiling method may include the following steps:
Step 601, the debugging code setting rule of developer's setting is received.
Step 602, the compiling received for source program instructs.
Step 603, it if the target program that compiling instruction instruction is compiled the source program acquisition is used to debug, obtains Take debugging code setting rule.
Step 604, debugging code is arranged in the source program according to debugging code setting rule.
Step 605, it is compiled to the source program after the debugging code is arranged, obtains target program.
Step 606, when receiving the instruction that the target program is packaged or is issued, prompting message, the prompt are shown Message is for prompting the target program for debugging.
Optionally, in the scheme shown in the present invention, to being arranged before the source program after the debugging code is compiled, Software Development Tools can be in the source program, and debugflag is arranged in the corresponding debugging code, this to the debugging code is arranged When source program afterwards is compiled, the code of the source program of setting debugging code and the debugflag can be compiled; When receiving to the target program is packaged or is issued instruction, Software Development Tools, which can open up to detect in the target program, is No includes the debugflag, if it includes the debugflag that testing result, which is in the target program, shows the prompting message.
Optionally, Software Development Tools can also determine location information of the debugflag in the target program, open up When showing the prompting message, the prompting message including the location information can be shown.
Optionally, above-mentioned debugflag can be the code annotation of a specified content.For example, referring to FIG. 7, it shows The present embodiments relate to a kind of debugflag's schematic diagram, wherein build.js is the target program that debugging compiling obtains, In build.js, the position of corresponding debugging code is provided with code annotation " // where there is debugging codes ", the code annotation " // where there is debugging codes " is debugflag.
Optionally, scheme shown in the embodiment of the present invention can also manually add user the target program of debugging code It is prompted.Specifically, when writing or changing the source program of software program, debugging can be manually arranged in user in source program Code, meanwhile, debugflag is arranged in corresponding debugging code, and Software Development Tools is to being manually provided with debugging code and debugflag Source program be compiled after, receive packing or publication compiling after target program instruction when, detect in target program Including debugflag, then can show prompting message to developer, to prompt in developer's target program comprising debugging Code.
Step 607, if the target program that compiling instruction instruction is compiled the source program acquisition is not used in debugging, The source program is compiled, target program is obtained.
Through the above scheme, developer is after rule is arranged in setting debugging code, after debugging is pinpointed the problems every time, in source It modifies on the basis of program, is subsequently compiled if it is debugging, then Software Development Tools is arranged according to debugging code and advises automatically Debugging code then is arranged to modified source program and is compiled, after debugging several times, if developer confirms that object code is logical Debugging is crossed, then in the code after being packaged or issuing the compiling of the source program, it is only necessary to refer to by the compiling of general compiled Show that Software Development Tools is directly compiled the code of the source program of Last modification, since developer does not need Debugging code is directly set in source program, and in packing or publication, also there is no need to developers is deleted again through debugging Debugging code in source program, further shortens debug time, improves the debugging efficiency of software program.
In addition, in the embodiment of the present invention, developer only needs to write the source program not comprising debugging code, is changing When, it also only needs to modify to the source program not comprising debugging code, be opened subsequently through different compiling command control softwares Source program is compiled as the target program (debugging routine) of debugging hair tool or the target program for being packaged or issuing (formal proceedings), compared with the existing technology in manual debugging code and compile acquisition debugging routine in source program, and by source The mode for obtaining formal proceedings is manually deleted and compiled to debugging code in program, and scheme can realize debugging shown in the present invention Program and formal proceedings are switched fast.
Specifically, referring to FIG. 8, the implementation process schematic diagram for the scheme being related to it illustrates illustrated embodiment of the present invention, As shown in figure 8, developer can write or a series of debugging code setting rule is arranged in advance, developer writes or repaiies After the code for having changed source program, when being compiled to source program, after Software Development Tools gets compiling instruction, according to compiling Instruction selection executes general compiled to source program or debugging compiles.When executing general compiled, Software Development Tools is directly by source The code of program, at binary language, obtains target program 1 by high-level language translation;When executing debugging compiling, software development Tool can obtain pre-set debugging code setting rule, and rule setting debugging code is arranged according to debugging code, together When correspond to debugging code setting debugflag, and by the code provided with the source program after debugging code and debugflag by advanced Language translation obtains target program 2 at binary language.After Software Development Tools executes debugging compiling to source program, exploit person Member sends out target program the instruction of packing or publication, at this point, whether Software Development Tools checks in the target program comprising tune Test-object remembers that, if including debugflag's (i.e. target program 2) in target program, Software Development Tools determines debugflag in target Location information in program, and show prompting message, include to prompt developer's target program to correspond at the location information There is debugging code;If not including debugflag's (i.e. target program 1) in target program, target program is executed and is packaged or issues Operation.
In conclusion method shown in the embodiment of the present invention, debugging code setting rule is pre-set by developer, When developer needs to debug source program, it is arranged in the code of source program automatically according to debugging code setting rule Debugging code simultaneously compiles, and when developer needs to source program change and debug repeatedly, it is each not need developer Wheel debugging before in source program manual setting debugging code, greatly simplify the debugging code setting steps of developer, Reduce debug time, improves the debugging efficiency of software program.
In addition, method shown in the embodiment of the present invention, when target program is used to debug, if receiving to the target program The instruction for being packaged or being issued, then Software Development Tools can show a prompting message, to prompt developer's target Program is the program for debugging, should not be packaged or issue, avoid developer will for the target program of debugging accidentally be packaged or Accidentally issue.
Following is apparatus of the present invention embodiment, can be used for executing the method for the present invention embodiment.For apparatus of the present invention reality Undisclosed details in example is applied, the method for the present invention embodiment is please referred to.
Referring to FIG. 9, a kind of block diagram of code compilation device shown in it illustrates an exemplary embodiment.The code is compiled The all or part of of electronic equipment can be embodied as by way of hardware or soft or hard combination by translating device.The code compilation fills It sets and may include:
Command reception module 901, for receiving the compiling instruction for source program, the compiling instruction instruction compiling obtains Target program whether for debugging;
Rule acquisition module 902, if the target program for the compiling instruction instruction compiling acquisition is obtained for debugging Debugging code setting rule is taken, includes object code and debugging code in the debugging code setting rule;
Code setup module 903, for rule, the institute for including in the corresponding source program to be arranged according to the debugging code It states object code and the debugging code is set;
Collector 904 obtains target journey for being compiled to the source program for being provided with the debugging code Sequence.
Optionally, include object code and the debugging code in the debugging code setting rule, the code is set Module is set, including:
Matching unit, for matching the object code in the source program;
If the object code is replaced with the debugging by setting unit for being successfully matched to the object code Code, alternatively, corresponding be inserted into the debugging code in the designated position of the object code.
Optionally, the rule acquisition module, including:
Program name acquiring unit, the program name for obtaining the source program;
Query unit, for inquiring the debugging generation corresponding with described program name from pre-set configuration file Code setting rule.
Optionally, described device further includes:
Reminding module, for when receiving the instruction that the target program is packaged or is issued, displaying prompt to disappear Breath, the prompting message include debugging code in the target program for prompting.
Optionally, described device further includes:
Mark module, for before the collector is compiled the source program for being provided with the debugging code, Debugflag is arranged in the corresponding debugging code;
The collector, for being compiled to the source program for being provided with the debugflag;
The reminding module, when for receiving the instruction that the target program is packaged or is issued, described in detection Whether include the debugflag in target program, if it includes the debugflag that testing result, which is in the target program, Show the prompting message.
Optionally, described device further includes:
Position determination module, for determining location information of the debugflag in the target program;
The reminding module, for show include the location information the prompting message.
In conclusion device shown in the embodiment of the present invention, debugging code setting rule is pre-set by developer, When developer needs to debug source program, it is arranged in the code of source program automatically according to debugging code setting rule Debugging code simultaneously compiles, and when developer needs to source program change and debug repeatedly, it is each not need developer Wheel debugging before in source program manual setting debugging code, greatly simplify the debugging code setting steps of developer, Reduce debug time, improves the debugging efficiency of software program.
In addition, device shown in the embodiment of the present invention, when target program is used to debug, if receiving to the target program The instruction for being packaged or being issued, then Software Development Tools can show a prompting message, to prompt developer's target Program is the program for debugging, should not be packaged or issue, avoid developer will for the target program of debugging accidentally be packaged or Accidentally issue.
It includes the non-transitorycomputer readable storage medium instructed that the embodiment of the present invention, which additionally provides a kind of, such as including The memory of instruction, above-metioned instruction can be executed by the processor of electronic equipment to complete code shown in each embodiment of the present invention Compilation Method.For example, the non-transitorycomputer readable storage medium can be ROM, random access memory (RAM), CD- ROM, tape, floppy disk and optical data storage devices etc..
Figure 10 is the structural schematic diagram according to a kind of electronic equipment shown in an exemplary embodiment.The electronic equipment can be with Being embodied as operation in said program of the present invention has the equipment of Software Development Tools.The electronic equipment 1000 includes central processing list Member (CPU) 1001 includes the system storage 1004 of random access memory (RAM) 1002 and read-only memory (ROM) 1003, And the system bus 1005 of connection system storage 1004 and central processing unit 1001.The electronic equipment 1000 further includes The basic input/output (I/O systems) 1006 of information is transmitted between each device in help computer, and for storing The mass-memory unit 1007 of operating system 1013, application program 1014 and other program modules 1015.
The basic input/output 1006 includes display 1008 for showing information and is inputted for user The input equipment 1009 of such as mouse, keyboard etc of information.The wherein described display 1008 and input equipment 1009 all pass through The input and output controller 1010 for being connected to system bus 1005 is connected to central processing unit 1001.The basic input/defeated It can also includes that input and output controller 1010 is touched for receiving and handling from keyboard, mouse or electronics to go out system 1006 Control the input of multiple other equipments such as pen.Similarly, input and output controller 1010 also provide output to display screen, printer or Other kinds of output equipment.
The mass-memory unit 1007 (is not shown by being connected to the bulk memory controller of system bus 1005 Go out) it is connected to central processing unit 1001.The mass-memory unit 1007 and its associated computer-readable medium are Electronic equipment 1000 provides non-volatile memories.That is, the mass-memory unit 1007 may include such as hard disk Or the computer-readable medium (not shown) of CD-ROM drive etc.
Without loss of generality, the computer-readable medium may include computer storage media and communication media.Computer Storage medium includes information such as computer-readable instruction, data structure, program module or other data for storage The volatile and non-volatile of any method or technique realization, removable and irremovable medium.Computer storage media includes RAM, ROM, EPROM, EEPROM, flash memory or other solid-state storages its technologies, CD-ROM, DVD or other optical storages, tape Box, tape, disk storage or other magnetic storage apparatus.Certainly, skilled person will appreciate that the computer storage media It is not limited to above-mentioned several.Above-mentioned system storage 1004 and mass-memory unit 1007 may be collectively referred to as memory.
According to various embodiments of the present invention, the electronic equipment 1000 can also pass through the network connections such as internet Remote computer operation on to network.Namely electronic equipment 1000 can be by the net that is connected on the system bus 1005 Network interface unit 1011 is connected to network 1012, in other words, can also be connected to other classes using Network Interface Unit 1011 The network or remote computer system (not shown) of type.
The memory further includes that one or more than one program, the one or more programs are stored in In memory, central processing unit 1001 realizes that Fig. 2 or shown in fig. 6 codes are compiled by executing one or more programs Translate method.
Those skilled in the art after considering the specification and implementing the invention disclosed here, will readily occur to its of the present invention Its embodiment.This application is intended to cover the present invention any variations, uses, or adaptations, these modifications, purposes or Person's adaptive change follows the general principle of the present invention and includes undocumented common knowledge in the art of the invention Or conventional techniques.The description and examples are only to be considered as illustrative, and true scope and spirit of the invention are by following Claim is pointed out.
It should be understood that the invention is not limited in the precision architectures for being described above and being shown in the accompanying drawings, and And various modifications and changes may be made without departing from the scope thereof.The scope of the present invention is limited only by the attached claims.

Claims (12)

1. a kind of code compiling method, which is characterized in that the method includes:
The compiling received for source program instructs, and whether the target program that the compiling instruction instruction compiling obtains is for debugging;
If the compiling instruction instruction, for debugging, obtains debugging code setting rule, institute to the target program of compiling acquisition It includes object code and debugging code to state in debugging code setting rule;
Rule is set according to the debugging code, the debugging generation is arranged in the object code for including in the corresponding source program Code;
The source program to being provided with the debugging code is compiled, and obtains target program.
2. according to the method described in claim 1, it is characterized in that, described be arranged rule, corresponding institute according to the debugging code It states the object code for including in source program and the debugging code is set, including:
The object code is matched in the source program;
If being successfully matched to the object code, the object code is replaced with into the debugging code, alternatively, corresponding in institute The debugging code is inserted into the designated position for stating object code.
3. according to the method described in claim 1, it is characterized in that, the acquisition debugging code setting rule, including:
Obtain the program name of the source program;
The debugging code setting rule corresponding with described program name is inquired from pre-set configuration file.
4. method according to any one of claims 1 to 3, which is characterized in that the method further includes:
When receiving the instruction that the target program is packaged or is issued, show that prompting message, the prompting message are used for Prompt the target program for debugging.
5. according to the method described in claim 4, it is characterized in that, the method further includes:
Before being compiled to the source program for being provided with the debugging code, debugflag is arranged in the corresponding debugging code;
The described pair of source program for being provided with the debugging code is compiled, including:
The source program to being provided with the debugflag is compiled;
It is described to show prompting message when receiving the instruction that the target program is packaged or is issued, including:
When receiving the instruction that the target program is packaged or is issued, whether detect in the target program comprising described Debugflag shows the prompting message if it includes the debugflag that testing result, which is in the target program,.
6. according to the method described in claim 5, it is characterized in that, the method further includes:
Determine location information of the debugflag in the target program;
The displaying prompting message, including:
Displaying includes the prompting message of the location information.
7. a kind of code compilation device, which is characterized in that described device includes:
Command reception module, for receiving the compiling instruction for source program, the target of the compiling instruction instruction compiling acquisition Whether program is for debugging;
Rule acquisition module, if the target program for the compiling instruction instruction compiling acquisition obtains debugging for debugging Code setting rule includes object code and debugging code during the debugging code setting is regular;
Code setup module, for rule, the target for including in the corresponding source program to be arranged according to the debugging code The debugging code is arranged in code;
Collector obtains target program for being compiled to the source program for being provided with the debugging code.
8. device according to claim 7, which is characterized in that the code setup module, including:
Matching unit, for matching the object code in the source program;
If the object code is replaced with the debugging code by setting unit for being successfully matched to the object code, Alternatively, corresponding be inserted into the debugging code in the designated position of the object code.
9. device according to claim 7, which is characterized in that the rule acquisition module, including:
Program name acquiring unit, the program name for obtaining the source program;
Query unit is set for inquiring the debugging code corresponding with described program name from pre-set configuration file Set rule.
10. according to any device of claim 7 to 9, which is characterized in that described device further includes:
Reminding module, for when receiving the instruction that the target program is packaged or is issued, showing prompting message, institute It includes debugging code in the target program that prompting message, which is stated, for prompting.
11. device according to claim 10, which is characterized in that described device further includes:
Mark module, for before the collector is compiled the source program for being provided with the debugging code, corresponding to Debugflag is arranged in the debugging code;
The collector, for being compiled to the source program for being provided with the debugflag;
The reminding module when for receiving the instruction that the target program is packaged or is issued, detects the target Whether include the debugflag in program, if it includes the debugflag that testing result, which is in the target program, shows The prompting message.
12. according to the devices described in claim 11, which is characterized in that described device further includes:
Position determination module, for determining location information of the debugflag in the target program;
The reminding module, for show include the location information the prompting message.
CN201710031295.2A 2017-01-17 2017-01-17 Code compiling method and device Active CN108614704B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710031295.2A CN108614704B (en) 2017-01-17 2017-01-17 Code compiling method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710031295.2A CN108614704B (en) 2017-01-17 2017-01-17 Code compiling method and device

Publications (2)

Publication Number Publication Date
CN108614704A true CN108614704A (en) 2018-10-02
CN108614704B CN108614704B (en) 2021-04-02

Family

ID=63658201

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710031295.2A Active CN108614704B (en) 2017-01-17 2017-01-17 Code compiling method and device

Country Status (1)

Country Link
CN (1) CN108614704B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110888756A (en) * 2019-11-19 2020-03-17 支付宝(杭州)信息技术有限公司 Diagnostic log generation method and device
CN111124378A (en) * 2018-10-31 2020-05-08 北京国双科技有限公司 Code generation method and device

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101067798A (en) * 2007-06-14 2007-11-07 华南理工大学 Dynamic probe method and application in embedded system thereof
CN101719093A (en) * 2009-12-09 2010-06-02 上海普元信息技术有限责任公司 System and method for realizing cross-browser Javascript debugging in enterprise Web application system
CN101739333A (en) * 2008-11-25 2010-06-16 国际商业机器公司 Method, tool and device for debugging application program
CN102279789A (en) * 2010-06-13 2011-12-14 三星电子(中国)研发中心 Debugging system and debugging method for embedded system of production phase
US20140181786A1 (en) * 2012-12-20 2014-06-26 International Business Machines Corporation Generating debugging extension source code utilizing debugging information

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101067798A (en) * 2007-06-14 2007-11-07 华南理工大学 Dynamic probe method and application in embedded system thereof
CN101739333A (en) * 2008-11-25 2010-06-16 国际商业机器公司 Method, tool and device for debugging application program
CN101719093A (en) * 2009-12-09 2010-06-02 上海普元信息技术有限责任公司 System and method for realizing cross-browser Javascript debugging in enterprise Web application system
CN102279789A (en) * 2010-06-13 2011-12-14 三星电子(中国)研发中心 Debugging system and debugging method for embedded system of production phase
US20140181786A1 (en) * 2012-12-20 2014-06-26 International Business Machines Corporation Generating debugging extension source code utilizing debugging information

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111124378A (en) * 2018-10-31 2020-05-08 北京国双科技有限公司 Code generation method and device
CN111124378B (en) * 2018-10-31 2024-02-13 北京国双科技有限公司 Code generation method and device
CN110888756A (en) * 2019-11-19 2020-03-17 支付宝(杭州)信息技术有限公司 Diagnostic log generation method and device

Also Published As

Publication number Publication date
CN108614704B (en) 2021-04-02

Similar Documents

Publication Publication Date Title
US11868231B2 (en) System and method for evaluating code by a hybrid of local and cloud-based computers
US8601436B2 (en) Simulation-based interface testing automation system and method for robot software components
US20170192880A1 (en) Defect prediction
US9632754B2 (en) Auto generation and linkage of source code to test cases
US8434062B2 (en) Enhancing source code debugging and readability using visual symbols
US20100095159A1 (en) Apparatus and method for automatic testing of software or digital devices
Costa et al. Pattern based GUI testing for mobile applications
CN101802792A (en) Method for automatic script generation for testing the validity of operational software of a system onboard and aircraft and device for implementing the same
US8868976B2 (en) System-level testcase generation
US20180074944A1 (en) Test case generator built into data-integration workflow editor
CN108319575B (en) Page component checking method, device, server and storage medium
US9645911B2 (en) System and method for debugging firmware/software by generating trace data
JP2009087354A (en) Automatic test generation system and method for web application
US20140298290A1 (en) Identification of code changes using language syntax and changeset data
US7322026B2 (en) Scoring assertions
CN104468655A (en) Method and system for testing reverse proxy software
US7739671B1 (en) Systems, methods and apparatus for implementation of formal specifications derived from informal requirements
US20100312541A1 (en) Program test device and program
KR20180061589A (en) Software build system and software build method using the system
CN112363938A (en) Data processing method and device, electronic equipment and storage medium
US20190129832A1 (en) System and method for test data generation for use in model based testing using source code test annotations and constraint solving
CN108614704A (en) Code compiling method and device
CN112988578A (en) Automatic testing method and device
Rocha et al. Hunting Memory Bugs in C Programs with Map2Check: (Competition Contribution)
US9298428B2 (en) Graphical user interface editor that displays live data during editing

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant