A multi-language mixed debugging method and device
By determining the call relationships and setting temporary breakpoints during the pre-compilation stage, and adding keyframes to enable information traceability in the debugging interface, the problem of untraceable debugging information in multi-language mixed debugging is solved, thus meeting the debugging needs of programmers.
Patent Information
- Application Number
- CN202110297531.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-19
- Publication Date
- 2026-01-09
- Estimated Expiration
- 2041-03-19
AI Technical Summary
Existing integrated development environments (IDEs) cannot trace debugging information between different programming languages in multi-language mixed debugging scenarios, especially when Java code segments call C++ code segments, and cannot switch from C++ debugging information to Java debugging information.
During the pre-compilation stage, the calling relationships of the source code are determined, temporary breakpoints are set to obtain debugging information, and keyframes are added to the debugging interface to correspond with the debugging information. The corresponding debugging information is displayed by triggering commands through user input, thus enabling the traceability of debugging information between different programming languages.
It enables the tracing of debugging information across different programming languages, meets the debugging needs of programmers, and provides comprehensive analysis capabilities of call relationships.
Smart Images

Figure CN115114142B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, more particularly, to a multi-language mixed debugging method and device. BACKGROUND
[0002] At present, the mainstream integrated development environment (IDE) on the market basically supports multi-language mixed programming, that is, the source code in a project is implemented by using multiple programming languages. For example, for performance considerations, the source code of game software A is implemented by using Java (a computer programming language), and the image rendering part of game software A needs to call C++ (a computer programming language) functions to implement.
[0003] In the multi-language mixed debugging scenario, the integrated development environment as a client can establish a connection with multiple debugging services corresponding to multiple programming languages, and the debugging interface of the client can display the debugging information provided by the debugging service, and the programmer can perform program debugging according to the debugging information in the debugging interface. For example, assuming that the integrated development environment as a client establishes a connection with a first debugging service and a second debugging service respectively, the first debugging service is a Java debugging service, and the second debugging service is a C++ debugging service, and the debugging interface of the client is used to display the debugging information provided by the Java debugging service or the debugging information provided by the C++ debugging service.
[0004] In the case where there is a calling relationship between different programming languages, the debugging interface of the client cannot realize the tracing of the debugging information between different programming languages. For example, if the code segment A of Java calls the code segment B of C++, when the debugging interface of the client displays the debugging information corresponding to the code segment B of C++, the programmer wants to analyze whether the parameter passing and calling at the code segment A of Java affect the code segment B of C++, and the programmer wants the debugging interface to trace from the debugging information of C++ to the debugging information of Java. However, the existing debugging interface of the client cannot switch from the debugging information corresponding to the code segment B of C++ to the debugging information corresponding to the code segment A of Java.
[0005] Therefore, in the multi-language mixed debugging scenario, when there is a calling relationship between the code segments of multiple programming languages, how to make the debugging interface of the client realize the tracing of the debugging information between different programming languages becomes a technical problem to be solved at present. SUMMARY
[0006] The present application provides a multi-language mixed debugging method and device, so that the debugging interface of the client can trace the debugging information corresponding to the code segments between different programming languages and having a calling relationship.
[0007] In a first aspect, the application provides a multi-language mixed debugging method, which is applied to an integrated development environment having source code, the source code including at least a first code segment and a second code segment, the method including: determining a calling relationship in the source code when the source code is in a pre-compilation stage, the calling relationship including that the first code segment calls the second code segment, and the first code segment and the second code segment being in different programming languages; obtaining first debugging information corresponding to the first code segment; displaying second debugging information corresponding to the second code segment in a debugging interface when the source code is in a debugging stage, the pre-compilation stage being earlier than the debugging stage; determining whether the second code segment is called according to the calling relationship; adding a key frame in the debugging interface and establishing a corresponding relationship between the key frame and the first debugging information when it is determined according to the calling relationship that the second code segment is called by the first code segment; and obtaining the first debugging information corresponding to the key frame and displaying the first debugging information in the debugging interface when a triggering instruction input by a user to the key frame is received.
[0008] In the first aspect, when the source code is in the pre-compilation stage, the integrated development environment can know that the first code segment in the source code calls the second code segment, and the first code segment and the second code segment are in different programming languages by determining the calling relationship in the source code. The integrated development environment needs to obtain the first debugging information corresponding to the first code segment, i.e., the debugging information of the caller. When the second debugging information corresponding to the second code segment is displayed in the debugging interface, the integrated development environment needs to determine whether the second code segment is called according to the calling relationship. When it is determined according to the calling relationship that the second code segment is called by the first code segment, a key frame is added in the debugging interface, and a corresponding relationship between the key frame and the first debugging information is established, so that when a triggering instruction input by a user to the key frame is received, the integrated development environment can obtain the first debugging information corresponding to the key frame and display the first debugging information in the debugging interface. Therefore, the integrated development environment provided by the application can trace the debugging information corresponding to the code in different programming languages and having a calling relationship, thereby meeting the debugging needs of programmers.
[0009] In a possible implementation manner of the first aspect, the obtaining of the first debugging information corresponding to the first code segment includes: setting a first breakpoint at the first code segment when the source code is in the pre-compilation stage, the first code segment being a caller that calls the second code segment in the calling relationship; obtaining the first debugging information corresponding to the first code segment, storing the first debugging information, and continuing to run the source code at a position of the first breakpoint when the source code is in the debugging stage and the first code segment is interrupted by the first breakpoint.
[0010] In a possible implementation manner of the first aspect, the second debugging information corresponding to the second code segment is displayed in the debugging interface, including: when the second code segment is interrupted by a second breakpoint, the second debugging information corresponding to the second code segment is acquired, and the second debugging information is displayed in the debugging interface, the second breakpoint being a breakpoint set by a user at the second code segment when the source code is in a writing stage.
[0011] In a possible implementation manner of the first aspect, the second debugging information at least includes the second breakpoint, a call stack, and a variable.
[0012] In a possible implementation manner of the first aspect, a key frame is added in a call stack window in the debugging interface, the call stack window being used to display the call stack, and the key frame being located at a bottom of the call stack.
[0013] In a second aspect, the present application provides an electronic device, including one or more processors and a memory, the memory being used to store instructions, and the processor being used to execute the instructions to enable the electronic device to perform the following operations: when source code in an integrated development environment is in a pre-compilation stage, determining a call relationship in the source code, the call relationship including that a first code segment calls a second code segment, the first code segment and the second code segment being different programming languages; acquiring first debugging information corresponding to the first code segment; when the source code is in a debugging stage, displaying second debugging information corresponding to the second code segment in a debugging interface, the pre-compilation stage being earlier than the debugging stage; determining whether the second code segment is called according to the call relationship; when it is determined according to the call relationship that the second code segment is called by the first code segment, adding a key frame in the debugging interface and establishing a corresponding relationship between the key frame and the first debugging information; when a trigger instruction input by a user to the key frame is received, acquiring the first debugging information corresponding to the key frame and displaying the first debugging information in the debugging interface.
[0014] In a possible implementation manner of the second aspect, the processor is specifically used to execute the instructions to enable the electronic device to perform the following operations: when the source code is in the pre-compilation stage, setting a first breakpoint at the first code segment, the first code segment being a caller that calls the second code segment in the call relationship; when the source code is in the debugging stage and the first code segment is interrupted by the first breakpoint, acquiring first debugging information corresponding to the first code segment, storing the first debugging information, and continuing to run the source code at a position of the first breakpoint.
[0015] In a possible implementation manner of the second aspect, the processor is specifically used to execute the instructions to enable the electronic device to perform the following operations: when the second code segment is interrupted by a second breakpoint, acquiring second debugging information corresponding to the second code segment, and displaying the second debugging information in the debugging interface, the second breakpoint being a breakpoint set by a user at the second code segment when the source code is in a writing stage.
[0016] In one possible implementation of the second aspect, the second debugging information includes at least the second breakpoint, call stack, and variables.
[0017] In one possible implementation of the second aspect, the processor is specifically used to execute instructions to cause the electronic device to do the following: add a keyframe to the call stack window in the debug interface, the call stack window being used to display the call stack, with the keyframe located at the bottom of the call stack.
[0018] Thirdly, embodiments of this application provide a computer-readable storage medium storing software code that, when read by one or more processors, can execute the first aspect or each possible implementation of the first aspect. Attached Figure Description
[0019] Figure 1 A schematic diagram of the existing integrated development environment 100 system architecture;
[0020] Figure 2 A schematic diagram of the interface in the first state of the integrated development environment 100;
[0021] Figure 3 A schematic diagram of the interface of Integrated Development Environment 100 in its second state;
[0022] Figure 4 A schematic diagram of the system architecture of the integrated development environment 200 provided in this application;
[0023] Figure 5 A schematic diagram of the interface in the first state of the integrated development environment 200;
[0024] Figure 6 A schematic diagram of the interface in the second state of the integrated development environment 200;
[0025] Figure 7 A schematic diagram of the modules of the integrated development environment 200 provided for this application;
[0026] Figure 8 A flowchart of a multilingual mixed debugging method provided in this application;
[0027] Figure 9 A schematic diagram of an electronic device provided in this application. Detailed Implementation
[0028] The following is through Figures 1 to 3 The example shown illustrates the system architecture of the existing integrated development environment 100 and the problems existing in the existing integrated development environment 100.
[0029] Please see Figure 1 As shown,Figure 1 This is a schematic diagram of the system architecture of the existing integrated development environment 100. The system architecture of the existing integrated development environment 100 includes a debugging service layer and a base layer. The debugging service layer includes Java debugging service 11 and C++ debugging service 12. The base layer includes project management 13, compilation and build 14, code editing 15, UI design 16, run / debug 17 and device management 18.
[0030] exist Figure 1 In the example shown, the components included in the base layer are all basic functional components commonly used in integrated development environments (IDEs). The debugging service in the debugging service layer is a multi-language debugging component of an IDE. Of course, Figure 1 The example shown is merely one provided in this application. In practice, there may be debugging services for more programming languages within the debugging service layer.
[0031] Please see Figure 2 and Figure 3 As shown, Figure 2 This is a schematic diagram of the interface in the first state of the integrated development environment 100. Figure 3 This is a schematic diagram of the integrated development environment 100 in its second state. The first state of the integrated development environment 100 refers to the programming interface 101 displaying Java programming window A, and the second state refers to the programming interface 101 displaying C++ programming window B. When programming interface 101 displays Java programming window A, the programmer can write code using the Java programming language within Java programming window A. When programming interface 101 displays C++ programming window B, the programmer can write code using the C++ programming language within C++ programming window B.
[0032] exist Figure 2 and Figure 3 In the example shown, the integrated development environment 100 includes a programming interface 101 and a debugging interface 102. The programming interface 101 can display either a Java programming window A or a C++ programming window B. Programmers can switch between Java programming window A and C++ programming window B at will by clicking commands or using shortcut keys. Programmers can write program code in Java programming window A and C++ programming window B respectively. The debugging interface 102 includes a call stack window C and a variable window D. The call stack window C is used to display the call stack corresponding to the interrupted code in the programming interface 101, and the variable window D is used to display the variables corresponding to the interrupted code in the programming interface 101.
[0033] For example, please refer to... Figure 2 and Figure 3As shown, when the programmer was writing the program, line 30 of the Java programming window A called lines 8-10 of the C++ programming window B. To determine if there was an error in lines 8-10 of the C++ programming window B, the programmer set a breakpoint G1 at line 8 of the C++ programming window B.
[0034] When the programmer clicks the debug button on the integrated development environment 100, the integrated development environment 100 enters debug mode. Then, the integrated development environment 100 runs the code in Java programming window A. When it reaches line 30 of the code in Java programming window A, based on the call relationship between line 30 of Java programming window A and lines 8-10 of the code in C++ programming window B, the program continues to run line 8 of the code in C++ programming window B. Since breakpoint G1 is set on line 8 of the code in C++ programming window B, the integrated development environment 100 obtains the debug information x1 corresponding to line 8 of the code in C++ programming window B. Debug information x1 includes call stack c1 and variable d1. Next, the call stack c1 from debug information x1 is displayed in call stack window C of debug interface 102, and the variable d1 from debug information x1 is displayed in variable window D of debug interface 102.
[0035] At this point, the programmer can see debugging information x1 corresponding to line 8 of the C++ programming window B within the debugging interface 102. However, in order to comprehensively analyze whether the parameter passing and calls at line 30 of the Java programming window A affect line 8 of the C++ programming window B, the programmer wants the debugging interface to be able to trace back from debugging information x1 corresponding to line 8 of the C++ programming window B to debugging information x2 corresponding to line 30 of the Java programming window A. However, the existing debugging interface 102 of the integrated development environment 100 cannot switch the currently displayed debugging information x1 to debugging information x2, so the existing integrated development environment 100 cannot meet the programmer's debugging needs.
[0036] The following is through Figures 4 to 7 The example shown illustrates the system architecture of the integrated development environment 200 provided in this application, and how the integrated development environment 200 provided in this application solves the problems existing in the prior art.
[0037] Please see Figure 4 As shown, Figure 4The schematic diagram of the system architecture of the integrated development environment 200 provided by the present application is shown in the figure. The system architecture of the integrated development environment 200 provided by the present application includes a debugging information layer, a debugging service layer and a basic layer. The debugging information layer includes a debugging information switching service 21 and a debugging information storage service 22. The debugging service layer includes a Java debugging service 23 and a C++ debugging service 24. The basic layer includes project management 25, compilation and building 26, code editing 27, UI design 28, running / debugging 29 and device management 30.
[0038] In the example shown in the figure, each component included in the basic layer belongs to the basic functional component commonly used by the integrated development environment. Figure 4 The debugging services in the debugging service layer belong to the multi-language mixed debugging component of the integrated development environment. Of course, Figure 4 The example shown in the figure is only one example provided by the present application. In actual cases, there can be more debugging services for more programming languages in the debugging service layer. The debugging information layer provides services provided by the present application. The debugging information switching service 21 is used to switch the corresponding call stack and variables in the debugging interface. The debugging information storage service 22 is used to store the debugging information.
[0039] The following examples will be used to illustrate how the integrated development environment 200 provided by the present application solves the problems existing in the prior art. Figure 5 The integrated development environment 200 uses the multi-language mixed debugging method provided by the present application. Figure 6 Please refer to
[0040] and Figure 5 , Figure 6 , Figure 5 The interface schematic diagram of the integrated development environment 200 in the first state is shown in the figure. Figure 6 The interface schematic diagram of the integrated development environment 200 in the second state is shown in the figure. The integrated development environment 200 in the first state means that the programming interface 201 displays the Java programming window A. The integrated development environment 200 in the second state means that the programming interface 201 displays the C++ programming window B.
[0041] In the example shown in the figure, the integrated development environment 200 includes a programming interface 201 and a debugging interface 202. The programming interface 201 can display the Java programming window A or the C++ programming window B. The debugging interface 202 includes a call stack window C and a variable window D. Figure 5 Figure 6 In the example shown in the figure, the integrated development environment 200 includes a programming interface 201 and a debugging interface 202. The programming interface 201 can display the Java programming window A or the C++ programming window B. The debugging interface 202 includes a call stack window C and a variable window D.
[0042] In the example shown in the figure, the integrated development environment 200 includes a programming interface 201 and a debugging interface 202. The programming interface 201 can display the Java programming window A or the C++ programming window B. The debugging interface 202 includes a call stack window C and a variable window D. Figure 5 Figure 6 As shown, the 30th line of code in the Java programming window A invokes the 8th-10th lines of code in the C++ programming window B. To determine whether the 8th-10th lines of code in the C++ programming window B have errors, the programmer sets a breakpoint Gl at the 8th line of code in the C++ programming window B. When the programmer clicks a debug button on the integrated development environment 200, the integrated development environment 200 enters a debug state. The debug state includes a pre-compile phase and a debug phase, and the pre-compile phase is earlier than the debug phase.
[0043] First, when the integrated development environment 200 enters the pre-compile phase of the debug state, the integrated development environment 200 determines a call relationship H between the code in the Java programming window A and the code in the C++ programming window B. The call relationship H includes that the 30th line of code in the Java programming window A invokes the 8th-10th lines of code in the C++ programming window B. Since the 30th line of code in the Java programming window A is the invoker of the code, the integrated development environment 200 sets a temporary breakpoint G2 at the 30th line of code in the Java programming window A. The temporary breakpoint G2 is used to obtain the debug information yl corresponding to the 30th line of code in the Java programming window A when the integrated development environment 200 enters the debug phase of the debug state.
[0044] Second, when the integrated development environment 200 enters the debug phase of the debug state, the integrated development environment 200 runs the code in the Java programming window A. When the 30th line of code in the Java programming window A is reached, the program is interrupted by the temporary breakpoint G2 since the temporary breakpoint G2 is set at the 30th line of code in the Java programming window A. The integrated development environment 200 obtains the debug information yl corresponding to the 30th line of code in the Java programming window A and stores the debug information yl in the memory so that the debug information yl can be obtained at any time. After the debug information yl is stored, the integrated development environment 200 continues to run the program code at the temporary breakpoint G2 according to a pre-set continue running instruction.
[0045] Again, since the code in line 30 in the Java programming window A invokes the code in lines 8-10 in the C++ programming window B, the integrated development environment 200 continues to run the code in line 8 in the C++ programming window B. When the integrated development environment 200 runs the code in line 8 in the C++ programming window B, since the programmer has previously set a breakpoint G1 at the code in line 8 in the C++ programming window B, the program is interrupted by the breakpoint G1, and the integrated development environment 200 acquires the debugging information y2 corresponding to the code in line 8 in the C++ programming window B, where the debugging information y2 includes the call stack c2 and the variable d2. Specifically, the integrated development environment 200 displays the call stack c2 in the debugging information y2 in the call stack window C of the debugging interface 202, and displays the variable d2 in the debugging information y2 in the variable window D of the debugging interface 202.
[0046] Then, the integrated development environment 200 determines whether the code in line 8 in the C++ programming window B is invoked by other programming languages according to the predetermined invocation relationship H. After analysis, it can be found that the invocation relationship H includes that the code in line 30 in the Java programming window A invokes the code in lines 8-10 in the C++ programming window B, so the integrated development environment 200 can determine that the code in line 8 in the C++ programming window B is invoked by the code in line 30 in the Java programming window A. At this time, the integrated development environment 200 adds a key frame q1 at the bottom of the call stack window C of the debugging interface 202, and establishes a corresponding relationship between the key frame q1 and the debugging information y1, so that after the user clicks the key frame q1, the debugging interface 202 can display the debugging information y1 corresponding to the key frame q1.
[0047] Finally, the current debugging interface 202 displays the debugging information y2 corresponding to the code in line 8 in the C++ programming window B. If the programmer needs to comprehensively analyze whether the parameter passing and invocation at the code in line 30 in the Java programming window A affect the code in line 8 in the C++ programming window B, the programmer can click the key frame q1 in the call stack window C of the debugging interface 202. After the programmer clicks the key frame q1 in the call stack window C of the debugging interface 202, the integrated development environment 200 acquires the debugging information y1 corresponding to the key frame q1. Wherein the debugging information y1 includes the call stack c1 and the variable d1. Specifically, the integrated development environment 200 displays the call stack c1 in the debugging information y1 in the call stack window C of the debugging interface 202, and displays the variable d1 in the debugging information y1 in the variable window D of the debugging interface 202. Therefore, the integrated development environment 200 provided by the present application can trace the debugging information corresponding to the codes between different programming languages and having an invocation relationship, thereby meeting the debugging needs of the programmer.
[0048] Please refer toFigure 7 as shown, Figure 7 a module schematic diagram of the integrated development environment 200 provided in the present application, Figure 7 the module schematic diagram shown is from the perspective of internal modules of the integrated development environment 200, Figure 5 and Figure 6 shows the flow of the debugging information.
[0049] In Figure 7 the example shown, in combination with Figure 5 and Figure 6 the example shown, Figure 7 the example shown shows four key steps, S1 to S4. S1 to S4 are only part of the key processes of the schemes shown in Figure 5 and Figure 6 S1 to S4 are used to more clearly show the flow of the debugging information y1 and the debugging information y2. In Figure 5 and Figure 6 the example shown, it is mentioned that the debugging information y1 is the debugging information corresponding to the 30th line of code in the Java programming window A, and the debugging information y2 is the debugging information corresponding to the 8th line of code in the C++ programming window B, and the 30th line of code in the Java programming window A calls the 8th line of code in the C++ programming window B. Among them:
[0050] S1, the debugging service 203 sends the debugging information y1 to the debugging information storage module 204.
[0051] S2, the debugging service 203 sends the debugging information y2 to the debugging interface 202.
[0052] Among them, after S2, the call stack of the debugging information y2 is displayed in the call stack window C of the debugging interface 202, the variables of the debugging information y2 are displayed in the variable window D of the debugging interface 202, and the key frame q1 is generated at the bottom of the call stack window C.
[0053] S3, after the programmer clicks the key frame q1, the debugging interface 202 sends an instruction to obtain the debugging information y1 to the debugging information storage module 204.
[0054] S4, the debugging information storage module 204 sends the debugging information y1 to the debugging interface 202.
[0055] Among them, after S4, the call stack of the debugging information y1 is displayed in the call stack window C of the debugging interface 202, the variables of the debugging information y1 are displayed in the variable window D of the debugging interface 202, and at this time, the call stack window C no longer has the key frame q1.
[0056] Through Figure 7As shown in the examples, the debugging service 203 needs to store the debugging information y1 in advance into the debugging information storage module 204. When the debugging interface 202 displays the debugging information y2, the key frame q1 also needs to be displayed. Finally, when the programmer clicks the key frame q1, the debugging information storage module 204 sends the pre-stored debugging information y1 to the debugging interface 202, so that the debugging interface 202 can display the debugging information y1.
[0057] Please refer to Figure 8 As shown, Figure 8 A flowchart of a multi-language mixed debugging method provided in the present application. Figure 8 The multi-language mixed debugging method shown is applied to an integrated development environment with source code, wherein the source code at least includes a first code segment and a second code segment. Figure 8 The multi-language mixed debugging method shown can realize the tracing of debugging information corresponding to code in different programming languages and having a calling relationship, Figure 8 The method shown includes steps S101-S106.
[0058] S101, when the source code is in a pre-compile stage, determining a calling relationship in the source code.
[0059] The pre-compile stage is a replacement work of code text, and the pre-compile stage is the first work in the entire compilation process. The calling relationship includes that the first code segment calls the second code segment, and the first code segment and the second code segment are different programming languages.
[0060] For S101, the integrated development environment 200 shown in Figure 3 and Figure 4 The examples provided in the present application, the source code of the integrated development environment 200 includes the code in the Java programming window A and the code in the C++ programming window B, and the calling relationship H includes that the 30th line of code in the Java programming window A calls the 8-10th line of code in the C++ programming window B.
[0061] S102, obtaining first debugging information corresponding to the first code segment.
[0062] There are many ways to obtain the first debugging information corresponding to the first code segment, and one specific method is introduced below, which includes the following steps: when the source code is in a pre-compile stage, setting a first breakpoint at the first code segment, and the first code segment is a caller of the second code segment in the calling relationship. When the source code is in a debugging stage and the first code segment is interrupted by the first breakpoint, obtain the first debugging information corresponding to the first code segment, store the first debugging information, and continue to run the source code at the position of the first breakpoint.
[0063] For S102, the integrated development environment 200 shown inFigure 3 and Figure 4 According to the example shown in FIG. 1 and FIG. 2, the integrated development environment 200 provided by the present application can obtain the debugging information y1 corresponding to the 30th line of code in the Java programming window A.
[0064] S103, display the second debugging information corresponding to the second code segment in the debugging interface when the source code is in the debugging stage.
[0065] The pre-compilation stage is earlier than the debugging stage. Moreover, the second debugging information at least includes the second breakpoint, the call stack and the variable.
[0066] Moreover, there are many ways to display the second debugging information corresponding to the second code segment in the debugging interface. Hereinafter, a specific method is introduced, which includes the following steps: when the second code segment is interrupted by the second breakpoint, obtain the second debugging information corresponding to the second code segment, and display the second debugging information in the debugging interface. The second breakpoint is the breakpoint set by the user in the second code segment when the source code is in the writing stage.
[0067] For S103, the example shown in FIG. 1 and FIG. 2 can be combined. Figure 3 and Figure 4 According to the example shown in FIG. 1 and FIG. 2, the debugging interface 202 of the integrated development environment 200 provided by the present application can display the debugging information y2 corresponding to the 8th line of code in the C++ programming window B. Specifically, the integrated development environment 200 displays the call stack c2 in the debugging information y2 in the call stack window C of the debugging interface 202, and displays the variable d2 in the debugging information y2 in the variable window D of the debugging interface 202.
[0068] S104, determine whether the second code segment is called according to the call relationship.
[0069] For S104, the example shown in FIG. 1 and FIG. 2 can be combined. Figure 3 and Figure 4 According to the example shown in FIG. 1 and FIG. 2, the integrated development environment 200 provided by the present application can determine whether the 8th line of code in the C++ programming window B is called by other programming languages according to the predetermined call relationship H. After analysis, it can be known that the call relationship H includes that the 30th line of code in the Java programming window A calls the 8th-10th line of code in the C++ programming window B, so the integrated development environment 200 can determine that the 8th line of code in the C++ programming window B is called by the 30th line of code in the Java programming window A.
[0070] S105, add a key frame in the debugging interface and establish the corresponding relationship between the key frame and the first debugging information when it is determined that the second code segment is called by the first code segment according to the call relationship.
[0071] There are many ways to add a key frame in the debugging interface, and a specific method is introduced below, which includes the following steps: adding a key frame in the call stack window in the debugging interface, the call stack window is used to display the call stack, and the key frame is located at the bottom of the call stack.
[0072] For S105, in combination with the examples shown in Figure 3 and Figure 4 , when the integrated development environment 200 determines that the code in the 8th line of the C++ programming window B is called by the code in the 30th line of the Java programming window A, the integrated development environment 200 will add a key frame q1 at the bottom of the call stack window C in the debugging interface 202, and establish a corresponding relationship between the key frame q1 and the debugging information y1, so that after the user clicks the key frame q1, the debugging interface 202 can display the debugging information y1 corresponding to the key frame q1.
[0073] S106, when receiving the trigger instruction input by the user to the key frame, obtaining the first debugging information corresponding to the key frame, and displaying the first debugging information in the debugging interface.
[0074] The trigger instruction can be an instruction generated by the programmer clicking the key frame with the mouse, or an instruction generated by the programmer inputting a shortcut key with the keyboard.
[0075] For S106, in combination with the examples shown in Figure 3 and Figure 4 , after the programmer clicks the key frame q1 in the call stack window C of the debugging interface 202, the integrated development environment 200 provided by the present application will obtain the debugging information y1 corresponding to the key frame q1. The debugging information y1 includes the call stack c1 and the variable d1. Specifically, the integrated development environment 200 will display the call stack c1 in the debugging information y1 in the call stack window C of the debugging interface 202, and then display the variable d1 in the debugging information y1 in the variable window D of the debugging interface 202.
[0076] In Figure 8In the embodiment shown, when the source code is in the pre-compiled stage, the integrated development environment can learn that the first code segment in the source code calls the second code segment and the first code segment and the second code segment are different programming languages by determining the call relationship in the source code. The integrated development environment needs to obtain the first debugging information corresponding to the first code segment, that is, the debugging information of the caller. When the second debugging information corresponding to the second code segment is displayed in the debugging interface, the integrated development environment needs to determine whether the second code segment is called according to the call relationship. When it is determined according to the call relationship that the second code segment is called by the first code segment, a key frame is added in the debugging interface, and a corresponding relationship between the key frame and the first debugging information is established, so that when a trigger instruction input by a user to the key frame is received, the integrated development environment can obtain the first debugging information corresponding to the key frame and display the first debugging information in the debugging interface. Therefore, the integrated development environment provided in the present application can realize the tracing of the debugging information corresponding to the code in different programming languages and having a call relationship, thereby meeting the debugging needs of programmers.
[0077] Please refer to Figure 9 shown, Figure 9 A schematic diagram of an electronic device is provided in the present application. Figure 9 The electronic device shown includes a processor 61 and a memory 62.
[0078] In Figure 9 In the embodiment shown, the processor 61 is configured to execute instructions stored in the memory 62 to cause the electronic device to perform the following operations: when the source code in the integrated development environment is in the pre-compiled stage, determining the call relationship in the source code, the call relationship including that the first code segment calls the second code segment, and the first code segment and the second code segment being different programming languages; obtaining the first debugging information corresponding to the first code segment; when the source code is in the debugging stage, displaying the second debugging information corresponding to the second code segment in the debugging interface, the pre-compiled stage being earlier than the debugging stage; determining whether the second code segment is called according to the call relationship; when it is determined according to the call relationship that the second code segment is called by the first code segment, adding a key frame in the debugging interface and establishing a corresponding relationship between the key frame and the first debugging information; and when a trigger instruction input by a user to the key frame is received, obtaining the first debugging information corresponding to the key frame and displaying the first debugging information in the debugging interface.
[0079] The processor 61 is one or more CPUs. Optionally, the CPU is a single-core CPU or a multi-core CPU.
[0080] The memory 62 includes, but is not limited to, random access memory (RAM), read only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), flash memory, or any other memory storage technology. The memory 62 stores code and / or data representing one or more applications, including the operating system.
[0081] Optionally, the electronic device further includes a bus 63, and the processor 61 and the memory 62 are connected with each other through the bus 63, and can also be connected with each other in other manners.
[0082] Each of the embodiments in the specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other. Each of the embodiments focuses on the difference from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant part can be referred to the part of the method embodiment.
[0083] Obviously, those skilled in the art can make various modifications and variations to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application belong to the scope of the claims of the present application, the present application also intends to include these modifications and variations.
Claims
1. A multi-language mixed debugging method, characterized by, The method is applied to an integrated development environment with source code, the source code at least including a first code segment and a second code segment, and the method comprises: determining a calling relationship in the source code when the source code is in a pre-compile stage, the calling relationship comprising that the first code segment calls the second code segment, and the first code segment and the second code segment being different programming languages; obtaining first debugging information corresponding to the first code segment, the first debugging information comprising a call stack and variables of the first code segment; displaying second debugging information corresponding to the second code segment in a debugging interface when the source code is in a debugging stage, the pre-compile stage being earlier than the debugging stage, the debugging interface comprising a call stack window and a variable window, the call stack window being used for displaying a call stack corresponding to interrupted code, and the variable window being used for displaying variables corresponding to the interrupted code; determining whether the second code segment is called according to the calling relationship; adding a key frame in the call stack window of the debugging interface and establishing a corresponding relationship between the key frame and the first debugging information when it is determined that the second code segment is called by the first code segment according to the calling relationship; obtaining the first debugging information corresponding to the key frame and displaying the first debugging information in the debugging interface when a trigger instruction input by a user to the key frame is received.
2. The method of claim 1, wherein, The obtaining of the first debugging information corresponding to the first code segment comprises: setting a first breakpoint at the first code segment when the source code is in the pre-compile stage, the first code segment being a caller of the second code segment in the calling relationship; obtaining the first debugging information corresponding to the first code segment when the first code segment is interrupted by the first breakpoint when the source code is in the debugging stage, storing the first debugging information, and continuing to run the source code at a position of the first breakpoint.
3. The method according to claim 1 or 2, characterized in that, The displaying of the second debugging information corresponding to the second code segment in the debugging interface comprises: obtaining the second debugging information corresponding to the second code segment and displaying the second debugging information in the debugging interface when the second code segment is interrupted by a second breakpoint, the second breakpoint being a breakpoint set by a user at the second code segment when the source code is in a writing stage.
4. The method of claim 3, wherein: the second debugging information at least comprises the second breakpoint, a call stack, and variables.
5. The method of claim 4, wherein, The adding of the key frame in the debugging interface comprises: adding the key frame in a call stack window of the debugging interface, the call stack window being used for displaying the call stack, and the key frame being located at a bottom of the call stack.
6. An electronic device, comprising: The electronic device comprises one or more processors and a memory, the memory being used for storing instructions; the processor is used for executing the instructions to enable the electronic device to perform the following operations: In a pre-compile stage of source code in an integrated development environment, a calling relationship in the source code is determined, the calling relationship comprising a first code segment calling a second code segment, the first code segment and the second code segment being in different programming languages; first debugging information corresponding to the first code segment is obtained, the first debugging information comprising a call stack and variables of the first code segment; In a debug stage of the source code, second debugging information corresponding to the second code segment is displayed in a debug interface, the pre-compile stage being earlier than the debug stage, the debug interface comprising a call stack window and a variable window, the call stack window being used to display a call stack corresponding to interrupted code, and the variable window being used to display variables corresponding to the interrupted code; It is determined whether the second code segment is called according to the calling relationship; When it is determined that the second code segment is called by the first code segment according to the calling relationship, a key frame is added in the call stack window of the debug interface, and a corresponding relationship between the key frame and the first debugging information is established; When a trigger instruction input by a user to the key frame is received, the first debugging information corresponding to the key frame is obtained, and the first debugging information is displayed in the debug interface.
7. The electronic device of claim 6, wherein, The processor is specifically configured to execute the instructions, so that the electronic device performs the following operations: In the pre-compile stage of the source code, a first breakpoint is set at the first code segment, the first code segment being a caller of the second code segment in the calling relationship; In the debug stage of the source code and when the first code segment is interrupted by the first breakpoint, first debugging information corresponding to the first code segment is obtained, the first debugging information is stored, and the source code is continued to be run at a position of the first breakpoint.
8. The electronic device of claim 6 or 7, wherein, The processor is specifically configured to execute the instructions, so that the electronic device performs the following operations: In the debug stage of the source code and when the second code segment is interrupted by a second breakpoint, second debugging information corresponding to the second code segment is obtained, and the second debugging information is displayed in the debug interface, the second breakpoint being a breakpoint set by a user at the second code segment in a writing stage of the source code.
9. The electronic device of claim 8, wherein: The second debugging information at least comprises the second breakpoint, a call stack, and variables.
10. The electronic device of claim 9, wherein, The processor is specifically configured to execute the instructions, so that the electronic device performs the following operations: The key frame is added in a call stack window in the debug interface, the call stack window being used to display the call stack, and the key frame being located at a bottom of the call stack.
11. A computer storage medium, characterized in that Computer software instructions for storage of an electronic device, comprising a program designed for executing a method as claimed in any one of claims 1-5.
Citation Information
Patent Citations
Method and system for debugging a program
US20140282415A1