WO2015067171A1 - Debug调试方法和装置 - Google Patents
Debug调试方法和装置 Download PDFInfo
- Publication number
- WO2015067171A1 WO2015067171A1 PCT/CN2014/090306 CN2014090306W WO2015067171A1 WO 2015067171 A1 WO2015067171 A1 WO 2015067171A1 CN 2014090306 W CN2014090306 W CN 2014090306W WO 2015067171 A1 WO2015067171 A1 WO 2015067171A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- program
- debugging
- debug
- information
- switch
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3664—Environments for testing or debugging software
Definitions
- PHP Hypertext Preprocessor
- PHP is a general-purpose open source scripting language that incorporates the features of C, Java, and Per l and is primarily used for Web development. Because PHP has the advantages of low entry barriers and easy learning, PHP has a wide range of applications.
- PHP Like other software development languages, PHP also needs to be debugged during the web development process; however, debugging in the web development process usually does not use single-step debugging. The reasons include: PHP for HTTP environment variables and databases. The dependence of external resources is strong. It is usually too cumbersome to construct such a single-step debugging environment. Therefore, PHP cannot be easily step-by-step debugging like software development languages such as C++ and Java. In addition, PHP is a weakly typed language. Single stepping is not a must.
- the existing PHP debugging methods mainly include: DEBUG debugging using YII-Debug-Boolbar of YII framework. Specifically, YII-Debug-Boolbar prints the DEBUG information to a hidden DIV of the page, and then expands the DIV by controlling the corresponding button, so that the DEBUG information can be viewed.
- the YII-Debug-Boolbar of the YII framework can no longer be used for DEBUG debugging in the current state.
- the tester cannot remotely obtain the DEBUG information accessed by the A user; Remote program debugging mode for program debugging.
- the existing remote program debugging mode is usually: using a remote login function of a tool such as QQ to log in to the terminal device of the user who reported the fault, and using the debugging tool in the user's terminal device to implement remote program debugging.
- the present invention has been made in order to provide an overcoming of the above problems or at least partially A DEBUG debugging method, a corresponding DEBUG debugging device, a computer program, and a computer readable medium that solve the above problems.
- a DEBUG debugging method comprising: acquiring, when a program including at least one debugging key point is started, acquiring identification information of a participating subject executed by the program; determining the participating subject Whether the identification information belongs to a preset set of participating subject identifiers; if it belongs to a preset set of participating subject identifiers, the current value of the debugging switch of the program is set to a first value; otherwise, the debugging of the program is set The current value is set to a second value; wherein the first value indicates that the debug switch is turned on, and the second value indicates that the debug switch is turned off; when the program is executed to each debug key point, the current state of the debug switch is obtained.
- a DEBUG debugging apparatus comprising: a first obtaining module adapted to acquire an identification of a participating subject executed by a program when a program including at least one debugging key point is initially executed
- the first processing module is configured to determine whether the identification information of the participating entity belongs to a preset set of participating subject identifiers; if it belongs to a preset set of participating subject identifiers, set the current value of the debugging switch of the program.
- the debug information set at the execution debug key point generates corresponding DEBUG information, continues to execute the program, and the DEBUG information is transmitted to the program. Test client; if the second value does not generate the above-described operation is performed DEBUG information, and continue the program.
- a computer program comprising computer readable code that causes the DEBUG debugging method to be executed when the electronic device runs the computer readable code.
- a computer readable medium storing a computer program as described above is provided.
- the DEBUG debugging method and device of the present invention sets the debugging switch to be turned on or off according to the identification information of the participating subject executed by the program when the program starts running, and the debugging information set at each debugging key point in the program is according to the debugging switch.
- the current value determines whether to perform the print processing of the DEBUG information (ie, generates the DEBUG information), so that it is not necessary to delete the debug letter in the program after the program is online.
- the debugging technology of the present invention does not affect the development efficiency of the web. And it does not destroy the BODY source code structure of the original page, so that when there is an AJAX request, there is no problem of data structure error; thus, the PHP debugging technology provided by the present invention has wide application range and is easy to use. Good character and so on.
- FIG. 1 is a flowchart of a DEBUG debugging method according to Embodiment 1 of the present invention
- FIG. 2 is a schematic diagram of DEBUG information according to Embodiment 2 of the present invention.
- FIG. 3 is a schematic diagram of DEBUG information according to Embodiment 3 of the present invention.
- FIG. 4 is a schematic diagram of a DEBUG debugging apparatus according to Embodiment 4 of the present invention.
- Figure 5 shows a block diagram of an electronic device for performing the method of the present invention
- Figure 6 shows a schematic diagram of a memory unit for holding or carrying program code implementing the method according to the invention.
- Embodiment 1 DEBUG debugging method. The method of this embodiment will be described below with reference to FIG. 1.
- S100 for a program including at least one debugging key point, acquires identification information of a participating subject executed by the program when the program starts to be executed.
- the program in this embodiment refers to a PHP-based program, such as a web-based development using PHP.
- the application of the service, etc.; and the debugging key point in the program can be the debugging key points automatically set by the existing tools, such as the debugging key points automatically set in the program by using the FIREPHP tool; of course, the debugging key points in the program It can also be a debugging key point that the program developer manually sets in the program according to actual needs.
- resource operations such as database operations, Memcache operations, and network calls in a program are usually set to debug keys that require DEBUG information.
- the entry of the program can be correspondingly improved, for example, the corresponding program code is newly set at the entrance of the program, so that when the program starts to be executed, the newly added program code is first executed. Since the function of the newly added program code in the program includes obtaining the identification information of the participating subject executed by the program; therefore, when the program is started to be executed, the embodiment may first obtain the identification information of the participating subject of the program execution.
- the participating entity of the program in this embodiment may be the server that executes the program, or may be: the user currently served by the program; therefore, the identification information of the participating entity executed by the program in this embodiment may be the IP of the server.
- the address or the server ID may also be the user's IP address or the user's login account (ie, user ID), etc.; the identification information should be able to uniquely identify the participating subject of the program execution.
- S110 Determine whether the acquired identification information of the participating subject belongs to a preset set of participating subject identifiers; if the identification information of the participating subject belongs to a preset set of participating subject identifiers, go to S120; if the identifier of the participating subject If the information does not belong to the preset set of participating subject identifiers, then go to S130.
- the participant identity identifier set in this embodiment is preset.
- the IP address of the server running the program in the development environment or the ID of the server may be preset in the participant body identifier set.
- the IP address of the user or the ID of the user may be set in the participant identifier set.
- the participant identity identifier set may be maintained by a server running the program, and the participant body identifier set may be set inside the program, or may be set independently of the program, such as being set in a database or a table, so that the above judgment is In the process, it involves the query access operation of the database or table.
- the participating subject identification set usually contains one or more participating subject identifiers. Whether the identification information of the participating participant obtained in the step is a preset participant identity identifier set refers to whether the identification information of the participant body matches a certain participant identity in the participant body identifier set; that is, if If the acquired identification information of the participating entity matches one of the participating subject identifiers in the participant subject identifier set, it indicates that the identification information of the participating subject belongs to a preset participating subject. The identification set, otherwise, the identification information indicating the participating entity does not belong to the preset set of participating subject identifiers.
- the acquired identity information of the participant body must not belong to the participant body identity set.
- the debugging switch of the program may be a constant, such as a boolean constant or a numerical constant, etc., after the current value of the debugging switch is set to the first value or the second value, during subsequent execution of the program, The value of this debug switch usually does not change.
- the debugging switch of the program can also be expressed as other forms such as flag bits.
- the first value may be true, or may be 0 or other predetermined value or the like.
- the second value is different from the first value.
- the second value is false; for example, the first value is 0, and the second value is 1.
- the default value of the debug switch can be set to the first value, and after the program is online, the default value of the debug switch can be set to the second value.
- the first value indicates that the debug switch is on
- the second value indicates that the debug switch is off
- all of the above S100 to S130 should be set at the entrance of the program, such as adding a corresponding program code at the entrance of the program to perform the operations of the above S100-S130.
- the debugging information set at the debugging key point is executed, and the current values of the debugging switch (such as the above Boolean constant) are obtained first.
- S150 Determine the current value of the debugging switch. If the current value of the debugging switch is the first value, go to S160. If the current value of the debugging switch is the second value, go to S170.
- S160 Generate corresponding DEBUG information according to the debugging information set at the currently executed debugging key point, and continue to execute subsequent content in the program.
- the debugging information set at the debugging key point includes a DEBUG command, and the DEBUG command is used to generate a key point log (that is, the DEBUG command is used to print a key point log), thereby generating corresponding DEBUG information.
- the process of generating the corresponding DEBUG information by executing the DEBUG command in this embodiment may also be referred to as printing DEBUG information.
- the DEBUG information generated in this embodiment may include: request URL information, POST information, cookie information, program execution debug information, page return content, execution time, and the like.
- the current value of the debugging switch is the second value, it indicates that the program does not need to be debugged during the current running process, therefore, the DEBUG in the debugging information set at the currently executed debugging key point should be ignored. Command, and continue to execute the program code of the non-debug part of the program.
- the DEBUG information in this embodiment may be sent to the program debugging client immediately after the generation, or all DEBUG information may be sent to the program debugging client together when the program is completed.
- DEBUG information being transmitted to the program debugging client is: after the DEBUG information is generated based on the debugging information at a key point, an HTTP message is generated immediately, and the currently generated DEBUG information is The Json format is carried in the header field of the currently generated HTTP message, after which the HTTP message is transmitted to the program debug client.
- the program debug client can be set to the device (such as the server) running the program.
- the DEBUG information may be carried in the header field of the HTTP message by using other formats (such as a custom format).
- the DEBUG information should also be parsed in a corresponding manner. And display.
- DEBUG information being transmitted to the program debugging client is: using the ShutDown function to register a DEBUG information transfer function in the program, the DEBUG information transfer function is mainly used to send DEBUG information in an asynchronous queue manner. Transfer to the debugging center (such as the debugging center management background); usually, the debugging center and the device running the program (such as the server) are two separate physical devices. During the execution of the program, the DEBUG information generated by the debug information set at the key point to be executed is temporarily stored, and the registered DEBUG information is transmitted when the program is completed or the program performs an exit (EXIT) operation.
- EXIT exit
- the DEBUG debugging method in this embodiment is not a single-step debugging technology; since the program starts running, the debugging switch is turned on or off according to the identification information of the participating subject executed by the program, and the program is in the program.
- the debugging information set at each debugging key point determines whether to execute the printing processing of the DEBUG information according to the current value of the debugging switch. Therefore, it is not necessary to delete the debugging information in the program after the program is online, and the program after going online is not used.
- Embodiment 2 DEBUG debugging method in the web development process. The method of this embodiment will be described below with reference to FIG.
- debugging information should be set in advance at key points that need attention (such as resource points).
- the debugging information set in the incremental operation of Memcache can be as follows:
- the DAGGER_DEBUG is a Boolean constant, which is mainly used to control whether the debug command is executed later, that is, whether the debug command set later is enabled, and the DAGGER_DEBUG is the debugging switch in this embodiment.
- the program When the program starts running, first obtain the IP address of the current server, and determine whether the IP address of the server belongs to a preset set of server IP addresses, and then set the current value of DAGGER_DEBUG according to the result of the judgment. Since the embodiment is in the web development environment, the IP address of the current server is set in the preset server IP address set, so that the IP address of the current server must belong to a preset set of server IP addresses, and further, DAGGER_DEBUG It should be set to characterize the information that the debug switch is turned on.
- the debugging information set in the increment operation When the user accesses the corresponding page, the debugging information set in the increment operation generates corresponding DEBUG information, and the DEBUG information is carried in the header field of the HTTP message in a manner based on the Json format, and the HTTP message is transmitted to the program debugging client.
- the DEBUG information in the header field of the HTTP message can be presented to the developer through the console of the local browser.
- the DEBUG information in the header field of the HTTP message is parsed by the Firephp tool, and the developer can control from the firebug under the Firefox browser. The station sees the corresponding DEBUG information.
- DEBUG information generated by the debug information set in the above increment operation can be found in the following:
- mc_increment(dagger_abc): 2 is the information output by the above DEBUG command.
- FIG. 2 A more complete DEBUG information is shown in Figure 2.
- the array portion is expandable and rendered.
- Embodiment 3 DEBUG debugging method in the remote program debugging process. The method of this embodiment will be described below with reference to FIG.
- Program code for opening remote program debugging is provided at the entrance of the program, and a specific example of the program code is:
- the remote program debugging function of the program is turned on.
- the above user ID can also be replaced with a user IP address or the like.
- the program When the program starts running, you should first obtain the user ID (such as obtaining the user ID from the HTTP message from the user), and determine whether the user ID belongs to a preset set of user IDs (that is, the array of arrays in the above program code). After that, according to the result of the judgment, the current value of DAGGER_DEBUG (such as "true” or "false") is set. Because the embodiment is in the remote program debugging environment, in the case that the user reports the fault information, the user ID of the user reporting the fault should be set in the array () array, thereby reporting the user of the faulty user. The ID must belong to the above array() array. Further, DAGGER_DEBUG should be set to represent the information that the debug switch is turned on, such as true.
- DAGGER_DEBUG should be set to represent the information that the debug switch is turned on, such as true.
- the debugging information set at each key point in the program will generate DEBUG information, and the DEBUG information is temporarily stored, when the program execution is completed, All temporarily stored DEBUG information is transmitted to the debugging center in the form of an asynchronous queue.
- the debugging center receives the DEBUG information in the JSON format and carries it in the header field of the HTTP message. Then, the debugging center transmits the HTTP message to the program debugging client. end.
- the program debugging client (such as the client of the Firephp tool) presents the DEBUG information to the maintenance personnel when the debug information button is clicked by the maintenance personnel.
- a specific example of the DEBUG information presented by the local browser's console for maintenance personnel is shown in Figure 3.
- Embodiment 4 DEBUG debugging device. The device will be described in detail below with reference to FIG.
- the device shown in FIG. 4 mainly includes: a first obtaining module 400, a first processing module 410, and a second The module 420 and the second processing module 430 are obtained.
- the first obtaining module 400 is mainly adapted to acquire identification information of the participating subject executed by the program when the program including the at least one debugging key point is initially executed.
- the program in this embodiment refers to a PHP-based program, such as a Web service-based application developed using PHP; and the debugging key point in the program may be a debugging key point automatically set by using an existing tool.
- the debugging key points automatically set in the program by using the FIREPHP tool can also be the debugging key points manually set by the program developer in the program according to actual needs.
- resource operations such as database operations, Memcache operations, and network calls in a program are usually set to debug keys that require DEBUG information.
- the entry of the program may be correspondingly improved, such as newly setting the first obtaining module 400 at the entrance of the program, so that when the program starts to be executed, the newly acquired first acquiring module 400 is first executed. Obtain the identification information of the participating entity that the program executes.
- the participating entity of the program in this embodiment may be the server that executes the program, or may be: the user currently served by the program; therefore, the identification information of the participating entity executed by the program in this embodiment may be the IP of the server.
- the address or the server ID may also be the user's IP address or the user's login account (ie, user ID), etc.; the identification information should be able to uniquely identify the participating subject of the program execution.
- the first processing module 410 is mainly configured to determine whether the identification information of the participating entity belongs to a preset set of participating subject identifiers; if it belongs to a preset set of participating subject identifiers, set the current value of the debugging switch of the program to the first Value, otherwise, the current value of the debugging switch of the program is set to a second value; wherein, the first value indicates that the debugging switch is turned on, and the second value indicates that the debugging switch is turned off;
- the participant identity identifier set in this embodiment is preset.
- the IP address of the server running the program in the development environment or the ID of the server may be preset in the participant body identifier set.
- the IP address of the user or the ID of the user may be set in the participant identifier set.
- the participating subject identification set usually contains one or more participating subject identifiers.
- the first processing module 410 determines whether the acquired identification information of the participating subject belongs to a preset set of participating subject identifiers, whether the identification information of the participating subject matches a certain participating subject identifier in the participating subject identification set; that is, If the first processing module 410 determines that the identification information of the participating entity acquired by the first obtaining module 400 matches one of the participating subject identifiers in the participating subject identification set, the The identification information of the participating subject belongs to a preset set of participating subject identifiers. Otherwise, the identifying information indicating the participating subject does not belong to a preset set of participating subject identifiers.
- the first processing module 410 determines that the identifier information of the participant body acquired by the first acquisition module 400 does not belong to the participant body identifier set.
- the debugging switch of the program may be a constant, such as a Boolean constant or a numeric constant. After the first processing module 410 sets the current value of the debugging switch to the first value or the second value, the subsequent execution process of the program is performed. The value of this debug switch usually does not change. In addition, the debugging switch of the program can also be expressed as other forms such as flag bits.
- the second value is different from the first value. If the first value is true, the second value is false; for example, the first value is 0 and the second value is 1.
- the default value of the debug switch can be set to the first value, and after the program is online, the default value of the debug switch can be set to the second value. The first value indicates that the debug switch is on, and the second value indicates that the debug switch is off.
- first acquiring module 400 and the first processing module 410 should be disposed at the entrance of the program.
- the second obtaining module 420 is mainly adapted to obtain the current value of the debugging switch when the program is executed to each debugging key point.
- the number of the second obtaining module 420 may be multiple, and a second acquiring module 420 is disposed at each debugging key point in the program; thus, when the program is executed to a debugging key point, the program The second acquisition module 420 set at the debug key point will be executed, and the current values of the debug switch (such as the above Boolean constant) will be obtained first.
- the second processing module 430 is mainly configured to determine the current value of the debugging switch. If the current value of the debugging switch is the first value, the corresponding DEBUG information is generated according to the debugging information set at the currently executed debugging key point, and the execution continues. The program, and the DEBUG information is transmitted to the program debugging client; if the current value of the debugging switch is the second value, the above-mentioned DEBUG information generation operation is not performed, and the program is continuously executed.
- the debugging information in the second processing module 430 set at the debugging key point includes a DEBUG command, which is used to generate a log of a key point (ie, the DEBUG command is used to print a log of a key point), thereby generating a corresponding DEBUG information.
- the DEBUG information generated by the second processing module 430 may include: request URL information, POST information, cookie information, program execution debug information, page return content, execution time, and the like.
- the debugging in the second processing module 430 set at the currently executed debugging key point should be ignored.
- the DEBUG command in the message so that you can continue to execute the program code in the non-debug part of the program.
- the second processing module 430 may send the DEBUG information to the program debugging client immediately after the DEBUG information is generated, or may send all the DEBUG information together to the program debugging client when the program execution is completed.
- a specific example of the second processing module 430 transmitting the DEBUG information to the program debugging client is: after the DEBUG information is generated based on the debugging information at a key point, the second processing module 430 immediately generates an HTTP.
- the message, and the currently generated DEBUG information is carried in the Json format in the header field of the currently generated HTTP message, after which the second processing module 430 transmits the HTTP message to the program debugging client.
- the second processing module 430 may also use other formats (such as a custom format) to carry the DEBUG information in the header field of the HTTP message.
- the DEBUG information should also be adopted in a corresponding manner. Analyze and display.
- a specific example of the second processing module 430 transmitting the DEBUG information to the program debugging client is: registering a DEBUG information transfer function in the program by using the ShutDown function (the DEBUG information transfer function belongs to the second processing module 430).
- the DEBUG information transfer function is mainly used to transmit the DEBUG information to the debugging center in an asynchronous queue manner (such as the debugging center management background); usually, the debugging center and the device (such as a server) running the program are two Physical devices that are set independently of each other.
- the DEBUG information generated by the debug information set at the key point to be executed is temporarily stored by the second processing module 430, and when the program execution is completed or the program performs an exit (EXIT) operation, the above The registered DEBUG information transfer function is called, so that the DEBUG information transfer function transmits all the DEBUG information temporarily stored by the second processing module 430 to the debugging center in an asynchronous queue manner, and after receiving the DEBUG information, the debugging center will The DEBUG information is carried in the header field of the HTTP message in Json format or other format (such as a custom format). Then, the debugging center transmits the HTTP message to the program debugging client, and the program debugging client presents the DEBUG information to the maintenance personnel. .
- a DEBUG debugging method which includes:
- the current value of the debugging switch of the program is set to a first value; otherwise, the current value of the debugging switch of the program is set to a second value;
- the first value indicates that the debug switch is turned on, and the second value indicates that the debug switch is turned off;
- A2 The method of A1, wherein the participating subject of the program execution comprises: a server executing the program or a user currently served by the program.
- identification information of the participating entity executed by the program comprises: an IP address of the server, an IP address of the user, or a login account of the user.
- A4 The method of A1, wherein the debugging switch of the program is a constant.
- A5. The method of A1, wherein, in the web development process, the DEBUG information is transmitted to the program debugging client, including:
- the DEBUG information is carried in a header field of an HTTP message, and the HTTP message is transmitted to a program debugging client.
- A6 The method of A1, wherein, in the remote debugging process, the DEBUG information is transmitted to the program debugging client, including:
- the DEBUG information is transmitted to the debugging center in an asynchronous queue manner, and the debugging center carries the received DEBUG information in a header field of the HTTP message, and transmits the HTTP message to the program debugging client.
- A7 The method of A5 or A6, wherein the DEBUG information is carried in a header field of an HTTP message in a Json format.
- the method of A7, wherein the transmitting the DEBUG information to the debugging center in an asynchronous queue manner comprises:
- the DEBUG information transfer function registered by the ShutDown function is called, and the DEBUG information transfer function transmits the DEBUG information to the debug center in an asynchronous queue manner.
- a DEBUG debugging device comprising:
- a first obtaining module configured to acquire identification information of a participating entity executed by the program when the program including the at least one debugging key point is started to be executed;
- the first processing module is configured to determine whether the identification information of the participating entity belongs to a preset set of participating subject identifiers; if it belongs to a preset set of participating subject identifiers, set a current value of the debugging switch of the program a first value, otherwise, setting a current value of the debugging switch of the program to a second value; wherein the first value indicates that the debugging switch is turned on, and the second value indicates that the debugging switch is turned off;
- a second obtaining module configured to obtain a current value of the debugging switch when the program is executed to each debugging key point
- the second processing module determines the current value of the debugging switch; if it is the first value, generates corresponding DEBUG information according to the debugging information set at the currently executed debugging key point, and continues to execute the program, and the DEBUG The information is transferred to the program debug client; if it is the second value, it is not executed The above-mentioned DEBUG information is generated and continues to execute the program.
- the device of A9, wherein the participating entity executed by the program comprises: a server executing the program or a user currently served by the program.
- identification information of the participating entity executed by the program comprises: an IP address of the server, an IP address of the user, or a login account of the user.
- A12 The device of claim 9, wherein the debug switch of the program is a constant.
- A13 The device of A9, wherein, in the web development process, the DEBUG information is transmitted to the program debugging client, including:
- the second processing module carries the DEBUG information in a header field of the HTTP message and transmits the HTTP message to the program debugging client.
- A14 The device of A9, wherein, during remote debugging, the DEBUG information is transmitted to the program debugging client, including:
- the second processing module transmits the DEBUG information to the debugging center in an asynchronous queue manner, and the debugging center carries the received DEBUG information in a header field of the HTTP message, and transmits the HTTP message to the program debugging client. end.
- the device of claim 14, wherein the transmitting, by the second processing module, the DEBUG information to the debugging center in an asynchronous queue manner comprises:
- the second processing module calls the DEBUG information transfer function registered by the ShutDown function, and the DEBUG information transfer function transmits the DEBUG information to the debug center in an asynchronous queue manner.
- modules in the devices of the embodiments can be adaptively changed and placed in one or more devices different from the embodiment.
- the modules or units or components of the embodiments may be combined into one module or unit or component, and further they may be divided into a plurality of sub-modules or sub-units or sub-components.
- any combination of the features disclosed in the specification, including the accompanying claims, the abstract and the drawings, and any methods so disclosed, or All processes or units of the device are combined.
- Each feature disclosed in this specification (including the accompanying claims, the abstract and the drawings) may be replaced by alternative features that provide the same, equivalent or similar purpose.
- the various component embodiments of the present invention may be implemented in hardware, or in a software module running on one or more processors, or in a combination thereof.
- a microprocessor or digital signal processor may be used in practice to implement some or all of the functionality of some or all of the components of the DEBUG debug device in accordance with embodiments of the present invention.
- the invention can also be implemented as a device or device program (such as a computer program and a computer program product) for performing some or all of the methods described herein.
- Such a program implementing the invention may be stored on a computer readable medium or may be in the form of one or more signals. Such signals may be downloaded from an Internet website, provided on a carrier signal, or provided in any other form.
- Figure 5 illustrates an electronic device in which the DEBUG debugging method of the present invention can be implemented.
- the electronic device conventionally includes a processor 1210 and a computer program product or computer readable medium in the form of a memory 1220.
- the memory 1220 may be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read Only Memory), an EPROM, a hard disk, or a ROM.
- Memory 1220 has a memory space 1230 for program code 1231 for performing any of the method steps described above.
- storage space 1230 for program code may include various program codes 1231 for implementing various steps in the above methods, respectively.
- the program code can be read from or written to one or more computer program products.
- These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks.
- Such computer program products are usually A portable or fixed storage unit as described with reference to FIG.
- the storage unit may have a storage section or a storage space or the like arranged similarly to the storage 1220 in the electronic device of FIG.
- the program code can be compressed, for example, in an appropriate form.
- the storage unit comprises a program 1231' for performing the steps of the method according to the invention, ie a code readable by a processor such as 1210, which when executed by the electronic device causes the electronic device to perform the above Each step in the described method.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
一种DEBUG调试方法和装置,其中的方法包括:在包含有至少一个调试关键点的程序开始被执行时,获取程序执行的参与主体的标识信息;判断参与主体的标识信息是否属于预先设定的参与主体标识集合;如果属于,则将调试开关的当前取值设置为第一值,否则,将调试开关的当前取值设置为第二值;在程序被执行到每一调试关键点时,均获取调试开关的当前取值;判断调试开关的当前取值;如果为第一值,则根据当前执行的调试关键点处设置的调试信息产生相应的DEBUG信息,并继续执行程序,且所述DEBUG信息被传输至程序调试客户端;如果为第二值,则不执行上述DEBUG信息的产生操作,而继续执行该程序。
Description
本发明涉及PHP调试技术,具体涉及一种针对PHP的DEBUG调试方法和装置。
PHP(Hypertext Preprocessor,超文本预处理器)是一种通用的开源脚本语言,其吸收了C语言、Java以及Per l的特点,且主要用于Web开发。由于PHP具有入门门槛较低且易于学习等优点,因此,PHP的应用范围非常广泛。
与其他的软件开发语言一样,PHP在Web开发过程中也需要进行调试;然而,在Web开发过程中的调试通常并不采用单步调试方式,这其中的原因包括:PHP对HTTP环境变量以及数据库等外部资源的依赖性较强,构造这样的单步调试环境通常较麻烦,因此,PHP并不能像C++以及Java等软件开发语言那样可以很方便的进行单步调试;另外,PHP作为弱类型语言,单步调试也并不是必须的。
在利用PHP进行Web开发过程中,现有的PHP调试方式主要包括:利用YII框架的YII-Debug-Boolbar进行DEBUG调试。具体的,YII-Debug-Boolbar将DEBUG信息打印到页面的一个隐藏的DIV中,然后,通过控制相应的按钮展开DIV,从而可以查看其中的DEBUG信息。
在程序正式上线后,如果用户上报故障,则在当前状态下无法再利用YII框架的YII-Debug-Boolbar进行DEBUG调试,如测试人员无法远程获得A用户访问的DEBUG信息;只能利用现有的远程程序调试方式进行程序调试。
现有的远程程序调试方式通常为:利用QQ等工具的远程登录功能登录上报故障的用户的终端设备,并利用用户的终端设备中的调试工具实现远程程序调试。
发明人在实现本发明过程中发现,现有的PHP调试方式不能同时兼顾Web开发过程中的程序调试以及程序上线后的远程程序调试;另外,在针对Web开发模式的PHP调试方式中,被打印到DIV中的DEBUG信息会破坏原有页面的BODY源代码结构,从而在有AJAX(异步JavaScript和XML)请求时,会出现数据结构错误的问题;还有,在Web(尤其是Web2.0)开发过程中,数据通常是以Json格式进行传输的,而现有的打印到DIV中的DEBUG信息通常需要以ECHO格式进行传输,这会影响Web的开发效率。
发明内容
鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地
解决上述问题的DEBUG调试方法、相应的DEBUG调试装置、计算机程序以及计算机可读介质。
依据本发明的一个方面,提供了一种DEBUG调试方法,该方法包括:在包含有至少一个调试关键点的程序开始被执行时,获取程序执行的参与主体的标识信息;判断所述参与主体的标识信息是否属于预先设定的参与主体标识集合;如果属于预先设定的参与主体标识集合,则将所述程序的调试开关的当前取值设置为第一值,否则,将该程序的调试开关的当前取值设置为第二值;其中,该第一值表示调试开关开启,该第二值表示调试开关关闭;在所述程序被执行到每一调试关键点时,均获取调试开关的当前取值;判断所述调试开关的当前取值;如果为第一值,则根据当前执行的调试关键点处设置的调试信息产生相应的DEBUG信息,继续执行所述程序,且所述DEBUG信息被传输至程序调试客户端;如果为第二值,则不执行上述DEBUG信息的产生操作,并继续执行所述程序。
根据本发明的另一方面,提供了一种DEBUG调试装置,该装置包括:第一获取模块,适于在包含有至少一个调试关键点的程序开始被执行时,获取程序执行的参与主体的标识信息;第一处理模块,适于判断所述参与主体的标识信息是否属于预先设定的参与主体标识集合;如果属于预先设定的参与主体标识集合,则将程序的调试开关的当前取值设置为第一值,否则,将所述程序的调试开关的当前取值设置为第二值;其中,所述第一值表示调试开关开启,所述第二值表示调试开关关闭;第二获取模块,适于在所述程序被执行到每一调试关键点时,均获取调试开关的当前取值;第二处理模块,判断所述调试开关的当前取值;如果为第一值,则根据当前执行的调试关键点处设置的调试信息产生相应的DEBUG信息,继续执行所述程序,且所述DEBUG信息被传输至程序调试客户端;如果为第二值,则不执行上述DEBUG信息的产生操作,并继续执行所述程序。
根据本发明的另一个方面,提供了一种计算机程序,其包括计算机可读代码,当电子设备运行所述计算机可读代码时,导致所述的DEBUG调试方法被执行。
根据本发明的再一个方面,提供了一种计算机可读介质,其中存储了如上所述的计算机程序。
本发明的DEBUG调试方法和装置通过在程序在开始运行时,根据程序执行的参与主体的标识信息设置调试开关开启或者关闭,且程序中的各调试关键点处设置的调试信息会根据调试开关的当前取值来决定是否执行DEBUG信息的打印处理(即产生DEBUG信息),这样,在程序上线后无需删除程序中的调试信
息;而且,通过对程序执行的参与主体的标识信息是否属于参与主体标识集合的判断,不仅可以方便的实现Web开发模式的程序调试,而且可以非常方便的针对上报故障的用户实现远程程序调试;进一步的,在Web开发模式下,由于本实施例的DEBUG信息可以以Json格式承载于HTTP消息的头域中传输至程序调试客户端,因此,本发明的调试技术不仅不会影响Web的开发效率,而且也不会破坏原有页面的BODY源代码结构,这样,在有AJAX请求时,不会出现数据结构错误的问题;由此可知,本发明提供的PHP调试技术具有适用范围广以及易用性好等特点。
上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。
通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。本实施例的附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:
图1示出了根据本发明实施例一的DEBUG调试方法流程图;
图2示出了根据本发明实施例二的DEBUG信息示意图;
图3示出了根据本发明实施例三的DEBUG信息示意图;
图4示出了根据本发明实施例四的DEBUG调试装置示意图;
图5示出了用于执行本发明的方法的电子设备的框图;以及
图6示出了用于保持或者携带实现根据本发明的方法的程序代码的存储单元示意图。
下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。
实施例一、DEBUG调试方法。下面结合图1对本实施例的方法进行说明。
图1中,S100、针对包含有至少一个调试关键点的程序而言,在该程序开始被执行时,获取该程序执行的参与主体的标识信息。
具体的,本实施例中的程序是指基于PHP的程序,如使用PHP开发的基于Web
服务的应用程序等;且该程序中的调试关键点可以是利用现有的工具自动设置的调试关键点,如利用FIREPHP工具在程序中自动设置的调试关键点;当然,程序中的调试关键点也可以是程序开发人员根据实际需求而在程序中自行手工设置的调试关键点。
通常情况下,程序中的数据库操作、Memcache操作、网络调用等资源类操作通常都会被设置为需要产生DEBUG信息的调试关键点。
本实施例可以对程序的入口进行相应的改进,如在程序的入口处新增设置相应的程序代码,以便于在程序开始被执行时,新增设置的程序代码首先被执行。由于在程序中新增设置的程序代码的作用包括获取该程序执行的参与主体的标识信息;因此,在该程序开始被执行时,本实施例可以首先获取到程序执行的参与主体的标识信息。
本实施例中的程序执行的参与主体可以为执行该程序的服务器,也可以为:该程序当前所服务的用户;因此,本实施例中的程序执行的参与主体的标识信息可以为服务器的IP地址或者服务器ID,也可以为用户的IP地址或者用户的登录账号(即用户ID)等;该标识信息应能够唯一标识出程序执行的参与主体。
S110、判断上述获取到的参与主体的标识信息是否属于预先设定的参与主体标识集合;如果该参与主体的标识信息属于预先设定的参与主体标识集合,则到S120;如果该参与主体的标识信息不属于预先设定的参与主体标识集合,则到S130。
具体的,本实施例中的参与主体标识集合是预先设置的,如在Web开发过程中,可以将开发环境中运行该程序的服务器的IP地址或者服务器的ID预先设置在该参与主体标识集合中;再如,在程序正式上线后,如果接收到某用户上报的故障信息,则可以将该用户的IP地址或者用户的ID设置在该参与主体标识集合中。
该参与主体标识集合可以由运行该程序的服务器进行维护,且该参与主体标识集合可以设置于该程序内部,也可以独立于该程序而设置,如设置于数据库或者表中,这样,在上述判断过程中,会涉及到数据库或者表的查询访问操作。
该参与主体标识集合通常会包含有一个或者多个参与主体标识。本步骤中的判断获取到的参与主体的标识信息是否属于预先设定的参与主体标识集合是指参与主体的标识信息是否与参与主体标识集合中的某个参与主体标识匹配;也就是说,如果获取到的参与主体的标识信息与参与主体标识集合中的一个参与主体标识匹配,则表示该参与主体的标识信息属于预先设定的参与主体
标识集合,否则,表示该参与主体的标识信息不属于预先设定的参与主体标识集合。
在该参与主体标识集合为空的情况下,上述获取到的参与主体的标识信息一定不属于该参与主体标识集合。
S120、将程序的调试开关的当前取值设置为第一值,然后,到S140。
具体的,该程序的调试开关可以为常量,如布尔型常量或者数值型常量等,在该调试开关的当前值被设置为第一值或者第二值后,在该程序的后续执行过程中,该调试开关的取值通常不会发生变化。另外,该程序的调试开关也可以表现为标志位等其他形式。
上述第一值可以为true,也可以为0或者其他预定数值等。
S130、将程序的调试开关的当前取值设置为第二值,然后,到S140。
具体的,第二值与上述第一值不相同,例如,第一值为true时,第二值为false;再如,第一值为0,第二值为1。另外,在Web开发过程中,该调试开关的缺省值可以设置为第一值,而在程序上线后,该调试开关的缺省值可以设置为第二值。
在本实施例中,第一值表示调试开关开启,第二值表示调试开关关闭。
另外,需要说明的是,上述S100至S130均应设置于程序的入口处,如在程序的入口处新增设置相应的程序代码以执行上述S100-S130的操作。
S140、在该程序执行到每一调试关键点时,均需要获取调试开关的当前取值。
具体的,在程序执行到一调试关键点时,该调试关键点处设置的调试信息均会被执行,且均会先获取调试开关(如上述布尔型常量)的当前取值。
S150、判断该调试开关的当前取值,如果该调试开关的当前取值为第一值,则到S160;如果调试开关的当前取值为第二值,则到S170。
S160、根据当前执行到的调试关键点处设置的调试信息产生相应的DEBUG信息,并继续执行该程序中的后续内容。
具体的,调试关键点处设置的调试信息包括DEBUG命令,该DEBUG命令用于产生关键点的日志(即该DEBUG命令用于打印关键点的日志),从而产生相应的DEBUG信息。本实施例中的通过执行DEBUG命令而产生相应的DEBUG信息的过程也可以称为打印DEBUG信息。
本实施例所产生的DEBUG信息可以包括:请求URL信息、POST信息、Cookie信息、程序执行debug信息、页面返回内容以及执行时间等等。
S170、不执行S160中记载的产生相应的DEBUG信息的操作,并继续执行该程序中的后续内容。
具体的,在调试开关的当前取值为第二值的情况下,表示该程序在本次运行过程中不需要进行调试,因此,应忽略当前执行的调试关键点处设置的调试信息中的DEBUG命令,而继续执行程序中的非调试部分的程序代码。
S180、将DEBUG信息传输至程序调试客户端。
具体的,本实施例中的DEBUG信息可以在产生后立即向程序调试客户端发送,也可以在该程序执行完成时,将所有的DEBUG信息一起向程序调试客户端发送。
在Web开发过程中,DEBUG信息被传输至程序调试客户端的一个具体的例子为:在基于一个关键点处的调试信息产生了DEBUG信息后,即刻产生一HTTP消息,并将当前产生的DEBUG信息以Json格式承载于当前产生的该HTTP消息的头域中,之后,将该HTTP消息传输至程序调试客户端。通常情况下,程序调试客户端可以设置于运行该程序的设备(如服务器)中。另外,本实施例也可以采用其他格式(如自定义格式)将DEBUG信息承载于HTTP消息的头域中,相应的,在DEBUG信息的呈现过程中,也应采用相应的方式对DEBUG信息进行解析并显示。
在远程调试过程中,DEBUG信息被传输至程序调试客户端的一个具体的例子为:利用ShutDown函数在程序中注册一DEBUG信息传输函数,该DEBUG信息传输函数主要用于以异步队列的方式将DEBUG信息传输至调试中心(如调试中心管理后台);通常情况下,该调试中心与运行该程序的设备(如服务器)为两台相互独立设置的物理设备。该程序在执行过程中,被执行到的关键点处设置的调试信息产生的DEBUG信息被暂时存储起来,在该程序执行完成或者该程序执行了退出(EXIT)操作时,上述注册的DEBUG信息传输函数被调用,这样,该DEBUG信息传输函数将上述暂时存储的所有DEBUG信息以异步队列的方式传输至调试中心,调试中心在接收到DEBUG信息之后,将该DEBUG信息以Json格式或者其他格式(如自定义格式)承载于HTTP消息的头域中,然后,调试中心将该HTTP消息传输至程序调试客户端,由程序调试客户端将DEBUG信息呈现给维护人员。通常情况下,该程序调试客户端设置于调试中心所在的物理设备中。
由上述实施例的描述可知,本实施例的DEBUG调试方法并不属于单步调试技术;由于程序在开始运行时,会根据程序执行的参与主体的标识信息设置调试开关开启或者关闭,且程序中的各调试关键点处设置的调试信息会根据调试开关的当前取值来决定是否执行DEBUG信息的打印处理,因此,在程序上线后无需删除程序中的调试信息,并且不会对上线后的程序的正常运行产生影响;通过对程序执行的参与主体的标识信息是否属于参与主体标识集合进行判断,不仅可以方便的实现Web开发模式的程序调试,而且,也可以方便的获知针对
上报故障的用户的程序运行状态,从而可以非常方便的针对上报故障的用户实现远程程序调试;因此,无论是Web开发模式,还是远程程序调试模式,本实施例均可以实现问题的快速分析定位;另外,在Web开发模式下,由于本实施例的DEBUG信息可以以Json格式承载于HTTP消息的头域中传输至程序调试客户端,因此,不仅不会影响Web的开发效率,而且也不会破坏原有页面的BODY源代码结构,进而在存在AJAX请求时,不会出现数据结构错误的问题。
实施例二、Web开发过程中的DEBUG调试方法。下面结合图2对本实施例的方法进行说明。
在Web开发过程中,应预先在需要关注的关键点(如资源点)处设置调试信息,例如,在Memcache的increment操作处设置的调试信息可以如下所示:
其中,DAGGER_DEBUG为布尔型常量,主要用于控制后面的debug命令是否执行,即控制其后面设置的debug命令是否开启,DAGGER_DEBUG是本实施例中的调试开关。
在程序开始运行时,先获取当前服务器的IP地址,并判断该服务器的IP地址是否属于预先设定的服务器IP地址集合,之后,根据该判断的结果设置DAGGER_DEBUG的当前取值。由于本实施例是在Web开发环境中,因此,预先设定的服务器IP地址集合中设置有当前服务器的IP地址,从而当前服务器的IP地址一定属于预先设定的服务器IP地址集合,进而,DAGGER_DEBUG应被设置为表征调试开关开启的信息。
在用户访问相应的页面时,上述increment操作中设置的调试信息会产生相应的DEBUG信息,该DEBUG信息以基于Json格式的方式承载于HTTP消息的头域中,该HTTP消息传输至程序调试客户端,HTTP消息的头域中的DEBUG信息可以通过本地浏览器的控制台呈现给开发人员,如HTTP消息的头域中的DEBUG信息经Firephp工具解析后,开发人员可以从Firefox浏览器下方的firebug控制台看到相应的DEBUG信息。
上述increment操作中设置的调试信息产生的DEBUG信息的一个具体的例子可参见下述内容:
Mc_connect:127.0.0.1:11211;
Mc_set(dogger_abc),ttl(0):1
Mc_increment(dagger_abc):2
其中,mc_increment(dagger_abc):2是上述DEBUG命令输出的信息。
一个比较完整的DEBUG信息如图2所示。在图2中,数组部分是可以展开呈现的。开发人员通过阅读DEBUG信息可以充分了解程序中的各关键点的执行情况,从而可以对程序中的问题进行快速定位。
实施例三、远程程序调试过程中的DEBUG调试方法。下面结合图3对本实施例的方法进行说明。
在程序的入口处设置有用于打开远程程序调试的程序代码,该程序代码的一个具体的例子为:
也就是说,在用户ID为“303426817”或者为“254659189”时,该程序的远程程序调试功能被打开。上述用户ID也可以替换为用户IP地址等。
在程序开始运行时,应先获取用户ID(如从来自用户的HTTP消息中获取用户ID),并判断该用户ID是否属于预先设定的用户ID集合(即上述程序代码中的array()数组),之后,根据该判断的结果设置DAGGER_DEBUG的当前取值(如“true”or“false”)。由于本实施例是在远程程序调试环境中,因此,在接收到用户上报故障信息的情况下,应将该上报故障的用户的用户ID设置于array()数组中,从而上报故障的用户的用户ID一定会属于上述array()数组,进而,DAGGER_DEBUG应被设置为表征调试开关开启的信息,如true。
在本实施例中,由于该程序的远程程序调试功能被打开,因此,程序中各关键点处设置的调试信息均会产生DEBUG信息,这些DEBUG信息均被暂时存储起来,在程序执行完成时,所有被暂时存储的DEBUG信息以异步队列的方式被传输至调试中心,调试中心将其接收到DEBUG信息以Json格式承载于HTTP消息的头域中,然后,调试中心将HTTP消息传输至程序调试客户端。该程序调试客户端(如Firephp工具的客户端)在其调试信息按钮被维护人员点击时,本地浏览器的控制台为维护人员呈现DEBUG信息。本地浏览器的控制台为维护人员呈现的DEBUG信息的一个具体的例子如图3所示。
实施例四、DEBUG调试装置。下面结合图4对该装置进行详细说明。
图4中示出的装置主要包括:第一获取模块400、第一处理模块410、第二
获取模块420以及第二处理模块430。
第一获取模块400主要适于在包含有至少一个调试关键点的程序开始被执行时,获取程序执行的参与主体的标识信息。
具体的,本实施例中的程序是指基于PHP的程序,如使用PHP开发的基于Web服务的应用程序等;且该程序中的调试关键点可以是利用现有的工具自动设置的调试关键点,如利用FIREPHP工具在程序中自动设置的调试关键点;当然,程序中的调试关键点也可以是程序开发人员根据实际需求而在程序中自行手工设置的调试关键点。
通常情况下,程序中的数据库操作、Memcache操作、网络调用等资源类操作通常都会被设置为需要产生DEBUG信息的调试关键点。
本实施例可以对程序的入口进行相应的改进,如在程序的入口处新增设置第一获取模块400,以便于在程序开始被执行时,新增设置的第一获取模块400首先被执行,获取到程序执行的参与主体的标识信息。
本实施例中的程序执行的参与主体可以为执行该程序的服务器,也可以为:该程序当前所服务的用户;因此,本实施例中的程序执行的参与主体的标识信息可以为服务器的IP地址或者服务器ID,也可以为用户的IP地址或者用户的登录账号(即用户ID)等;该标识信息应能够唯一标识出程序执行的参与主体。
第一处理模块410主要适于判断参与主体的标识信息是否属于预先设定的参与主体标识集合;如果属于预先设定的参与主体标识集合,则将程序的调试开关的当前取值设置为第一值,否则,将程序的调试开关的当前取值设置为第二值;其中,第一值表示调试开关开启,第二值表示调试开关关闭;
具体的,本实施例中的参与主体标识集合是预先设置的,如在Web开发过程中,可以将开发环境中运行该程序的服务器的IP地址或者服务器的ID预先设置在该参与主体标识集合中;再如,在程序正式上线后,如果接收到某用户上报的故障信息,则可以将该用户的IP地址或者用户的ID设置在该参与主体标识集合中。
该参与主体标识集合可以由运行该程序的服务器进行维护,且该参与主体标识集合可以设置于该程序内部,也可以独立于该程序而设置。
该参与主体标识集合通常会包含有一个或者多个参与主体标识。第一处理模块410判断获取到的参与主体的标识信息是否属于预先设定的参与主体标识集合是指参与主体的标识信息是否与参与主体标识集合中的某个参与主体标识匹配;也就是说,如果第一处理模块410判断出第一获取模块400获取到的参与主体的标识信息与参与主体标识集合中的一个参与主体标识匹配,则表示该
参与主体的标识信息属于预先设定的参与主体标识集合,否则,表示该参与主体的标识信息不属于预先设定的参与主体标识集合。
在该参与主体标识集合为空的情况下,第一处理模块410判断出第一获取模块400获取到的参与主体的标识信息一定不属于该参与主体标识集合。
该程序的调试开关可以为常量,如布尔型常量或者数值型常量等,在第一处理模块410将该调试开关的当前值设置为第一值或者第二值后,在该程序的后续执行过程中,该调试开关的取值通常不会发生变化。另外,该程序的调试开关也可以表现为标志位等其他形式。
第二值与上述第一值不相同,如第一值为true时,第二值为false;再如,第一值为0,第二值为1。另外,在Web开发过程中,该调试开关的缺省值可以设置为第一值,而在程序上线后,该调试开关的缺省值可以设置为第二值。第一值表示调试开关开启,第二值表示调试开关关闭。
另外,需要说明的是,上述第一获取模块400和第一处理模块410均应设置于程序的入口处。
第二获取模块420主要适于在程序被执行到每一调试关键点时,均获取调试开关的当前取值。
具体的,第二获取模块420的数量可以为多个,且程序中的每个调试关键点处均会设置一第二获取模块420;这样,在程序每执行到一个调试关键点处时,该调试关键点处设置的第二获取模块420均会被执行,且均会先获取调试开关(如上述布尔型常量)的当前取值。
第二处理模块430主要适于判断调试开关的当前取值;如果调试开关的当前取值为第一值,则根据当前执行的调试关键点处设置的调试信息产生相应的DEBUG信息,继续执行该程序,且该DEBUG信息被传输至程序调试客户端;如果调试开关的当前取值为第二值,则不执行上述DEBUG信息的产生操作,并继续执行该程序。
具体的,调试关键点处设置的第二处理模块430中的调试信息包括DEBUG命令,该DEBUG命令用于产生关键点的日志(即该DEBUG命令用于打印关键点的日志),从而产生相应的DEBUG信息。
第二处理模块430产生的DEBUG信息可以包括:请求URL信息、POST信息、Cookie信息、程序执行debug信息、页面返回内容以及执行时间等等。
在调试开关的当前取值为第二值的情况下,表示该程序在本次运行过程中不需要进行调试,因此,应忽略当前执行的调试关键点处设置的第二处理模块430中的调试信息中的DEBUG命令,从而可以继续执行程序中的非调试部分的程序代码。
第二处理模块430可以在DEBUG信息产生后,立即向程序调试客户端发送,也可以在该程序执行完成时,将所有的DEBUG信息一起向程序调试客户端发送。
在Web开发过程中,第二处理模块430将DEBUG信息传输至程序调试客户端的一个具体的例子为:在基于一个关键点处的调试信息产生了DEBUG信息后,第二处理模块430即刻产生一HTTP消息,并将当前产生的DEBUG信息以Json格式承载于当前产生的该HTTP消息的头域中,之后,第二处理模块430将该HTTP消息传输至程序调试客户端。另外,第二处理模块430也可以采用其他格式(如自定义格式)将DEBUG信息承载于HTTP消息的头域中,相应的,在DEBUG信息的呈现过程中,也应采用相应的方式对DEBUG信息进行解析并显示。
在远程调试过程中,第二处理模块430将DEBUG信息传输至程序调试客户端的一个具体的例子为:利用ShutDown函数在程序中注册一DEBUG信息传输函数(该DEBUG信息传输函数属于第二处理模块430),该DEBUG信息传输函数主要用于以异步队列的方式将DEBUG信息传输至调试中心(如调试中心管理后台);通常情况下,该调试中心与运行该程序的设备(如服务器)为两台相互独立设置的物理设备。该程序在执行过程中,被执行到的关键点处设置的调试信息产生的DEBUG信息被第二处理模块430暂时存储起来,在该程序执行完成或者该程序执行了退出(EXIT)操作时,上述注册的DEBUG信息传输函数被调用,这样,该DEBUG信息传输函数将上述第二处理模块430暂时存储的所有DEBUG信息以异步队列的方式传输至调试中心,调试中心在接收到DEBUG信息之后,将该DEBUG信息以Json格式或者其他格式(如自定义格式)承载于HTTP消息的头域中,然后,调试中心将该HTTP消息传输至程序调试客户端,由程序调试客户端将DEBUG信息呈现给维护人员。
A1、一种DEBUG调试方法,其包括:
在包含有至少一个调试关键点的程序开始被执行时,获取程序执行的参与主体的标识信息;
判断所述参与主体的标识信息是否属于预先设定的参与主体标识集合;
如果属于预先设定的参与主体标识集合,则将所述程序的调试开关的当前取值设置为第一值,否则,将所述程序的调试开关的当前取值设置为第二值;其中,所述第一值表示调试开关开启,所述第二值表示调试开关关闭;
在所述程序被执行到每一调试关键点时,均获取调试开关的当前取值;
判断所述调试开关的当前取值;
如果为第一值,则根据当前执行的调试关键点处设置的调试信息产生相应的DEBUG信息,继续执行所述程序,且所述DEBUG信息被传输至程序调试客户端;如果为第二值,则不执行上述DEBUG信息的产生操作,并继续执行所述程序。
A2、如A1所述的方法,其中,所述程序执行的参与主体包括:执行所述程序的服务器或者所述程序当前所服务的用户。
A3、如A2所述的方法,其中,所述程序执行的参与主体的标识信息包括:服务器的IP地址、用户的IP地址或者用户的登录账号。
A4、如A1所述的方法,其中,所述程序的调试开关为常量。
A5、如A1所述的方法,其中,在Web开发过程中,所述DEBUG信息被传输至程序调试客户端包括:
将所述DEBUG信息承载于HTTP消息的头域中,并将所述HTTP消息传输至程序调试客户端。
A6、如A1所述的方法,其中,在远程调试过程中,所述DEBUG信息被传输至程序调试客户端包括:
将所述DEBUG信息以异步队列的方式传输至调试中心,且所述调试中心将接收到的DEBUG信息承载于HTTP消息的头域中,并将所述HTTP消息传输至程序调试客户端。
A7、如A5或A6所述的方法,其中,所述DEBUG信息以Json格式承载于HTTP消息的头域中。
A8、如A7所述的方法,其中,所述将所述DEBUG信息以异步队列的方式传输至调试中心包括:
在所述程序执行完成或者执行了退出操作时,调用通过ShutDown函数注册的DEBUG信息传输函数,所述DEBUG信息传输函数将所述DEBUG信息以异步队列的方式传输至调试中心。
A9、一种DEBUG调试装置,其包括:
第一获取模块,适于在包含有至少一个调试关键点的程序开始被执行时,获取程序执行的参与主体的标识信息;
第一处理模块,适于判断所述参与主体的标识信息是否属于预先设定的参与主体标识集合;如果属于预先设定的参与主体标识集合,则将所述程序的调试开关的当前取值设置为第一值,否则,将所述程序的调试开关的当前取值设置为第二值;其中,所述第一值表示调试开关开启,所述第二值表示调试开关关闭;
第二获取模块,适于在所述程序被执行到每一调试关键点时,均获取调试开关的当前取值;
第二处理模块,判断所述调试开关的当前取值;如果为第一值,则根据当前执行的调试关键点处设置的调试信息产生相应的DEBUG信息,继续执行所述程序,且所述DEBUG信息被传输至程序调试客户端;如果为第二值,则不执行
上述DEBUG信息的产生操作,并继续执行所述程序。
A10、如A9所述的装置,其中,该程序执行的参与主体包括:执行所述程序的服务器或者所述程序当前所服务的用户。
A11、如A10所述的装置,其中,所述程序执行的参与主体的标识信息包括:服务器的IP地址、用户的IP地址或者用户的登录账号。
A12、如A9所述的装置,其中,所述程序的调试开关为常量。
A13、如A9所述的装置,其中,在Web开发过程中,所述DEBUG信息被传输至程序调试客户端包括:
第二处理模块将所述DEBUG信息承载于HTTP消息的头域中,并将所述HTTP消息传输至程序调试客户端。
A14、如A9所述的装置,其中,在远程调试过程中,所述DEBUG信息被传输至程序调试客户端包括:
第二处理模块将所述DEBUG信息以异步队列的方式传输至调试中心,且所述调试中心将接收到的DEBUG信息承载于HTTP消息的头域中,并将所述HTTP消息传输至程序调试客户端。
A15、如A13或A14所述的装置,其中,所述DEBUG信息以Json格式承载于HTTP消息的头域中。
A16、如A14所述的装置,其中,所述第二处理模块将所述DEBUG信息以异步队列的方式传输至调试中心包括:
在所述程序执行完成或者执行了退出操作时,第二处理模块调用通过ShutDown函数注册的DEBUG信息传输函数,所述DEBUG信息传输函数将所述DEBUG信息以异步队列的方式传输至调试中心。
在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。
类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确
记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。
本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。
此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。
本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的DEBUG调试装置中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(如计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网网站上下载得到,或者在载体信号上提供,或者以任何其他形式提供。
例如,图5示出了可以实现本发明的DEBUG调试方法的电子设备。该电子设备传统上包括处理器1210和以存储器1220形式的计算机程序产品或者计算机可读介质。存储器1220可以是诸如闪存、EEPROM(电可擦除可编程只读存储器)、EPROM、硬盘或者ROM之类的电子存储器。存储器1220具有用于执行上述方法中的任何方法步骤的程序代码1231的存储空间1230。例如,用于程序代码的存储空间1230可以包括分别用于实现上面的方法中的各种步骤的各个程序代码1231。这些程序代码可以从一个或者多个计算机程序产品中读出或者写入到这一个或者多个计算机程序产品中。这些计算机程序产品包括诸如硬盘,紧致盘(CD)、存储卡或者软盘之类的程序代码载体。这样的计算机程序产品通常为
如参考图6所述的便携式或者固定存储单元。该存储单元可以具有与图5的电子设备中的存储器1220类似布置的存储段或者存储空间等。程序代码可以例如以适当形式进行压缩。通常,存储单元包括用于执行根据本发明的方法步骤的程序1231’,即可以由例如诸如1210之类的处理器读取的代码,这些代码当由电子设备运行时,导致该电子设备执行上面所描述的方法中的各个步骤。
本文中所称的“一个实施例”、“实施例”或者“一个或者多个实施例”意味着,结合实施例描述的特定特征、结构或者特性包括在本发明的至少一个实施例中。此外,请注意,这里“在一个实施例中”的词语例子不一定全指同一个实施例。
在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下被实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。
应该注意的是,上述实施例对本发明进行的详细说明并不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”或“包括”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。
此外,还应当注意,本说明书中使用的语言主要是为了可读性和教导的目的而选择的,而不是为了解释或者限定本发明的主题而选择的。因此,在不偏离所附权利要求书的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。对于本发明的范围,对本发明所做的公开是说明性的,而非限制性的,本发明的范围由所附权利要求书限定。
Claims (18)
- 一种DEBUG调试方法,其包括:在包含有至少一个调试关键点的程序开始被执行时,获取程序执行的参与主体的标识信息;判断所述参与主体的标识信息是否属于预先设定的参与主体标识集合;如果属于预先设定的参与主体标识集合,则将所述程序的调试开关的当前取值设置为第一值,否则,将所述程序的调试开关的当前取值设置为第二值;其中,所述第一值表示调试开关开启,所述第二值表示调试开关关闭;在所述程序被执行到每一调试关键点时,均获取调试开关的当前取值;判断所述调试开关的当前取值;如果为第一值,则根据当前执行的调试关键点处设置的调试信息产生相应的DEBUG信息,继续执行所述程序,且所述DEBUG信息被传输至程序调试客户端;如果为第二值,则不执行上述DEBUG信息的产生操作,并继续执行所述程序。
- 如权利要求1所述的方法,其中,所述程序执行的参与主体包括:执行所述程序的服务器或者所述程序当前所服务的用户。
- 如权利要求2所述的方法,其中,所述程序执行的参与主体的标识信息包括:服务器的IP地址、用户的IP地址或者用户的登录账号。
- 如权利要求1所述的方法,其中,所述程序的调试开关为常量。
- 如权利要求1所述的方法,其中,在Web开发过程中,所述DEBUG信息被传输至程序调试客户端包括:将所述DEBUG信息承载于HTTP消息的头域中,并将所述HTTP消息传输至程序调试客户端。
- 如权利要求1所述的方法,其中,在远程调试过程中,所述DEBUG信息被传输至程序调试客户端包括:将所述DEBUG信息以异步队列的方式传输至调试中心,且所述调试中心将接收到的DEBUG信息承载于HTTP消息的头域中,并将所述HTTP消息传输至程序调试客户端。
- 如权利要求5或6所述的方法,其中,所述DEBUG信息以Json格式承载于HTTP消息的头域中。
- 如权利要求7所述的方法,其中,所述将所述DEBUG信息以异步队列的方式传输至调试中心包括:在所述程序执行完成或者执行了退出操作时,调用通过ShutDown函数注册的DEBUG信息传输函数,所述DEBUG信息传输函数将所述DEBUG信息以异步队列的方式传输至调试中心。
- 一种DEBUG调试装置,其包括:第一获取模块,适于在包含有至少一个调试关键点的程序开始被执行时,获取程序执行的参与主体的标识信息;第一处理模块,适于判断所述参与主体的标识信息是否属于预先设定的参与主体标识集合;如果属于预先设定的参与主体标识集合,则将所述程序的调试开关的当前取值设置为第一值,否则,将所述程序的调试开关的当前取值设置为第二值;其中,所述第一值表示调试开关开启,所述第二值表示调试开关关闭;第二获取模块,适于在所述程序被执行到每一调试关键点时,均获取调试开关的当前取值;第二处理模块,判断所述调试开关的当前取值;如果为第一值,则根据当前执行的调试关键点处设置的调试信息产生相应的DEBUG信息,继续执行所述程序,且所述DEBUG信息被传输至程序调试客户端;如果为第二值,则不执行上述DEBUG信息的产生操作,并继续执行所述程序。
- 如权利要求9所述的装置,其中,该程序执行的参与主体包括;执行所述程序的服务器或者所述程序当前所服务的用户。
- 如权利要求10所述的装置,其中,所述程序执行的参与主体的标识信息包括:服务器的IP地址、用户的IP地址或者用户的登录账号。
- 如权利要求9所述的装置,其中,所述程序的调试开关为常量。
- 如权利要求9所述的装置,其中,在Web开发过程中,所述DEBUG信息被传输至程序调试客户端包括:第二处理模块将所述DEBUG信息承载于HTTP消息的头域中,并将所述HTTP消息传输至程序调试客户端。
- 如权利要求9所述的装置,其中,在远程调试过程中,所述DEBUG信息被传输至程序调试客户端包括:第二处理模块将所述DEBUG信息以异步队列的方式传输至调试中心,且所述调试中心将接收到的DEBUG信息承载于HTTP消息的头域中,并将所述HTTP消息传输至程序调试客户端。
- 如权利要求13或14所述的装置,其中,所述DEBUG信息以Json格式承载于HTTP消息的头域中。
- 如权利要求14所述的装置,其中,所述第二处理模块将所述DEBUG信息以异步队列的方式传输至调试中心包括:在所述程序执行完成或者执行了退出操作时,第二处理模块调用通过ShutDown函数注册的DEBUG信息传输函数,所述DEBUG信息传输函数将所述 DEBUG信息以异步队列的方式传输至调试中心。
- 一种计算机程序,包括计算机可读代码,当电子设备运行所述计算机可读代码运行时,导致权利要求1-8中的任一项权利要求所述的DEBUG调试方法被执行。
- 一种计算机可读介质,其中存储了如权利要求17所述的计算机程序。
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310540974.4 | 2013-11-05 | ||
CN201310540974.4A CN103577326B (zh) | 2013-11-05 | 2013-11-05 | Debug调试方法和装置 |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2015067171A1 true WO2015067171A1 (zh) | 2015-05-14 |
Family
ID=50049150
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2014/090306 WO2015067171A1 (zh) | 2013-11-05 | 2014-11-05 | Debug调试方法和装置 |
Country Status (2)
Country | Link |
---|---|
CN (1) | CN103577326B (zh) |
WO (1) | WO2015067171A1 (zh) |
Families Citing this family (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103577326B (zh) * | 2013-11-05 | 2016-06-29 | 北京奇虎科技有限公司 | Debug调试方法和装置 |
CN110287112B (zh) * | 2019-06-25 | 2023-10-20 | 网易(杭州)网络有限公司 | 客户端的维护方法、装置及可读存储介质 |
CN110928753A (zh) * | 2019-11-19 | 2020-03-27 | 深圳前海环融联易信息科技服务有限公司 | 浏览器控制台日志输出的控制方法、装置、计算机设备及计算机可读存储介质 |
CN113254286B (zh) * | 2021-05-28 | 2021-11-19 | 苏州浪潮智能科技有限公司 | 一种服务器的日志输出方法、系统及相关装置 |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101309475A (zh) * | 2007-05-18 | 2008-11-19 | 中兴通讯股份有限公司 | 一种通讯终端调试和发布软件版本合一的方法 |
CN101482848A (zh) * | 2009-02-03 | 2009-07-15 | 中兴通讯股份有限公司 | 一种在嵌入式软件运行状态下的动态调试方法及系统 |
US20110088015A1 (en) * | 2001-07-10 | 2011-04-14 | Ryan Shillington | System and method for remotely debugging application programs |
CN103577326A (zh) * | 2013-11-05 | 2014-02-12 | 北京奇虎科技有限公司 | Debug调试方法和装置 |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7478367B2 (en) * | 2005-01-11 | 2009-01-13 | International Business Machines Corporation | Dynamic source code analyzer |
CN102214137B (zh) * | 2010-04-06 | 2014-01-22 | 华为技术有限公司 | 调试方法和调试设备 |
US8856742B2 (en) * | 2010-06-11 | 2014-10-07 | International Business Machines Corporation | Distributed debugging |
CN103049385B (zh) * | 2012-12-29 | 2015-09-09 | 百度在线网络技术(北京)有限公司 | 一种云环境下的php代码调试方法及系统 |
-
2013
- 2013-11-05 CN CN201310540974.4A patent/CN103577326B/zh not_active Expired - Fee Related
-
2014
- 2014-11-05 WO PCT/CN2014/090306 patent/WO2015067171A1/zh active Application Filing
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20110088015A1 (en) * | 2001-07-10 | 2011-04-14 | Ryan Shillington | System and method for remotely debugging application programs |
CN101309475A (zh) * | 2007-05-18 | 2008-11-19 | 中兴通讯股份有限公司 | 一种通讯终端调试和发布软件版本合一的方法 |
CN101482848A (zh) * | 2009-02-03 | 2009-07-15 | 中兴通讯股份有限公司 | 一种在嵌入式软件运行状态下的动态调试方法及系统 |
CN103577326A (zh) * | 2013-11-05 | 2014-02-12 | 北京奇虎科技有限公司 | Debug调试方法和装置 |
Also Published As
Publication number | Publication date |
---|---|
CN103577326B (zh) | 2016-06-29 |
CN103577326A (zh) | 2014-02-12 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107122297B (zh) | 用于测试接口的请求消息生成的方法及设备 | |
CN107122258B (zh) | 用于测试接口的状态码校验的方法及设备 | |
CN105099811A (zh) | 一种接口测试方法和装置 | |
JP6564532B2 (ja) | クライアント−サーバトランザクションをアノテーションするためのシステム及び方法 | |
WO2019071891A1 (zh) | 代码覆盖率分析方法及应用服务器 | |
WO2015103938A1 (zh) | 一种加载网站点评信息的方法和浏览器客户端 | |
CN110221948B (zh) | 测试脚本生成方法、装置、计算机装置及存储介质 | |
CN111460356B (zh) | 一种自动登录方法、装置、介质和设备 | |
CN110069413B (zh) | 测试数据通信、测试方法、装置、设备及存储介质 | |
WO2015067171A1 (zh) | Debug调试方法和装置 | |
CN111611140B (zh) | 埋点数据的上报验证方法、装置、电子设备及存储介质 | |
US10705949B2 (en) | Evaluation of library test suites using mutation testing | |
CN110704390A (zh) | 获取服务器维护脚本的方法、装置、电子设备及介质 | |
CN108074033A (zh) | 指标数据的处理方法、系统、电子设备和存储介质 | |
CN111949545A (zh) | 自动化测试方法、系统、服务器及存储介质 | |
WO2018121266A1 (zh) | 一种应用程序获取方法和装置以及一种终端设备 | |
CN112115475A (zh) | 越权漏洞的检测方法、装置、存储介质及计算机设备 | |
CN111143650B (zh) | 获取页面数据的方法、装置、介质及电子设备 | |
CN112181485B (zh) | 脚本执行方法、装置、电子设备及存储介质 | |
CN113362173A (zh) | 防重机制验证方法、验证系统、电子设备及存储介质 | |
CN112947959A (zh) | 一种ai服务平台的更新方法、装置、服务器及存储介质 | |
CN111241821B (zh) | 确定用户的行为特征的方法和装置 | |
CN111240948A (zh) | 一种体验数据处理方法、装置、计算机设备及存储介质 | |
CN113238940B (zh) | 一种接口测试结果的比对方法、装置、设备和存储介质 | |
US11500764B2 (en) | Human interactions with artificial intelligence (AI)-based testing tool |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 14860850 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
122 | Ep: pct application non-entry in european phase |
Ref document number: 14860850 Country of ref document: EP Kind code of ref document: A1 |