Program debugging method and device and storage medium
Through cross-language debugging technology, threads from different languages automatically execute debugging instructions and generate debug interfaces, solving the problem of manually positioning object code in cross-language debugging and improving the efficiency of program debugging.
Patent Information
- Application Number
- CN202410091355.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-22
- Publication Date
- 2025-07-25
Smart Images

Figure CN120371684A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer technology, and particularly relates to a method, device, and storage medium for debugging a program. Background Art
[0002] An application program, as the main carrier of today's electronic services, the length of its development cycle directly affects the popularization and application of electronic services. During the process of developing an application program, in order to ensure the correctness of the program's operation, it is often necessary to debug the program. Therefore, how to efficiently debug the program determines the development efficiency of the application program. During the process of developing a program, multiple programming languages can be used to write the same program. Existing program debugging technologies generally run the program on a test machine and obtain feedback information during the program's operation on the test machine through a monitoring terminal to determine whether the program operates as expected.
[0003] However, when debugging a program containing multiple programming languages, since the debugging threads used by different programming languages are different, if a certain piece of code in the program calls a function of a programming language different from this code, the user needs to manually search for and open the function in the function library to continue the debugging operation of the function, thereby greatly reducing the debugging efficiency of programs with multiple programming languages. Summary of the Invention
[0004] Embodiments of this application provide a method, device, and storage medium for debugging a program, which can solve the problems of existing debugging technologies that when the debugging operation involves a cross-language scenario, the user needs to manually locate the code position of the target code in the function to continue debugging the function, with a large operation difficulty and low debugging efficiency.
[0005] In a first aspect, embodiments of this application provide a method for debugging a program, which is applied to a first device. The method for debugging the program includes:
[0006] During the process of debugging a target program through a first thread corresponding to a first programming language, receiving a debugging instruction about a first piece of code in the target program sent by a second device; the debugging instruction is generated based on a debugging operation initiated by a user within a first debugging interface corresponding to the first programming language displayed on the second device; the first piece of code is written based on the first programming language;
[0007] If the second programming language of a second piece of code is different from the first programming language, then execute the debugging instruction through a second thread corresponding to the second programming language; the second piece of code is the target code corresponding to the debugging instruction;
[0008] Send the debugging information corresponding to the debugging instruction to the second device through the second thread, so that the second device generates a second debugging interface corresponding to the second programming language including the second code according to the debugging information; the debugging information is used to determine the code address of the second code.
[0009] Implementing the embodiments of the present application has the following beneficial effects: The second device can send the debugging instruction for the first code in the target program to the first device. Before the first device responds to the debugging instruction, it determines whether the programming language of the second code corresponding to the debugging instruction is the same as the programming language of the first code. If the programming languages of the two are different, the above debugging instruction is executed through the second thread corresponding to the second code, and the code address corresponding to the second code is fed back to the second device through the second thread, so that a second debugging interface including the second code can be displayed in the second device, realizing the automatic switching to the debugging interface of the corresponding language during cross-language debugging. Compared with the existing program debugging technology, in the process of debugging a program written in multiple languages in the embodiments of the present application, when the programming language of the target code corresponding to the debugging operation is inconsistent with the programming language of the debugging interface corresponding to the debugging operation, the user does not need to locate the position of the function where the target code is located. Instead, the first device can automatically switch to the thread of the corresponding programming language to execute the above debugging instruction and feed back the corresponding code address to the second device to automatically generate the debugging interface of the corresponding program code, improving the debugging efficiency of the program written in multiple languages.
[0010] In a possible implementation manner of the first aspect, the if the second programming language of the second code is different from the first programming language, then the debugging instruction is executed through the second thread corresponding to the second programming language, including:
[0011] If the debugging instruction is a function step-in instruction, the first function referenced by the first code is determined through the second thread;
[0012] Jump to the second code through the second thread according to the first code address of the first function; the second code is the first line code of the first function.
[0013] In a possible implementation manner of the first aspect, the if the second programming language of the second code is different from the first programming language, then the debugging instruction is executed through the second thread corresponding to the second programming language, including:
[0014] If the debugging instruction is a function step-out instruction, the third code that references the second function where the first code is located is determined through the second thread;
[0015] Jump to the second code through a second thread according to the second code address of the third code; the second code is the next line of code of the third code.
[0016] In a possible implementation manner of the first aspect, if the second programming language of the second code is different from the first programming language, then executing the debug instruction through a second thread corresponding to the second programming language includes:
[0017] If the second programming language is different from the first programming language, stop the debug task of the first thread through a cross-language interface;
[0018] Send a wake-up notification to the second thread through the cross-language interface to control the second thread to execute the debug instruction.
[0019] In a possible implementation manner of the first aspect, before the step of stopping the debug task of the first thread through the cross-language interface if the second programming language is different from the first programming language, further includes:
[0020] In response to a mode setting instruction, set the debug mode to a cross-language debug mode;
[0021] The step of stopping the debug task of the first thread through the cross-language interface if the second programming language is different from the first programming language includes:
[0022] If it is detected that the second programming language is different from the first programming language in the cross-language debug mode, stop the debug task of the first thread through the cross-language interface.
[0023] In a possible implementation manner of the first aspect, the first programming language is JavaScript; the second programming language is C / C++;
[0024] Or the first programming language is C / C++; the second programming language is JavaScript.
[0025] In a possible implementation manner of the first aspect, before the step of executing the debug instruction through a second thread corresponding to the second programming language if the second programming language of the second code is different from the first programming language, further includes:
[0026] Receive a custom function range sent by the second device;
[0027] The step of executing the debug instruction through a second thread corresponding to the second programming language if the second programming language of the second code is different from the first programming language includes:
[0028] Invoke a cross - language interface to determine whether the function where the second code is located is within the scope of the custom function;
[0029] If the function where the second code is located is within the scope of the custom function, execute the debugging instruction through the second thread.
[0030] In a possible implementation manner of the first aspect, the scope of the custom function includes: the code address range of the custom function;
[0031] The step of invoking the cross - language interface to determine whether the function where the second code is located is within the scope of the custom function includes:
[0032] Invoke the cross - language interface to determine whether the code address of the second code is within the code address range of the custom function;
[0033] The step of if the function where the second code is located is within the scope of the custom function, then execute the debugging instruction through the second thread includes:
[0034] If the code address of the second code is within the code address range of the custom function, execute the debugging instruction through the second thread.
[0035] In a second aspect, a debugging device for a program, the debugging device includes:
[0036] A receiving unit, configured to receive a debugging instruction about the first code in the target program during the process of debugging the target program through a first thread corresponding to a first programming language; the debugging instruction is generated based on a debugging operation initiated by a user in a first debugging interface corresponding to the first programming language displayed on the second device; the first code is written based on the first programming language;
[0037] A debugging unit, configured to if the second programming language of the second code is different from the first programming language, execute the debugging instruction through a second thread corresponding to the second programming language; the second code is the target code corresponding to the debugging instruction;
[0038] A sending unit, configured to send the debugging information corresponding to the debugging instruction to the second device through the second thread, so that the second device generates a second debugging interface corresponding to the second programming language including the second code according to the debugging information; the debugging information is used to determine the code address of the second code.
[0039] In a possible implementation manner of the second aspect, the step of if the second programming language of the second code is different from the first programming language, then execute the debugging instruction through a second thread corresponding to the second programming language includes:
[0040] A step instruction response unit, configured to determine a first function referenced by the first code through the second thread if the debug instruction is a function step instruction;
[0041] A first jump unit, configured to jump to the second code through the second thread according to the first code address of the first function; the second code is the first line of code of the first function.
[0042] In a possible implementation manner of the second aspect, the debug unit includes:
[0043] A step-out instruction response unit, configured to determine the third code of the second function referencing the first code through the second thread if the debug instruction is a function step-out instruction;
[0044] A second jump unit, configured to jump to the second code through the second thread according to the second code address of the third code; the second code is the next line of code of the third code.
[0045] In a possible implementation manner of the second aspect, the debug unit includes:
[0046] A thread stop unit, configured to stop the debug task of the first thread through a cross-language interface if the second programming language is different from the first programming language;
[0047] A thread start unit, configured to send an arousal notification to the second thread through the cross-language interface to control the second thread to execute the debug instruction.
[0048] In a possible implementation manner of the second aspect, the debug device further includes:
[0049] A mode setting unit, configured to set the debug mode to a cross-language debug mode in response to a mode setting instruction;
[0050] The debug unit includes:
[0051] A cross-language debug unit, configured to stop the debug task of the first thread through a cross-language interface if it is detected that the second programming language is different from the first programming language in the cross-language debug mode.
[0052] In a possible implementation manner of the second aspect, the first programming language is the JavaScript language; the second programming language is the C / C++ language;
[0053] Or the first programming language is the C / C++ language; the second programming language is the JavaScript language.
[0054] In a possible implementation of the second aspect, the debugging device further includes:
[0055] A function range receiving unit, configured to receive a custom function range sent by the second device;
[0056] The debugging unit includes:
[0057] A function range determination unit, configured to call a cross-language interface to determine whether the function where the second code is located is within the custom function range;
[0058] A cross-language determination unit, configured to, if the function where the second code is located is within the custom function range, execute the debugging instruction through the second thread.
[0059] In a possible implementation of the second aspect, the custom function range includes: a code address range of a custom function;
[0060] The function range determination unit is configured to: call the cross-language interface to determine whether the code address of the second code is within the code address range of the custom function;
[0061] The cross-language determination unit is configured to: if the code address of the second code is within the code address range of the custom function, execute the debugging instruction through the second thread.
[0062] In a third aspect, an embodiment of the present application provides a program debugging method, which is applied to a second terminal. The program debugging method includes:
[0063] In response to a debugging operation initiated by a user for a first code of a target program, send a debugging instruction corresponding to the debugging operation to a first device; the first code is displayed in a first debugging interface of a first programming language corresponding to the first code; the first device debugs the target program in a first thread during the process of the second device displaying the first debugging interface;
[0064] Receive debugging information sent by the first device; the debugging information is obtained after the second device executes the debugging instruction on the target program; the debugging information is sent by the first device through a second thread corresponding to the second programming language when it detects that the second programming language of the second code is different from the first programming language; the second code is the target code corresponding to the debugging instruction; the debugging information is used to determine the code address of the second code;
[0065] Generate a second debugging interface corresponding to the second programming language including the second code according to the code address.
[0066] In a possible implementation of the third aspect, sending a debugging instruction corresponding to the debugging operation to the first device in response to the user's debugging operation on the first code of the target program includes:
[0067] In response to the user's function stepping operation on the first code of the target program, sending a function stepping instruction to the second device; the first code is the code that references the first function;
[0068] Receiving the debugging information sent by the first device includes:
[0069] Receiving the debugging information through the second thread of the first device; the debugging information includes the first code address corresponding to the first line of code of the first function;
[0070] Generating a second debugging interface in the second programming language including the second code according to the code address includes:
[0071] Displaying the second code in the second debugging interface according to the first code address; the second code is the first line of code of the first function.
[0072] In a possible implementation of the third aspect, sending a debugging instruction corresponding to the debugging operation to the first device in response to the user's debugging operation on the first code of the target program includes:
[0073] In response to the user's function stepping out operation on the first code of the target program, sending a function stepping out instruction to the second device; the first code is the code within the second function; the second function is referenced by the third code;
[0074] Receiving the debugging information sent by the first device includes:
[0075] Receiving the debugging information through the second thread of the first device; the debugging information includes the second code address of the next line of code of the third code;
[0076] Generating a second debugging interface in the second programming language including the second code according to the code address includes:
[0077] Displaying the second code in the second debugging interface according to the second code address; the second code is the next line of code of the third code.
[0078] In a possible implementation of the third aspect, before sending a debugging instruction corresponding to the debugging operation to the first device in response to the user's debugging operation on the first code of the target program, it further includes:
[0079] In response to a mode setting operation initiated by a user, generate a mode setting instruction for setting a cross - language debugging mode;
[0080] Send the mode setting instruction to a first device, so that when the first device detects that the second programming language is different from the first programming language, it controls a second thread to send debugging information through a cross - language interface.
[0081] In a possible implementation manner of the third aspect, the first programming language is the JavaScript language; the second programming language is the C / C++ language;
[0082] Or the first programming language is the C / C++ language; the second programming language is the JavaScript language.
[0083] In a possible implementation manner of the third aspect, before sending the debugging instruction corresponding to the debugging operation to the first device in response to the user's debugging operation on the first code of the target program, it further includes:
[0084] Send a custom function range to the first device, so that when the first device determines through the cross - language interface that the function where the second code is located is within the custom function range, it sends debugging information to the second device through the second thread.
[0085] In a possible implementation manner of the third aspect, the custom function range includes: the code address range of the custom function;
[0086] The sending the custom function range to the first device includes:
[0087] Send the code address range of the custom function to the first device, so that when the first device determines through the cross - language interface that the code address of the second code is within the code address range of the custom function, it sends debugging information to the second device through the second thread.
[0088] In a fourth aspect, an embodiment of the present application provides a debugging device for a program, including:
[0089] An operation response unit, configured to send a debugging instruction corresponding to the debugging operation to a first device in response to the user's debugging operation on the first code of the target program; the first code is displayed in a first debugging interface of the first programming language corresponding to the first code; the first device debugs the target program with a first thread during the process of the second device displaying the first debugging interface;
[0090] A receiving unit, configured to receive the debugging information sent by the first device; the debugging information is obtained after the second device executes the debugging instruction on the target program; the debugging information is sent by the second thread corresponding to the second programming language when the first device detects that the second programming language of the second code is different from the first programming language; the second code is the target code corresponding to the debugging instruction; the debugging information is used to determine the code address of the second code.
[0091] A display unit, configured to generate a second debugging interface corresponding to the second programming language including the second code according to the code address.
[0092] In a possible implementation manner of the fourth aspect, the operation response unit includes:
[0093] A step operation unit, configured to send a function step instruction to the second device in response to a function step operation initiated by a user for a first code of a target program; the first code is the code that references a first function.
[0094] The receiving unit includes:
[0095] A first address receiving unit, configured to receive the debugging information through the second thread of the first device; the debugging information includes a first code address corresponding to the first line of code of the first function.
[0096] The display unit includes:
[0097] A first display unit, configured to display the second code in the second debugging interface according to the first code address; the second code is the first line of code of the first function.
[0098] In a possible implementation manner of the fourth aspect, the operation response unit includes:
[0099] A step-out operation unit, configured to send a function step-out instruction to the second device in response to a function step-out operation initiated by a user for a first code of a target program; the first code is the code within a second function; the second function is referenced by a third code.
[0100] The receiving unit includes:
[0101] A second address receiving unit, configured to receive the debugging information through the second thread of the first device; the debugging information includes a second code address of the next line of code of the third code.
[0102] The display unit includes:
[0103] A second display unit, configured to display the second code in the second debugging interface according to the second code address; the second code is the next line of code of the third code.
[0104] In a possible implementation manner of the fourth aspect, the debugging device further includes:
[0105] A mode setting unit, configured to generate a mode setting instruction for setting a cross-language debugging mode in response to a mode setting operation initiated by a user;
[0106] A mode instruction sending unit, configured to send the mode setting instruction to a first device, so that when the first device detects that the second programming language is different from the first programming language, it controls a second thread to send debugging information through a cross-language interface.
[0107] In a possible implementation manner of the fourth aspect, the first programming language is the JavaScript language; the second programming language is the C / C++ language;
[0108] Or the first programming language is the C / C++ language; the second programming language is the JavaScript language.
[0109] In a possible implementation manner of the fourth aspect, the debugging device further includes:
[0110] A function range sending unit, configured to send a custom function range to the first device, so that when the first device determines, through a cross-language interface, that the function where the second code is located is within the custom function range, it sends debugging information to a second device through the second thread.
[0111] In a possible implementation manner of the fourth aspect, the custom function range includes: a code address range of a custom function;
[0112] The function range sending unit includes:
[0113] An address range sending unit, configured to send the code address range of the custom function to the first device, so that when the first device determines, through a cross-language interface, that the code address of the second code is within the code address range of the custom function, it sends debugging information to a second device through the second thread.
[0114] In a fifth aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor, and a program stored in the memory, and when the processor executes the program, it implements the steps of the debugging method described in any one of the first aspect above, or the steps of the debugging method described in any one of the third aspect above.
[0115] Sixth aspect, an embodiment of the present application provides a readable storage medium storing a program, which when executed by a processor implements the steps of the debugging method described in any one of the above first aspects, or the steps of the debugging method described in any one of the above third aspects.
[0116] Seventh aspect, an embodiment of the present application provides a program product, which when running on a device causes the device to execute the steps of the debugging method described in any one of the above first aspects, or the steps of the debugging method described in any one of the above third aspects.
[0117] Eighth aspect, an embodiment of the present application provides a debugging system for a program, including a first device and a second device;
[0118] The first device includes a processor coupled to a memory, and the processor executes a program stored in the memory to implement the steps of the debugging method described in any one of the above first aspects;
[0119] The second device includes a processor coupled to a memory, and the processor executes a program stored in the memory to implement the steps of the debugging method described in any one of the above first aspects.
[0120] It can be understood that the beneficial effects of the above second to eighth aspects can be referred to the relevant descriptions in the above first aspect and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0121] Figure 1 is a schematic diagram of an operation for debugging a multi-language program in the prior art;
[0122] Figure 2 is a schematic diagram of a debugging system for a program provided by an embodiment of the present application;
[0123] Figure 3 is a schematic flowchart of a debugging method for a program provided by an embodiment of the present application;
[0124] Figure 4 is a schematic diagram of a debugging interface provided by an embodiment of the present application;
[0125] Figure 5 is a schematic diagram of a function stepping operation provided by an embodiment of the present application;
[0126] Figure 6 is a schematic diagram of a function stepping out operation provided by an embodiment of the present application;
[0127] Figure 7 is a schematic diagram of a function skipping operation provided by an embodiment of the present application;
[0128] Figure 8It is a specific implementation flowchart of S303 in a program debugging method provided by another embodiment of the present application;
[0129] Figure 9 It is a schematic diagram of the connection between each module between the first device and the second device provided by an embodiment of the present application;
[0130] Figure 10 It is a schematic diagram of the switching between the first debugging interface and the second debugging interface provided by an embodiment of the present application;
[0131] Figure 11 It is an interaction flowchart of each thread and interface during the process of responding to a debugging operation across programming languages provided by an embodiment of the present application;
[0132] Figure 12 It is a schematic diagram of the function nesting relationship of the target program to be debugged provided by an embodiment of the present application;
[0133] Figure 13 It is an interaction flowchart between the first device and the second device in case 1 provided by an embodiment of the present application;
[0134] Figure 14 It is an interaction flowchart between the first device and the second device in case 2 provided by an embodiment of the present application;
[0135] Figure 15 It is an interaction flowchart between the first device and the second device in case 3 provided by an embodiment of the present application;
[0136] Figure 16 It is an interaction flowchart between the first device and the second device in case 4 provided by an embodiment of the present application;
[0137] Figure 17 It is a flowchart of the implementation of a program debugging method on the first device side provided by an embodiment of the present application;
[0138] Figure 18 It is a structural block diagram of a program debugging device provided by an embodiment of the present application;
[0139] Figure 19 It is a flowchart of the implementation of a program debugging method on the second device side provided by an embodiment of the present application;
[0140] Figure 20 It is a structural block diagram of a program debugging device provided by an embodiment of the present application;
[0141] Figure 21 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. Detailed implementation manners
[0142] In the following description, specific details such as specific system architectures and technologies are presented for the purpose of illustration rather than limitation, so as to thoroughly understand the embodiments of the present application. However, those skilled in the art should clearly understand that the present application can also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid unnecessary details from interfering with the description of the present application.
[0143] It should be understood that when used in the specification of the present application and the appended claims, the term "comprising" indicates the presence of the described features, wholes, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components, and / or their combinations.
[0144] It should also be understood that the term "and / or" used in the specification of the present application and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0145] As used in the specification of the present application and the appended claims, the term "if" can be interpreted as "when", "once", "in response to determining", or "in response to detecting" depending on the context. Similarly, the phrase "if determined" or "if detecting [the described condition or event]" can be interpreted as meaning "once determined", "in response to determining", "once detecting [the described condition or event]", or "in response to detecting [the described condition or event]" depending on the context.
[0146] In addition, in the description of the specification of the present application and the appended claims, the terms "first", "second", "third", etc. are only used for distinguishing descriptions and cannot be understood as indicating or implying relative importance.
[0147] The reference to "one embodiment" or "some embodiments" etc. described in the specification of the present application means that a specific feature, structure, or characteristic described in connection with that embodiment is included in one or more embodiments of the present application. Thus, statements such as "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments", etc. that appear in different places in this specification do not necessarily all refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "comprising", "including", "having", and their variants all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0148] Embodiment 1:
[0149] Applications, as the main carriers of electronic services, are growing in number and update speed at a geometric rate. Therefore, how to develop applications efficiently has become the focus of attention for developers. Among them, the debugging process is one of the important links in the development process, and the debugging efficiency directly affects the development and update speed of applications. In most of the existing developed applications, most programs often need to be written in multiple languages. For example, applications are developed by mixing JavaScript language (also known as JS language) and C / C++ language. When debugging the above types of programs, different debugging threads are often required to debug the functions of the corresponding languages.
[0150] Exemplarily, Figure 1 The operation schematic diagram of debugging a multi-language program in the prior art is shown. Refer to Figure 1 As shown, a part of the code in the application to be debugged is written in JavaScript language. During the implementation of this code, the function "Minute Two", that is, Code 11, written in C / C++ language can be called. Since Figure 1 the interface shown in is the debugging interface corresponding to the Script language, and the displayed code content is the code written in JavaScript language in the application. The functions of other languages it calls are stored in the function library and cannot be directly displayed in the above debugging interface.
[0151] At this time, when the user debugs the above code and needs to determine the change situation of relevant variables in the function "Minute Two", since the debugging tasks of different programming languages are executed by different threads and the transfer of debugging tasks cannot be achieved between the two threads, when the debugging interface corresponding to the JavaScript language is displayed, the debugging task is executed by the thread corresponding to the JavaScript language on the test machine where the application to be debugged is installed, and the thread corresponding to the C / C++ language will not be started.
[0152] Therefore, if the change situation of relevant variables in the function "Minute Two" is required during the debugging process, the user needs to manually open the function library corresponding to the corresponding programming language, such as the function library 12 corresponding to the C / C++ language, and select the function "Minute Two", that is, Function 13, from the function library corresponding to the C / C++ language, so as to start the debugging interface corresponding to the C / C++ language and activate the thread corresponding to the C / C++ language on the test machine to execute the debugging task.
[0153] It can be seen that in the existing debugging technology, when debugging an application program written in multiple languages, if the debugging content of a function in another programming language called is viewed in the debugging interface of one programming language, the user needs to search for the corresponding function code from the function library of another programming language in order to open the debugging interface of the corresponding programming language and activate the thread of the corresponding programming language to execute the debugging task. The operation is difficult and the operation efficiency is low. In the case where there are many function codes included in the function library, the user needs to spend a long time searching for the called function code, which further reduces the debugging efficiency and affects the development efficiency of the application program.
[0154] To solve the problems existing in the debugging technology, an embodiment of the present application provides a debugging method for a program. This debugging method for a program can be applied to a debugging system for a program. The debugging system for a program includes a first device and a second device. The first device can be a device installed with a target program to be debugged, that is, a test machine; and the second device can be a device installed with a debugging program, that is, a debugging control device. The user can initiate a debugging task in the debugging program running on the debugging control device to debug the target program installed in the test machine.
[0155] Exemplarily, Figure 2 shows a schematic diagram of a debugging system for a program provided by an embodiment of the present application. Refer to Figure 2 as shown in (a) of. This debugging system for a program includes two devices, namely device 21 and device 22, which are directly connected between the above-mentioned device 21 and device 22. Among them, device 21 is a test machine installed with a target program to be debugged. This test machine can be a smart phone, a tablet computer, a notebook computer, or other devices capable of installing programs. Device 22 is a debugging control device installed with a debugging program. This debugging control device can also be a smart phone, a tablet computer, a server, a notebook computer, or other devices capable of responding to the debugging operations initiated by the user. In this embodiment, device 21 and device 22 are two independent devices. It should be noted that in other implementation scenarios, the above-mentioned device 22 can also be used as a test machine, and correspondingly, device 21 can also be used as a debugging control device.
[0156] Refer to Figure 2 as shown in (b) of. This debugging system for a program includes one device, that is, device 23. Among them, device 23 is a debugging control device that responds to the debugging operations initiated by the user. An analog device 24 can be run inside this device 23, and the target program to be debugged can be installed on this analog device 24. Then, the user can initiate a debugging operation in the debugging program of device 23, and then send the debugging instruction corresponding to the debugging operation to the analog device 24 through the analog interface between device 23 and the analog device 24 to complete the debugging function.
[0157] Refer toFigure 2 As shown in (c) of Figure 2 , the debugging system of this program includes two devices, namely device 25 and device 26. Among them, device 26 can establish a communication connection according to the communication address of device 25. That is, device 25 can be a test machine shared in the cloud, and device 26 can establish a communication connection with device 25 through the Internet, thereby achieving the purpose of remote debugging. For the specific debugging process, please refer to the relevant description in (a) of
[0158] It should be noted that the debugging control device can be connected to multiple test machines at the same time. In the case where the debugging control device is connected to multiple test machines at the same time, the test machine that needs to install the target program to be debugged can be selected from multiple test machines, so as to debug the target program on one of the test machines.
[0159] Specifically, Figure 3 shows a schematic flowchart of the program debugging method provided by an embodiment of the present application. Combining Figure 2 any program debugging system provided by the embodiment and Figure 3 the schematic flowchart, the program debugging method provided by the embodiment of the present application includes:
[0160] In S301, the second device displays a first debugging interface corresponding to the first programming language; the first debugging interface contains the code of the target program.
[0161] In this embodiment, a debugging program can run on the second device. After the user starts the debugging program, the user can open the target program to be debugged within the debugging program. The debugging program can generate a debugging interface corresponding to the basic programming language used to write the target program. Herein, the basic programming language specifically refers to the programming language used to write the program framework code of the target program. The program framework code of the program is used to describe the running logic of the program and multiple related functions. During the process of the program implementing the above running logic or functions, other functions in the function library can be called. The called functions can be written in any programming language, and the programming language of the called functions can be different from the programming language used for the program framework code. For example, in a program with a basic programming language of JavaScript, its program framework code can be written in JavaScript. In the above program framework code, functions written in the C++ language and functions written in the JavaScript language can be called. Other functions in the function library can also be continuously called within these functions, nested layer by layer. In this case, when the second device first opens the above program with a basic programming language of JavaScript, the debugging interface will be the debugging interface corresponding to the JavaScript programming language, and during subsequent debugging, according to whether the user's debugging operation involves cross-programming-language debugging operations, the debugging interface corresponding to the corresponding programming language will be adaptively displayed.
[0162] Exemplarily, Figure 4 shows a schematic diagram of the debugging interface provided by an embodiment of the present application. Refer to Figure 4 As shown, this debugging interface includes an area 1 for displaying the target program to be debugged, an area 2 for displaying the file structure within the target program, and an area 3 for initiating debugging operations. Among them, when the user opens the target program to be debugged within the debugging program, the generated debugging interface is the program interface corresponding to the underlying programming language of the opened target program.
[0163] For example, if the target program is written in the JavaScript programming language as the underlying programming language, that is, in the program architecture written in the JavaScript programming language, functions in the C language or the C++ language can be called. Then, when the debugging program opens this target program, the initially displayed debugging interface is the debugging interface corresponding to the JavaScript language. The program code corresponding to the target program can be displayed in the program display area corresponding to the debugging interface. Similarly, if the target program is written with a C language program framework and JavaScript functions or C++ language functions are called within this program framework, then when the debugging program opens this target program, the initially displayed debugging interface is the debugging interface corresponding to the C / C++ language. The same applies to other programming languages and will not be elaborated here.
[0164] In this embodiment, the debugging interface displayed by the second device can be determined according to the programming language corresponding to the code operated by the user. For example, if the user is currently operating on the C / C++ language code in the target program, the above debugging interface can be the debugging interface corresponding to the C / C++ language; if the user is currently operating on the JavaScript language code in the target program, the above debugging interface can be the debugging interface corresponding to the JavaScript language. Among them, the code displayed in the debugging interface is also the code associated with the corresponding programming language.
[0165] In this embodiment, a debugging program is running on the second device. The user can open the target program to be debugged in the debugging program and initiate a debugging operation on the target program in the above debugging program. When debugging the target program, the device on which the target program is installed can be determined, that is, the above first device is specified. The second program can send the data packet of the target program to the first device specified by the user. After receiving the data packet of the target program, the first device can run the data packet to install the target program on the first device. After the first device completes the installation operation of the target program, the first device can run the above target program locally, and then the first device sends the relevant information generated during the running of the target program to the second device through the thread activated during the current debugging process. The second device can display the relevant information generated during the received debugging process in the debugging interface corresponding to the debugging program.
[0166] In a possible implementation manner, the second device can receive the setting operation of the debugging mode initiated by the user. The above setting operation of the debugging mode can be set when the user starts the debugging program, or can be set when the user opens the target program in the debugging program. In some implementation manners, if the user does not initiate the setting operation of the debugging mode, the second device can set the debugging mode to the default debugging mode, or use the previous debugging mode as the current debugging mode. Among them, the above debugging mode includes: cross-language debugging mode and single-programming language debugging mode. In the cross-language debugging mode, when responding to the debugging operation, the involved code includes the code of two different programming languages, and it can realize the automatic jump of the code position across programming languages and the switching of debugging interfaces of different programming languages; in the single-programming language debugging mode, when responding to the debugging operation, the involved code includes the code of two different programming languages, and it cannot realize the automatic jump of the code position across programming languages and the switching of debugging interfaces of different programming languages.
[0167] In S302, the second device responds to the debugging operation initiated by the user for the first code of the target program, and sends a debugging instruction corresponding to the debugging operation to the first device.
[0168] In this embodiment, the debugging interface of the second device may include a debugging operation area, and the debugging operation area includes a plurality of operation controls. The user can initiate corresponding debugging operations by clicking on the above-mentioned operation controls. Among them, the above-mentioned debugging operations include, but are not limited to: function step into operation, function step out operation, function step over operation, etc. The specific execution logics of the above-mentioned various debugging operations are as follows:
[0169] 1. The function step into operation is specifically used for: executing the code of a specified line in the program. If the code references a function, it will jump to the first line of code of that function.
[0170] Exemplarily, Figure 5 shows a schematic diagram of the function step into operation provided by an embodiment of the present application. Refer to Figure 5 as shown in (a) of. When the user initiates a function step into operation on code 51, since code 51 does not reference function code, when performing the function step into operation on code 51, it will move to the next line of code of code 51, that is, code 52, waiting for the user to initiate the next debugging operation, that is, achieving the purpose of single-step executing the code.
[0171] Refer to Figure 5 as shown in (b) of. When the user initiates a function step into operation on code 53, since code 53 references another function, such as the function "Minute Two", and the programming language of this function "Minute Two" and code 53 are both written in the same programming language, therefore, it can directly jump to the first line of code corresponding to this function "Minute Two", that is, the position of code 54, waiting for the user to initiate the next debugging operation.
[0172] 2. The function step out operation is specifically used for: executing the remaining content of the function where the specified code is located and jumping to the next line of code that references that function.
[0173] Exemplarily, Figure 6 shows a schematic diagram of the function step out operation provided by an embodiment of the present application. Refer to Figure 6 as shown in. Code 61 references the function "Minute Two", and this function "Minute Two" contains multiple lines of code, that is, the code area 62. If the user initiates a function step out operation on any line of code in the code area 62, for example, initiates a function step out operation on code 63, it will execute all the subsequent code of this code 63 and jump to the next line of code that references this code 61, that is, the position of code 64, waiting for the user to initiate the next debugging operation.
[0174] 3. The function skip operation is specifically used for: executing the code on a specified line in the program. If the code references a function, the referenced function will be skipped, and the program will jump to the next line of code.
[0175] Exemplarily, Figure 7 FIG. shows a schematic diagram of the function skip operation provided by an embodiment of the present application. Refer to Figure 7 As shown in (a) in, when the user initiates a function skip operation on code 71, since code 71 does not reference function code, when the function skip operation is performed on code 71, it will move to the next line of code after code 71, that is, code 72, and wait for the user to initiate the next debugging operation. This part of the operation is similar to the function step operation.
[0176] Refer to Figure 7 As shown in (b) in, when the user initiates a function skip operation on code 73, since code 73 references other functions, such as the function "Minute Two", it will directly jump to this function "Minute Two" and move to the next line of code, that is, the position of code 74, and wait for the user to initiate the next debugging operation.
[0177] In this embodiment, after receiving the debugging operation initiated by the user, for example, the user clicks an operation control in any debugging interface, the second device will convert the debugging operation into a corresponding debugging instruction, such as a function step instruction, a function step-out instruction, and a function skip instruction, etc., and send the debugging instruction to the first device through the communication connection with the first device. Among them, during the startup process of the debug program, according to the program language corresponding to the currently foreground-displayed debugging interface, a debugging session corresponding to this debugging language will be created in the second device. Correspondingly, the debugging thread corresponding to this program language in the first device will also be in a running state. This debugging session will send the generated debugging instruction to the debugging thread running in the first device, and the debugging thread running in the first device will execute the above-mentioned debugging instruction on the specified code (i.e., the above-mentioned first code) in the target program.
[0178] In S303, in response to the debugging instruction, when the first device detects that the second program language of the second code is different from the first program language of the first code, it executes the debugging instruction through the second thread corresponding to the second program language.
[0179] In this embodiment, when the first device receives the debugging instruction sent by the second device, it can determine the first program language corresponding to the code (i.e., the first code) specified by the debugging instruction. This first program language is specifically the same as the program language corresponding to the currently running debugging thread (i.e., the first thread) in the first device. The first device can also determine the second program language corresponding to the target code (i.e., the second code) when executing the debugging instruction, and determine whether the above two program languages are the same.
[0180] In this embodiment, the object code of the above debugging instruction may be any code involved in the process of executing the debugging instruction. If multiple different lines of code are involved in the process of executing the debugging instruction, the above object code may be any line of the involved code. Correspondingly, whether the second programming language of the above second code is the same as the first programming language is specifically: determining whether the programming languages of all object codes are the same as the first programming language; if the programming language of any object code is different from the first programming language, the debugging instruction is executed through the second thread corresponding to the second programming language; otherwise, if the programming languages of all object codes are the same as the first programming language, the debugging instruction continues to be executed through the first thread.
[0181] In some implementation manners, when the first device detects that the first programming language is the same as the second programming language, it indicates that the current debugging operation does not involve content across programming languages, and the debugging instruction can be executed through the currently running debugging thread (i.e., the first thread).
[0182] In this embodiment, when the first device detects that the first programming language is different from the second programming language, it indicates that the current debugging operation involves debugging content across programming languages, and the debugging task corresponding to the execution of the debugging instruction cannot be completed through the current debugging thread. At this time, the debugging thread corresponding to the second programming language (i.e., the second thread) can be started to execute the debugging instruction.
[0183] Further, in some implementation manners, Figure 8 The specific implementation flowchart of S303 in a debugging method of a program provided in another embodiment of the present application is shown. Refer to Figure 8 As shown, in the embodiment of the present application, when the above S303 starts the second thread corresponding to the second programming language, it may specifically include the following steps:
[0184] In S3031, when the first device detects that the second programming language is different from the first programming language, it stops the debugging task of the first thread through the cross-language interface.
[0185] In S3032, the first device sends an awakening notification to the second thread through the cross-language interface to control the second thread to execute the debugging instruction.
[0186] In this embodiment, when the first device detects that the debugging instruction involves a debugging operation across programming languages, it can control the working states of the threads corresponding to different programming languages through the cross-language interface, that is, stop the running of the first thread of the first programming language and send an awakening notification to the second thread corresponding to the second programming language to notify the second thread to start, so as to be able to respond to the above debugging instruction through the debugging thread corresponding to the object code (i.e., the second code).
[0187] In some implementations, the above cross - language interface needs to be started when the debugging mode is in the cross - language debugging mode. Then, the above S3031 can specifically be: when the first device detects that the second programming language is different from the first programming language in the cross - language mode, it stops the debugging task of the first thread through the cross - language interface and sends a wake - up notice to the second thread through the cross - language interface; when the first device detects that the second programming language is different from the first programming language in the non - cross - language debugging mode, it can continue to execute the above - mentioned debugging instructions through the first thread.
[0188] Exemplarily, Figure 9 shows a schematic connection diagram of each module between the first device and the second device provided in an embodiment of the present application. Refer to Figure 9 as shown in (a) therein, the second device includes a debug session management module. When the above - mentioned debug program runs on the second device, multiple debug sessions can be configured according to the number of programming languages supported by the debug program. For example, a debug session JavaScript91 for debugging the JavaScript language and a debug session Native92 for debugging the C / C++ language. Correspondingly, in order to implement communication with the debug sessions in the second device on the first device, session services corresponding to the number can be created according to the programming languages included in the target program. For example, a JS debugger service 93 and an lldb - service service 94. The above - mentioned JS debugger service 93 is used to implement communication with the debug session JavaScript91 of the JavaScript language in the second device; the lldb - service service 94 is used to implement communication with the debug session Native92 of the C / C++ language in the second device. The above - mentioned JS debugger service 93 can be maintained by the thread JSEngine; and the above - mentioned lldb - service service 94 can be maintained by the thread JS Native Module. Among them, the first device further includes a cross - language interface Napi for data interaction between different threads, such as data interaction between the debug thread JSNative Module and the debug thread JS Engine.
[0189] Refer to Figure 9 as shown in (b) therein, the above - mentioned debug thread JSNative Module and the debug thread JS Engine can be located in the application framework layer of the first device, and the application framework layer further includes a cross - language interface Napi to implement data interaction between the debug thread JSNative Module and the debug thread JS Engine through the cross - language interface Napi.
[0190] In this embodiment, when the foreground interface of the debugging program of the second device is a JavaScript debugging interface, the above-mentioned debugging session JavaScript91 is activated, and data transmission is achieved through the debugging session JavaScript91 and the JSdebugger service 93 on the first device, and the above-mentioned JS debugger service 93 is maintained by the thread JS Engine; similarly, when the foreground interface of the debugging program of the second device is a debugging interface in the C / C++ language, the above-mentioned debugging session Native92 is activated, and data transmission is achieved through the debugging session Native92 and the lldb-service service 94 on the first device, and the above-mentioned lldb-service service 94 is maintained by the thread JS Native Module.
[0191] In the prior art, since the above-mentioned thread JS Native Module and the thread JS Engine are independent of each other, during the debugging process, when responding to cross-thread debugging instructions, the user needs to manually start the debugging interface of the programming language of the target code of the debugging instruction in the debugging program of the second device (that is, manually start the second debugging interface of the second programming language) to activate the debugging session of the corresponding programming language on the second device, so as to wake up the thread of the corresponding programming language in the first device (that is, the second thread), and execute the corresponding debugging instruction through this thread. The operation is cumbersome and the debugging efficiency is low.
[0192] To solve the above problems, a cross-language interface can be configured in the first device of the embodiment of the present application. The cross-language interface can be a Napi interface. After a debugging instruction is received by a debugging thread of any programming language (such as the first thread), the debugging instruction can be forwarded to the cross-language interface. The cross-language interface can determine whether the programming language of the target code is the same as the programming language corresponding to the current debugging thread according to the debugging instruction. If the two are different, it means that there is a cross-language debugging situation. At this time, only the operations of S3031 and S3032 are required to achieve the purpose of automatically waking up the debugging thread corresponding to the target code, reducing the operations required during the debugging process and improving the debugging efficiency.
[0193] In some implementation manners, the cross-language debugging interface can determine whether the second programming language of the second code is the same as the first program code according to whether the function where the second code is located is a custom function. The first device can store a custom function range, and determine whether the debugging operation initiated by the user is a cross-programming language debugging operation by judging whether the function where the second code is located is within the above-mentioned custom function range. Among them, the above-mentioned custom function range can be sent from the second device to the first device.
[0194] For example, the operating system of the first device mentioned above is the Android system. In the Android system, some basic functions or modules are implemented by functions written in the C / C++ language and are not within the scope of the objects to be debugged. Therefore, when the target program to be debugged calls the functions of the above basic functions, there is no need to perform debugging operations on this type of function through the corresponding debugging thread, nor is it necessary to locate the code addresses of this part of the functions, that is, there is no need to display the code of this part of the functions through the corresponding debugging interface. During the debugging process, the user only needs to debug the custom function range within the target program, such as custom C / C++ functions and custom JavaScript functions, etc. Of course, in the case where the operating system of the first device is other operating systems, the functions of the basic functions and modules can be written in other programming languages, and the range of the corresponding custom functions can also be determined according to the programming languages used in each basic module in this operating system, which is not specifically limited.
[0195] In some implementation manners, the above custom function range can specifically be the code address range of the custom function. Correspondingly, the manner in which the cross-language interface Napi determines whether the function where the second code is located is within the custom function range can specifically be: the cross-language interface Napi determines whether the code address of the second code is within the code address range of the above custom function. If the code address of the second code is within the code address range of the above custom function, it is recognized that the second programming language of the second code is different from the first programming language of the first code; conversely, if the code address of the second code is not within the code address range of the above custom function, it is recognized that the second programming language of the second code is the same as the first programming language of the first code.
[0196] In this embodiment, when the first device detects that the debugging instruction involves a cross-programming language debugging operation, it can execute the above debugging instruction through the second thread corresponding to the target code, so as to be able to process the above debugging instruction through the debugging thread of the programming language corresponding to the target code, improving the accuracy of the debugging operation. Among them, after the first device executes the debugging instruction through the second thread, it can generate corresponding debugging information, and the debugging information can include the debugging result corresponding to the debugging instruction and the code address corresponding to the target code.
[0197] In S304, the first device sends the debugging information corresponding to the debugging instruction to the second device through the second thread.
[0198] In this embodiment, after the first device finishes executing the debugging instruction, it can send the debugging information carrying the target code to the second device through the second thread, so as to display the debugging result corresponding to the above debugging instruction on the second device.
[0199] In S305, the second device generates a second debugging interface corresponding to the second programming language, and displays the second code in the second debugging interface according to the code address in the debugging information.
[0200] In this embodiment, since the above debugging information is sent by the first device through the second thread, the second device can determine that the current debugging operation involves cross-programming language debugging. At this time, the debugging interface in the foreground can be switched from the debugging interface corresponding to the first programming language to the debugging interface corresponding to the second programming language, and according to the received debugging information, determine the code address corresponding to the target code, locate the position where the target code is located according to the code address, and display the target code in the above-mentioned second debugging interface, achieving the purpose of automatically jumping to the debugging interface and code position corresponding to the corresponding programming language, and reducing the operations that the user needs to perform.
[0201] Exemplarily, Figure 10 shows a schematic diagram of the switch between the first debugging interface and the second debugging interface provided by an embodiment of the present application. Refer to Figure 10 As shown in (a) in, the second device initiates a function stepping operation on the code 101 in the first debugging interface corresponding to the JavaScript language. The code 101 references a function "Minute Two" written in the C language. After the second device sends the debugging instruction to the first device, the first device can respond to the debugging instruction through the thread corresponding to the C language (i.e., the second thread), and determine the first line code corresponding to the function "Minute Two", and send the code address of the first line code to the second device through the second thread. The second device can display the debugging interface corresponding to the C language, and display the first line code of the function "Minute Two" in the second display interface, as Figure 10 shown in (b) in.
[0202] To further illustrate the interaction process between each module and thread between the two devices during the debugging process, Figure 11 shows an interaction flow chart of each thread and interface provided by an embodiment of the present application during the response to cross-programming language debugging operations. Refer to Figure 11 As shown in, the second device includes a debugging session JavaScript and a debugging session Native. Taking the first programming language as the JavaScript language and the second programming language as the C / C++ language as an example for illustration. The above first device includes two threads, namely the debugging thread JS Engine of the JavaScript language and the debugging thread JS Native Module of the C / C++ language. The first device also includes a cross-language interface Napi. Among them, the above interaction process can specifically include the following stages:
[0203] Phase 1: Debugging Program Startup Phase
[0204] Step 1.1: The user starts the debugging program on the first device and opens the target program to be debugged.
[0205] Step 1.2: The first device starts the debugging program and determines that the programming language of the target program is JavaScript. At this time, a debugging session for the JavaScript language, JavaScript, and a debugging session for the C / C++ language, Native, will be started.
[0206] After the debugging session JavaScript on the first device is started, it will send a service creation notification to the first device. In response to this service creation notification, the first device will create a debugging thread for the JavaScript language, JS Engine. This debugging thread JS Engine is used to maintain the debugging service for the JavaScript language, that is, the JS debugger service. After creating the above debugging thread JS Engine, it will notify the debugging session JavaScript in the second device.
[0207] After the debugging session Native on the second device is started, it will send a service creation notification to the first device. In response to this service creation notification, the first device will create a debugging thread for the C / C++ language, JS Native Module. This debugging thread JS Native Module is used to maintain the debugging service for the C / C++ language, that is, the lldb-service service. After creating the above debugging thread JS Native Module, it will notify the debugging session Native in the second device. It should be noted that since the debugging interface running in the foreground of the debugging program is the debugging interface for the JavaScript language, although the above debugging thread JSNative Module is created, it is not in an active state.
[0208] Phase 2: Second Device Responds to User's Debugging Operations Phase
[0209] Step 2.1: When the user initiates a debugging operation within the debugging interface corresponding to the JavaScript language displayed on the second device, the debugging session JavaScript will convert the debugging operation of the JavaScript code into a debugging instruction and send it to the JavaScript debugging thread running on the first device, that is, the thread JS Engine.
[0210] Step 2.2: The thread JS Engine in the first device can send the debugging instruction to the cross-language interface. The cross-language interface Napi determines whether the target code corresponding to the debugging instruction is C / C++ code.
[0211] Step 2.3: When the cross-language interface Napi in the first device determines that the target code of the debugging instruction is C / C++ code, it stops the operation of the debugging thread JS Engine. At this time, when the debugging thread JS Engine stops, the above debugging session JavaScript will also be closed.
[0212] Step 2.4: The cross-language interface Napi in the first device activates the already created debugging thread JS NativeModule and maintains the debugging service corresponding to the C / C++ language, that is, the lldb-service service, through the debugging thread JS Native Module. At this time, when the debugging thread JS Native Module starts, the above debugging session Native will also be opened, and a debugging interface for the C / C++ language will be generated on the second device.
[0213] Step 2.5: The debugging thread JS NativeModule in the first device executes the above debugging instruction to generate debugging information. The debugging information includes the code address of the target code.
[0214] Step 2.6: The second device receives the debugging information sent by the first device through the debugging thread JS NativeModule and displays the target code in the debugging interface for the C / C++ language according to the code address of the target code.
[0215] In this embodiment, the cross-language interface is used to determine whether the debugging instruction involves cross-language debugging operations, so that when there are cross-language debugging operations, the corresponding thread can be automatically started to execute the debugging instruction, reducing the operations that the user needs to perform, lowering the operation difficulty of the user, and improving the debugging efficiency.
[0216] In some implementation manners, the debugging program method provided in this embodiment can be applied to the scenario where the target program to be debugged is written in JavaScript language and C / C++ language. Corresponding to the above two implementation scenarios, according to the differences in the program languages of the starting code and the target code, and the differences in the initiated debugging operations, it can be specifically divided into four cases, as shown in Table 1.
[0217]
[0218] Table 1
[0219] According to the above different situations, the specific implementation processes of S302 to S305 are described as follows:
[0220] Situation 1: Initiate a function stepping operation on JavaScript code that references C / C++ language
[0221] Exemplarily, Figure 12 shows a schematic diagram of the function nesting relationship of the target program to be debugged provided by an embodiment of the present application. Refer to Figure 12 As shown, the target program includes at least four functions, namely function 1, function 2, function 3, and function 4. Among them, function 1 and function 3 are written in JavaScript language, and function 2 and function 4 are written in C / C++ language. Among them, in one piece of code of function 1, function 2 is referenced, in one piece of code of function 2, function 3 is referenced, and in one piece of code of function 3, function 4 is referenced.
[0222] The above situation 1 can be a function stepping operation initiated on the code in function 1 that references function 2; it can also be a function stepping operation initiated on the code in function 3 that references function 4.
[0223] Exemplarily, Figure 13 shows an interaction flowchart between the first device and the second device in situation 1 provided by an embodiment of the present application. Refer to Figure 13 As shown, the debugging method of the program provided by the embodiment of the present application specifically includes:
[0224] In S1301, in response to the function stepping operation initiated by the user on the JavaScript code in the target program, the second device sends a function stepping instruction about the JavaScript code to the debugging thread JS Engine in the first device through the debugging session JavaScript.
[0225] In S1302, the debugging thread JS Engine in the first device sends the function stepping instruction to the cross-language interface Napi.
[0226] In S1303, when the cross-language interface Napi in the first device detects that the JavaScript code references a function written in C / C++ language and this function belongs to a custom function, the cross-language interface Napi will pause the debugging thread JS Engine.
[0227] In S1304, the cross-language interface Napi in the first device sends a wake-up notification to the debugging thread JS Native Module to start the debugging thread JS Native Module.
[0228] In S1305, the debugging thread JS Native Module in the first device executes the above-mentioned function stepping instruction to determine the code address of the first-line code of the C / C++ function referenced by the JavaScript code.
[0229] In S1306, the first device sends a start notification of a debugging session for the C / C++ language to the second device through the debugging thread JS Native Module, and sends the code address of the first-line code of the referenced C / C++ function to the second device.
[0230] In S1307, in response to the above start notification, the second device closes the JavaScript debugging session, opens the Native debugging session, and displays the first-line code of the referenced C / C++ function in the C / C++ language debugging interface according to the code address of the first-line code of the C / C++ function. For example, the first-line code of the above function 2, or the first-line code of function 4.
[0231] Among them, when the second device receives the above start notification of the debugging session for the C / C++ language, it can record the code position corresponding to the JavaScript code that references the C / C++ function, so that when returning from the C / C++ function later, it can continue debugging from the JavaScript code that references the above C / C++ function.
[0232] Case 2: Initiate a function step-out operation on a C / C++ function nested in a JavaScript function
[0233] The above Case 2 can be a function step-out operation initiated on the code in function 2 to return to function 1; it can also be a function step-out operation initiated on the code in function 4 to return to function 3.
[0234] Exemplarily, Figure 14 shows the interaction flow chart between the first device and the second device in Case 2 provided by an embodiment of the present application. See Figure 14 As shown, the debugging method of the program provided by the embodiment of the present application specifically includes:
[0235] In S1401, in response to a function step-out operation initiated by the user on the code in a C / C++ function in the target program, the second device sends a function step-out instruction for the C / C++ code to the debugging thread JS Native Module in the first device through the Native debugging session. The C / C++ function is nested within a JavaScript function.
[0236] In S1402, the debugging thread JS Native Module in the first device sends a function step-out instruction to the cross-language interface Napi.
[0237] In S1403, the cross-language interface Napi in the first device detects that a C / C++ function is nested in a JavaScript function, and the cross-language interface Napi pauses the debugging thread JS Native Module.
[0238] In S1404, the cross-language interface Napi in the first device sends a wake-up notification to the debugging thread JS Engine to start the debugging thread JS Engine.
[0239] In S1405, the debugging thread JS Engine in the first device executes the above function step-out instruction to determine the code address of the JavaScript code that references the C / C++ function.
[0240] In S1406, the first device sends a start notification of a debugging session for the JavaScript language to the second device through the debugging thread JS Engine, and sends the code address of the JavaScript code that references the C / C++ function to the second device.
[0241] In S1407, in response to the above start notification, the second device closes the debugging session Native, opens the debugging session JavaScript, and displays the next line of the JavaScript code that references the C / C++ function in the debugging interface of the JavaScript language according to the code address of the JavaScript code that references the C / C++ function. For example, the next line of the code that references function 2 in function 1, or the next line of the code that references function 4 in function 3.
[0242] Case 3: Initiate a function step-in operation on C / C++ code that references the JavaScript language
[0243] The above Case 3 can be a function step-in operation initiated on the code that references function 3 in function 2.
[0244] Exemplarily, Figure 15 shows an interaction flowchart between the first device and the second device in Case 3 provided by an embodiment of the present application. Refer to Figure 15 As shown, the debugging method of the program provided by the embodiment of the present application specifically includes:
[0245] In S1501, in response to a function stepping operation initiated by the user on the C / C++ code in the target program, the second device sends a function stepping instruction regarding the C / C++ code to the debug thread JS Native Module in the first device through the debug session Native.
[0246] In S1502, the debug thread JS Native Module in the first device sends the function stepping instruction to the cross-language interface Napi.
[0247] In S1503, when the cross-language interface Napi in the first device detects that the C / C++ code references a function written in the JavaScript language, the cross-language interface Napi pauses the debug thread JS Native Module.
[0248] In S1504, the cross-language interface Napi in the first device sends a wake-up notification to the debug thread JS Engine to start the debug thread JS Engine.
[0249] In S1505, the debug thread JS Engine in the first device executes the above function stepping instruction to determine the code address of the first line of code of the JavaScript function referenced by the C / C++ code.
[0250] In S1506, the first device sends a start notification regarding the debug session of the JavaScript language to the second device through the debug thread JS Engine, and sends the code address of the first line of code of the referenced JavaScript function to the second device.
[0251] In S1507, in response to the above start notification, the second device closes the debug session Native, opens the debug session JavaScript, and displays the first line of code of the referenced JavaScript function in the debug interface of the JavaScript language according to the code address of the first line of code of the JavaScript function. For example, the first line of code of the above function 3.
[0252] Among them, when the second device receives the above start notification regarding the debug session of the JavaScript language, it can record the code position corresponding to the C / C++ code that references the JavaScript function, so that when returning from the JavaScript function to the C / C++ function later, debugging can continue from the C / C++ code that references the above JavaScript function.
[0253] Case 4: Initiate a function step-out operation on a C / C++ function nested in a JavaScript function
[0254] The above-mentioned situation 4 may be a function stepping out operation initiated for the code in function 3 to return to function 2.
[0255] Exemplarily, Figure 16 The interaction flowchart between the first device and the second device in situation 4 provided by an embodiment of the present application is shown. Refer to Figure 16 As shown, the debugging method of the program provided by the embodiment of the present application specifically includes:
[0256] In S1601, in response to a function stepping out operation initiated by the user for the code in the JavaScript function in the target program, the second device sends a function stepping out instruction regarding the JavaScript code to the debugging thread JS Engine in the first device through the debugging session JavaScript, and the JavaScript function is nested within a C / C++ function.
[0257] In S1602, the debugging thread JS Engine in the first device sends the function stepping out instruction to the cross-language interface Napi.
[0258] In S1603, when the cross-language interface Napi in the first device detects that the JavaScript function is nested within a C / C++ function, the cross-language interface Napi will pause the debugging thread JS Engine.
[0259] In S1604, the cross-language interface Napi in the first device sends a wake-up notification to the debugging thread JS Native Module to start the debugging thread JS Native Module.
[0260] In S1605, the debugging thread JS Native Module in the first device executes the above-mentioned function stepping out instruction to determine the code address of the C / C++ code that references the JavaScript function.
[0261] In S1606, the first device sends a start notification regarding the debugging session of the C / C++ language to the second device through the debugging thread JS Native Module, and sends the code address of the C / C++ code that references the JavaScript function to the second device.
[0262] In S1607, in response to the above startup notification, the second device closes the JavaScript debugging session, opens the Native debugging session, and displays the next line of the C / C++ code that references the JavaScript function in the C / C++ language debugging interface according to the code address of the C / C++ code that references the JavaScript function. For example, the next line of the code in function 2 that references the above function 3.
[0263] As can be seen from the above, in a program debugging method provided by an embodiment of the present application, the second device can send a debugging instruction for the first code in the target program to the first device. Before responding to the debugging instruction, the first device determines whether the programming language of the second code corresponding to the debugging instruction is the same as the programming language of the first code. If the programming languages of the two are different, the above debugging instruction is executed through the second thread corresponding to the second code, and the code address corresponding to the second code is fed back to the second device through the second thread, so that a second debugging interface including the second code can be displayed in the second device, realizing the process of automatically switching to the debugging interface of the corresponding language during cross-language debugging. Compared with the existing program debugging technology, in the process of debugging a program written in multiple languages in an embodiment of the present application, when the programming language of the target code corresponding to the debugging operation is inconsistent with the programming language of the debugging interface corresponding to the debugging operation initiated, the user does not need to locate the position of the function where the target code is located. Instead, the first device can automatically switch to the thread of the corresponding programming language to execute the above debugging instruction and feed back the corresponding code address to the second device to automatically generate a debugging interface for the corresponding program code, improving the debugging efficiency of the program written in multiple languages.
[0264] Embodiment 2:
[0265] Compared with Embodiment 1, Embodiment 1 describes a program debugging method provided by an embodiment of the present application from the perspective of the dual-end interaction between the first device and the second device, while Embodiment 2 describes a program debugging method provided by an embodiment of the present application from the perspective of the first device. Exemplarily, Figure 17 The following shows a flowchart of the implementation of a program debugging method provided by an embodiment of the present application on the first device side, which is specifically described as follows:
[0266] In S1701, during the process of debugging the target program through the first thread corresponding to the first programming language, a debugging instruction for the first code in the target program sent by the second device is received; the debugging instruction is generated based on a debugging operation initiated by the user in the first debugging interface corresponding to the first programming language displayed on the second device; the first code is written based on the first programming language;
[0267] In S1702, if the second programming language of the second code is different from the first programming language, the debugging instruction is executed through a second thread corresponding to the second programming language; the second code is the target code corresponding to the debugging instruction.
[0268] In S1703, the debugging information corresponding to the debugging instruction is sent to the second device through the second thread, so that the second device generates a second debugging interface corresponding to the second programming language of the second code according to the debugging information; the debugging information is used to determine the code address of the second code.
[0269] Optionally, the step of, if the second programming language of the second code is different from the first programming language, executing the debugging instruction through a second thread corresponding to the second programming language includes:
[0270] If the debugging instruction is a function step-in instruction, the first function referenced by the first code is determined through the second thread.
[0271] According to the first code address of the first function, the second thread jumps to the second code through the second thread; the second code is the first line code of the first function.
[0272] Optionally, the step of, if the second programming language of the second code is different from the first programming language, executing the debugging instruction through a second thread corresponding to the second programming language includes:
[0273] If the debugging instruction is a function step-out instruction, the third code of the second function where the first code is referenced is determined through the second thread.
[0274] According to the second code address of the third code, the second thread jumps to the second code through the second thread; the second code is the next line code of the third code.
[0275] Optionally, the step of, if the second programming language of the second code is different from the first programming language, executing the debugging instruction through a second thread corresponding to the second programming language includes:
[0276] If the second programming language is different from the first programming language, the debugging task of the first thread is stopped through a cross-language interface.
[0277] An awakening notice is sent to the second thread through the cross-language interface to control the second thread to execute the debugging instruction.
[0278] Optionally, before the step of, if the second programming language is different from the first programming language, stopping the debugging task of the first thread through a cross-language interface, it further includes:
[0279] In response to a mode setting instruction, set the debug mode to a cross - language debug mode;
[0280] If the second programming language is different from the first programming language, stopping the debug task of the first thread through a cross - language interface includes:
[0281] If it is detected that the second programming language is different from the first programming language in the cross - language debug mode, stop the debug task of the first thread through a cross - language interface.
[0282] Optionally, the first programming language is the JavaScript language; the second programming language is the C / C++ language;
[0283] Or the first programming language is the C / C++ language; the second programming language is the JavaScript language.
[0284] Optionally, before, if the second programming language of the second code is different from the first programming language, execute the debug instruction through the second thread corresponding to the second programming language, further includes:
[0285] Receive the custom function range sent by the second device;
[0286] If the second programming language of the second code is different from the first programming language, executing the debug instruction through the second thread corresponding to the second programming language includes:
[0287] Call the cross - language interface to determine whether the function where the second code is located is within the custom function range;
[0288] If the function where the second code is located is within the custom function range, execute the debug instruction through the second thread.
[0289] Optionally, the custom function range includes: the code address range of the custom function;
[0290] The calling the cross - language interface to determine whether the function where the second code is located is within the custom function range includes:
[0291] Call the cross - language interface to determine whether the code address of the second code is within the code address range of the custom function;
[0292] If the function where the second code is located is within the custom function range, executing the debug instruction through the second thread includes:
[0293] If the code address of the second code is within the code address range of the custom function, execute the debugging instruction through the second thread.
[0294] Embodiment 3:
[0295] A debugging method for a program corresponding to Embodiment 2 above Figure 18 The structural block diagram of a debugging device for a program provided by an embodiment of the present application is shown. For ease of description, only the parts related to the embodiment of the present application are shown.
[0296] See Figure 18 As shown, the debugging device for the above program includes:
[0297] A receiving unit 181, configured to receive a debugging instruction about the first code in the target program during the process of debugging the target program through the first thread corresponding to the first programming language; the debugging instruction is generated based on a debugging operation initiated by a user within the first debugging interface corresponding to the first programming language displayed on the second device; the first code is written based on the first programming language;
[0298] A debugging unit 182, configured to execute the debugging instruction through the second thread corresponding to the second programming language if the second programming language of the second code is different from the first programming language; the second code is the target code corresponding to the debugging instruction;
[0299] A sending unit 183, configured to send the debugging information corresponding to the debugging instruction to the second device through the second thread, so that the second device generates a second debugging interface corresponding to the second programming language including the second code according to the debugging information; the debugging information is used to determine the code address of the second code.
[0300] Optionally, the "if the second programming language of the second code is different from the first programming language, execute the debugging instruction through the second thread corresponding to the second programming language" includes:
[0301] A step instruction response unit, configured to determine the first function referenced by the first code through the second thread if the debugging instruction is a function step instruction;
[0302] A first jump unit, configured to jump to the second code through the second thread according to the first code address of the first function; the second code is the first line code of the first function.
[0303] Optionally, the debugging unit includes:
[0304] A step-out instruction response unit, configured to, if the debug instruction is a function step-out instruction, determine, via the second thread, the third code that references the second function where the first code is located;
[0305] A second jump unit, configured to jump, via the second thread, to the second code according to the second code address of the third code; the second code is the next line of code of the third code.
[0306] Optionally, the debug unit includes:
[0307] A thread stop unit, configured to, if the second programming language is different from the first programming language, stop the debug task of the first thread via a cross-language interface;
[0308] A thread start unit, configured to send a wake-up notification to the second thread via the cross-language interface to control the second thread to execute the debug instruction.
[0309] Optionally, the debug device further includes:
[0310] A mode setting unit, configured to, in response to a mode setting instruction, set the debug mode to a cross-language debug mode;
[0311] The debug unit includes:
[0312] A cross-language debug unit, configured to, if it is detected that the second programming language is different from the first programming language in the cross-language debug mode, stop the debug task of the first thread via a cross-language interface.
[0313] Optionally, the first programming language is the JavaScript language; the second programming language is the C / C++ language;
[0314] Or the first programming language is the C / C++ language; the second programming language is the JavaScript language.
[0315] Optionally, the debug device further includes:
[0316] A function range receiving unit, configured to receive a custom function range sent by the second device;
[0317] The debug unit includes:
[0318] A function range judgment unit, configured to call a cross-language interface to judge whether the function where the second code is located is within the custom function range;
[0319] A cross-language determination unit, configured to, if the function where the second code is located is within the custom function range, execute the debug instruction via the second thread.
[0320] Optionally, the custom function range includes: the code address range of the custom function;
[0321] The function range determination unit is configured to: call the cross-language interface to determine whether the code address of the second code is within the code address range of the custom function;
[0322] The cross-language determination unit is configured to: if the code address of the second code is within the code address range of the custom function, execute the debug instruction through the second thread.
[0323] Embodiment 4:
[0324] Compared with Embodiment 1, Embodiment 1 describes a program debugging method provided by an embodiment of the present application from the perspective of dual-end interaction between a first device and a second device, while Embodiment 4 describes a program debugging method provided by an embodiment of the present application from the perspective of the second device. Exemplarily, Figure 19 The flowchart of implementing a program debugging method provided by an embodiment of the present application on the second device side is shown, and the specific description is as follows:
[0325] In S1901, in response to a debugging operation initiated by a user for the first code of a target program, send a debug instruction corresponding to the debugging operation to a first device; the first code is displayed in a first debugging interface of a first programming language corresponding to the first code; the first device debugs the target program in a first thread during the process of the second device displaying the first debugging interface;
[0326] In S1902, receive debugging information sent by the first device; the debugging information is obtained after the second device executes the debug instruction on the target program; the debugging information is sent by a second thread corresponding to the second programming language when the first device detects that the second programming language of the second code is different from the first programming language; the second code is the target code corresponding to the debug instruction; the debugging information is used to determine the code address of the second code;
[0327] In S1903, generate a second debugging interface corresponding to the second programming language including the second code according to the code address.
[0328] Optionally, the step of, in response to a debugging operation initiated by a user for the first code of a target program, sending a debug instruction corresponding to the debugging operation to a first device includes:
[0329] In response to a function stepping operation initiated by a user for the first code of a target program, send a function stepping instruction to the second device; the first code is the code that references a first function;
[0330] Receiving the debugging information sent by the first device includes:
[0331] Receiving the debugging information through a second thread of the first device; the debugging information includes a first code address corresponding to the first line of code of the first function;
[0332] Generating a second debugging interface corresponding to a second programming language including the second code according to the code address includes:
[0333] Displaying the second code in the second debugging interface according to the first code address; the second code is the first line of code of the first function.
[0334] Optionally, responding to a debugging operation initiated by a user for the first code of a target program and sending a debugging instruction corresponding to the debugging operation to the first device includes:
[0335] Responding to a function step-out operation initiated by a user for the first code of a target program and sending a function step-out instruction to the second device; the first code is code within a second function; the second function is referenced by a third code;
[0336] Receiving the debugging information sent by the first device includes:
[0337] Receiving the debugging information through a second thread of the first device; the debugging information includes a second code address of the next line of code of the third code;
[0338] Generating a second debugging interface corresponding to a second programming language including the second code according to the code address includes:
[0339] Displaying the second code in the second debugging interface according to the second code address; the second code is the next line of code of the third code.
[0340] Optionally, before responding to a debugging operation initiated by a user for the first code of a target program and sending a debugging instruction corresponding to the debugging operation to the first device, it further includes:
[0341] Responding to a mode setting operation initiated by a user and generating a mode setting instruction for setting a cross-language debugging mode;
[0342] Sending the mode setting instruction to the first device so that when the first device detects that the second programming language is different from the first programming language, it controls a second thread to send debugging information through a cross-language interface.
[0343] Optionally, the first programming language is JavaScript; the second programming language is C / C++;
[0344] or the first programming language is C / C++; the second programming language is JavaScript.
[0345] Optionally, before sending a debugging instruction corresponding to the debugging operation to the first device in response to a debugging operation initiated by a user for a first code of a target program, it further includes:
[0346] Sending a custom function range to the first device, so that when the first device determines that a function where the second code is located is within the custom function range through a cross-language interface, sending debugging information to the second device through the second thread.
[0347] Optionally, the custom function range includes: a code address range of a custom function;
[0348] The sending the custom function range to the first device includes:
[0349] Sending the code address range of the custom function to the first device, so that when the first device determines that the code address of the second code is within the code address range of the custom function through a cross-language interface, sending debugging information to the second device through the second thread.
[0350] Embodiment 5:
[0351] Corresponding to a debugging method of a program in the above Embodiment 3, Figure 20 A structural block diagram of a debugging device for a program provided by an embodiment of the present application is shown. For ease of description, only parts related to the embodiment of the present application are shown.
[0352] See Figure 20 As shown, the above-mentioned debugging device for a program includes:
[0353] An operation response unit 201, configured to send a debugging instruction corresponding to the debugging operation to a first device in response to a debugging operation initiated by a user for a first code of a target program; the first code is displayed in a first debugging interface of a first programming language corresponding to the first code; the first device debugs the target program in a first thread during the process of the second device displaying the first debugging interface;
[0354] A receiving unit 202, configured to receive the debugging information sent by the first device; the debugging information is obtained after the second device executes the debugging instruction on the target program; the debugging information is sent by the second thread corresponding to the second programming language when the first device detects that the second programming language of the second code is different from the first programming language; the second code is the target code corresponding to the debugging instruction; the debugging information is used to determine the code address of the second code.
[0355] A display unit 203, configured to generate a second debugging interface corresponding to the second programming language including the second code according to the code address.
[0356] Optionally, the operation response unit includes:
[0357] A step operation unit, configured to send a function step instruction to the second device in response to a function step operation initiated by a user for a first code of a target program; the first code is a code that references a first function.
[0358] The receiving unit includes:
[0359] A first address receiving unit, configured to receive the debugging information through the second thread of the first device; the debugging information includes a first code address corresponding to the first line of code of the first function.
[0360] The display unit includes:
[0361] A first display unit, configured to display the second code in the second debugging interface according to the first code address; the second code is the first line of code of the first function.
[0362] Optionally, the operation response unit includes:
[0363] A step-out operation unit, configured to send a function step-out instruction to the second device in response to a function step-out operation initiated by a user for a first code of a target program; the first code is a code within a second function; the second function is referenced by a third code.
[0364] The receiving unit includes:
[0365] A second address receiving unit, configured to receive the debugging information through the second thread of the first device; the debugging information includes a second code address of the next line of code of the third code.
[0366] The display unit includes:
[0367] A second display unit, configured to display the second code in the second debugging interface according to the second code address; the second code is the next line of code of the third code.
[0368] Optionally, the debugging device further includes:
[0369] A mode setting unit, configured to generate a mode setting instruction for setting a cross-language debugging mode in response to a mode setting operation initiated by a user;
[0370] A mode instruction sending unit, configured to send the mode setting instruction to a first device, so that when the first device detects that the second programming language is different from the first programming language, it controls a second thread to send debugging information through a cross-language interface.
[0371] In a possible implementation manner of the fourth aspect, the first programming language is the JavaScript language; the second programming language is the C / C++ language;
[0372] Or the first programming language is the C / C++ language; the second programming language is the JavaScript language.
[0373] In a possible implementation manner of the fourth aspect, the debugging device further includes:
[0374] A function range sending unit, configured to send a custom function range to the first device, so that when the first device determines through a cross-language interface that the function where the second code is located is within the custom function range, it sends debugging information to the second device through the second thread.
[0375] Optionally, the custom function range includes: a code address range of a custom function;
[0376] The function range sending unit includes:
[0377] An address range sending unit, configured to send the code address range of the custom function to the first device, so that when the first device determines through a cross-language interface that the code address of the second code is within the code address range of the custom function, it sends debugging information to the second device through the second thread.
[0378] Figure 21 It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. As Figure 21 shown, the electronic device 21 in this embodiment includes: at least one processor 210 ( Figure 21Only one processor is shown. The number of processors can match the number of chips actually included in the electronic device in the embodiment), a memory 211, and a program 212 stored in the memory 211 and executable on the at least one processor 210. When the processor 210 executes the program 212, the steps in the method embodiments for setting any of the above-mentioned electronic devices are implemented.
[0379] The electronic device 21 may be a VR display device, a smart phone, etc. The electronic device may include, but is not limited to, a processor 210 and a memory 211. Those skilled in the art can understand that Figure 21 This is only an example of the electronic device 21 and does not limit the electronic device 21. It may include more or fewer components than shown in the figure, or combine some components, or different components. For example, it may also include input / output electronic devices, network access electronic devices, etc.
[0380] The so-called processor 210 may be a central processing unit (CPU). The processor 210 may also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), off-the-shelf programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0381] In some embodiments, the memory 211 may be an internal storage unit of the electronic device 21, such as the hard disk or memory of the electronic device 21. In other embodiments, the memory 211 may also be an external storage electronic device of the electronic device 21, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc., equipped on the electronic device 21. Further, the memory 211 may also include both the internal storage unit of the electronic device 21 and the external storage electronic device. The memory 211 is used to store an operating system, application programs, a boot loader, data, and other programs, such as the program code of the program. The memory 211 may also be used to temporarily store data that has been output or will be output.
[0382] It should be noted that for the content such as information interaction and execution process between the above-mentioned devices / units, since it is based on the same concept as the method embodiment of this application, for its specific functions and the technical effects brought, reference can be specifically made to the method embodiment part, and details will not be elaborated here.
[0383] Those skilled in the art can clearly understand that for the convenience and brevity of description, only the above division of each functional unit and module is used as an example. In actual applications, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of this application. The specific working process of the units and modules in the above system can refer to the corresponding process in the foregoing method embodiment, and details will not be elaborated here.
[0384] The embodiment of this application also provides an electronic device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor. When the processor executes the computer program, the steps in any of the above method embodiments are implemented.
[0385] The embodiment of this application also provides a readable storage medium, which stores a program that can implement the steps in the above method embodiments when executed by a processor.
[0386] The embodiment of this application provides a program product, which, when running on an electronic device, enables the electronic device to implement the steps in the above method embodiments when executed.
[0387] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, to implement all or part of the processes in the above-described embodiment methods of this application, a computer program can be used to instruct relevant hardware to complete. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-described various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the photographing device / electronic device, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk, or an optical disc, etc. In some jurisdictions, according to legislation and patent practice, the computer-readable medium cannot be an electrical carrier signal and a telecommunication signal.
[0388] In the above embodiments, the descriptions of the various embodiments have their own emphases. For parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0389] The above-described embodiments are only used to illustrate the technical solutions of this application, rather than to limit it; although this application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that: they can still modify the technical solutions recorded in the foregoing various embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the various embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A debugging method for a program, characterized in that, Applied to a first device, the debugging method includes: During the process of debugging a target program through a first thread corresponding to a first programming language, receiving a debugging instruction for a first piece of code in the target program sent by a second device; the debugging instruction is generated based on a debugging operation initiated by a user within a first debugging interface corresponding to the first programming language displayed on the second device; the first piece of code is written based on the first programming language; If the second programming language of a second piece of code is different from the first programming language, then execute the debugging instruction through a second thread corresponding to the second programming language; the second piece of code is the target code corresponding to the debugging instruction; Send the debugging information corresponding to the debugging instruction to the second device through the second thread, so that the second device generates a second debugging interface corresponding to the second programming language including the second piece of code according to the debugging information; the debugging information is used to determine the code address of the second piece of code.
2. The debugging method according to claim 1, characterized in that The "if the second programming language of the second piece of code is different from the first programming language, then execute the debugging instruction through a second thread corresponding to the second programming language" includes: If the debugging instruction is a function step-in instruction, then determine a first function referenced by the first piece of code through the second thread; Jump to the second piece of code through the second thread according to the first code address of the first function; the second piece of code is the first line of code of the first function.
3. The debugging method according to claim 1, characterized in that The "if the second programming language of the second piece of code is different from the first programming language, then execute the debugging instruction through a second thread corresponding to the second programming language" includes: If the debugging instruction is a function step-out instruction, then determine a third piece of code in a second function that references the first piece of code through the second thread; Jump to the second piece of code through the second thread according to the second code address of the third piece of code; the second piece of code is the next line of code of the third piece of code.
4. The debugging method according to claim 1, characterized in that The "if the second programming language of the second piece of code is different from the first programming language, then execute the debugging instruction through a second thread corresponding to the second programming language" includes: If the second programming language is different from the first programming language, then stop the debugging task of the first thread through a cross-language interface; Send an awakening notification to the second thread through the cross-language interface to control the second thread to execute the debugging instruction.
5. The debugging method according to claim 4, characterized in that Before the "if the second programming language is different from the first programming language, then stop the debugging task of the first thread through a cross-language interface", it further includes: In response to a mode setting instruction, set the debugging mode to a cross-language debugging mode; The "if the second programming language is different from the first programming language, then stop the debugging task of the first thread through a cross-language interface" includes: If it is detected that the second programming language is different from the first programming language in the cross-language debugging mode, then stop the debugging task of the first thread through a cross-language interface.
6. The debugging method according to any one of claims 1-5, characterized in that The first programming language is JavaScript language; the second programming language is C / C++ language; Or the first programming language is C / C++; the second programming language is JavaScript language.
7. The debugging method according to any one of claims 1-6, characterized in that Before executing the debugging instruction through a second thread corresponding to the second programming language if the second programming language of the second code is different from the first programming language, it further includes: Receiving a custom function range sent by the second device; If the second programming language of the second code is different from the first programming language, executing the debugging instruction through a second thread corresponding to the second programming language, includes: Invoking a cross-language interface to determine whether the function where the second code is located is within the custom function range; If the function where the second code is located is within the custom function range, executing the debugging instruction through the second thread.
8. The debugging method according to claim 7, wherein The custom function range includes: the code address range of the custom function; Invoking the cross-language interface to determine whether the function where the second code is located is within the custom function range, includes: Invoking the cross-language interface to determine whether the code address of the second code is within the code address range of the custom function; If the function where the second code is located is within the custom function range, executing the debugging instruction through the second thread, includes: If the code address of the second code is within the code address range of the custom function, executing the debugging instruction through the second thread.
9. A debugging method for a program, characterized in that, Applied to a second device, the debugging method includes: In response to a debugging operation initiated by a user for a first code of a target program, sending a debugging instruction corresponding to the debugging operation to a first device; the first code is displayed in a first debugging interface of a first programming language corresponding to the first code; the first device debugs the target program in a first thread during the process of the second device displaying the first debugging interface; Receiving debugging information sent by the first device; the debugging information is obtained after the second device executes the debugging instruction on the target program; The debugging information is sent by a second thread corresponding to the second programming language when the first device detects that the second programming language of a second code is different from the first programming language; the second code is the target code corresponding to the debugging instruction; the debugging information is used to determine the code address of the second code; Generating a second debugging interface corresponding to the second programming language including the second code according to the code address.
10. The debugging method according to claim 9, characterized in that In response to a debugging operation initiated by a user for a first code of a target program, sending a debugging instruction corresponding to the debugging operation to a first device, includes: In response to a function stepping operation initiated by a user for a first code of a target program, sending a function stepping instruction to the second device; the first code is the code referencing a first function; Receiving the debugging information sent by the first device, includes: Receiving the debugging information through a second thread of the first device; the debugging information includes a first code address corresponding to the first line of code of the first function; Generating a second debugging interface corresponding to a second programming language including the second code according to the code address, includes: Displaying the second code in the second debugging interface according to the first code address; the second code is the first line code of the first function.
11. The debugging method according to claim 9, wherein Responding to a debugging operation initiated by a user for the first code of a target program and sending a debugging instruction corresponding to the debugging operation to a first device, includes: Responding to a function step-out operation initiated by a user for the first code of a target program and sending a function step-out instruction to the second device; the first code is the code within a second function; the second function is referenced by a third code; Receiving debugging information sent by the first device, includes: Receiving the debugging information through a second thread of the first device; the debugging information includes a second code address of the next line code of the third code. Generating a second debugging interface corresponding to a second programming language including the second code according to the code address, includes: Displaying the second code in the second debugging interface according to the second code address; the second code is the next line code of the third code.
12. The debugging method according to claim 9, wherein Before responding to a debugging operation initiated by a user for the first code of a target program and sending a debugging instruction corresponding to the debugging operation to a first device, further includes: Responding to a mode setting operation initiated by a user and generating a mode setting instruction for setting a cross-language debugging mode; Sending the mode setting instruction to the first device, so that when the first device detects that the second programming language is different from the first programming language, it controls a second thread to send debugging information through a cross-language interface.
13. The debugging method according to any one of claims 9-12, characterized in that, The first programming language is JavaScript language; the second programming language is C / C++ language; Or the first programming language is C / C++ language; the second programming language is JavaScript language.
14. The debugging method according to any one of claims 9-13, characterized in that, Before responding to a debugging operation initiated by a user for the first code of a target program and sending a debugging instruction corresponding to the debugging operation to a first device, further includes: Sending a custom function range to the first device, so that when the first device determines through a cross-language interface that the function where the second code is located is within the custom function range, it sends debugging information to the second device through the second thread.
15. The debugging method according to claim 14, wherein The custom function range includes: a code address range of a custom function; Sending the custom function range to the first device, includes: Sending the code address range of the custom function to the first device, so that when the first device determines through a cross-language interface that the code address of the second code is within the code address range of the custom function, it sends debugging information to the second device through the second thread.
16. An electronic device, characterized in that, The electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 8, or the steps of the method according to any one of claims 9 to 15.
17. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8, or the steps of the method according to any one of claims 9 to 15.