Debugging methods, devices and systems

CN115964262BActive Publication Date: 2026-08-14HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-08
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

该调试方式不仅操作复杂,而且存在资源消耗大、调试时延高等问题

Benefits of technology

[0035] Sixthly, embodiments of this application provide a debugging apparatus, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to implement one or more of the debugging methods of the first aspect or multiple possible implementations of the first aspect when executing the instructions, or to implement one or more of the debugging methods of the second aspect or multiple possible implementations of the second aspect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115964262B_ABST
    Figure CN115964262B_ABST
Patent Text Reader

Abstract

This application relates to a debugging method, apparatus, and system. The debugging method includes: when a debugger receives a first debugging request to debug an application, processing the first debugging request according to a preset debugging protocol to obtain a second debugging request; the first source code of the application is written in multiple languages; sending the second debugging request to a lower-level machine so that the lower-level machine's debugging service debugs the target bytecode according to the second debugging request; when the debugger receives a debugging response from the debugging service corresponding to the second debugging request, converting the first debugging result in the debugging response into a second debugging result corresponding to the target language type; and displaying the second debugging result. Embodiments of this application, through a single debugger and debugging service, can debug applications developed in multiple languages, reducing resource consumption and debugging latency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a debugging method, apparatus and system. Background Technology

[0002] With the development of information technology (IT), programming languages ​​have evolved from the initial assembly language to embedded programming languages ​​(such as C), object-oriented high-level languages ​​(such as Java), and front-end development languages ​​(such as JavaScript). Since each language has its own advantages, an application typically uses different languages ​​to implement different functional components; that is, applications are often developed through a multi-language hybrid approach.

[0003] During application debugging, each language provides corresponding debuggers and debugging services to help developers troubleshoot and locate problems. However, when debugging applications developed in multiple languages, it is usually necessary to start multiple debuggers on the host computer (i.e., the device on which the developer debugs the code) and multiple debugging services on the slave computer (i.e., the terminal device, such as a mobile phone or tablet). This debugging method is not only complex to operate, but also suffers from high resource consumption and high debugging latency. Summary of the Invention

[0004] In view of this, a debugging method, device and system are proposed.

[0005] In a first aspect, embodiments of this application provide a debugging method applied to a host computer, the host computer including a debugger, the method comprising: when the debugger receives a first debugging request for debugging an application, processing the first debugging request according to a preset debugging protocol to obtain a second debugging request, wherein the first source code of the application is written in multiple types of languages; sending the second debugging request to a lower-level computer, so that the debugging service of the lower-level computer debugs the target bytecode according to the second debugging request, wherein the target bytecode is bytecode with a unified format generated after compiling the first source code in debug mode; when the debugger receives a debugging response sent by the debugging service corresponding to the second debugging request, converting a first debugging result in the debugging response into a second debugging result corresponding to the target language type according to the target language type in the debugging response; and displaying the second debugging result.

[0006] In the embodiments of this application, when the debugger of the host computer receives a first debugging request for an application written in multiple languages, it can convert the language-type-related first debugging request into a language-type-independent second debugging request according to a preset debugging protocol, and then send it to the lower computer so that the debugging service of the lower computer can debug the target bytecode (bytecode with a unified format generated after compiling the first source code). When the debugger receives the debugging response sent by the debugging service of the lower computer corresponding to the second debugging request, it can convert the language-type-independent first debugging result in the debugging response into a second debugging result corresponding to the target language type according to the target language type in the debugging response, and display it. Thus, an application developed in multiple languages ​​can be debugged through a single debugger and debugging service, which can not only reduce resource consumption and debugging latency, but also improve the user experience during debugging, thereby achieving the integration and unification of debugging of applications developed in multiple languages.

[0007] According to the first aspect, in a first possible implementation of the debugging method, the method further includes: compiling the first source code in debug mode to obtain the target bytecode with a uniform format, wherein the debugging information of the target bytecode includes the correspondence between each bytecode segment in the target bytecode and the language type; and pushing the target bytecode to the lower-level machine.

[0008] In the embodiments of this application, the first source code can be compiled in debug mode to obtain a target bytecode with a uniform format, and the target bytecode is pushed to the lower-level machine, so that the debugging service on the lower-level machine can be debugged based on the target bytecode with a uniform format, thereby shielding the differences caused by different languages.

[0009] According to the first aspect or the first possible implementation of the first aspect, in the second possible implementation of the debugging method, the first source code includes a plurality of second source codes, each of the second source codes being source code of a language type in the first source code, and the step of compiling the first source code in debug mode to obtain the target bytecode includes: for any second source code, compiling the second source code in debug mode using a compiler of the language type of the second source code to obtain first bytecode; converting the first bytecode into second bytecode according to the correspondence between the data type of the language type of the second source code and the data type of the target bytecode; and packaging the second bytecode of the plurality of second source codes to obtain the target bytecode.

[0010] In the embodiments of this application, the first source code can be divided into multiple second source codes, and each second source code can be compiled and bytecode converted to obtain second bytecode with a uniform format. Then, the second bytecode of multiple second source codes is packaged to obtain the target bytecode. This not only makes full use of the existing compilers of each language, but also allows for the simultaneous compilation of each second source code, thereby improving compilation efficiency.

[0011] According to any one of the first aspect, the first possible implementation of the first aspect, and the second possible implementation of the first aspect, in the third possible implementation of the debugging method, the step of converting the first debugging result in the debugging response into a second debugging result corresponding to the target language type according to the target language type in the debugging response includes: converting the first debugging result in the debugging response into a second debugging result corresponding to the target language type according to the correspondence between the data type of the target language type and the data type of the target bytecode.

[0012] In the embodiments of this application, a first debugging result based on the target bytecode and independent of the language type can be converted into a second debugging result corresponding to the target language type, which is simple, fast and convenient for the host computer to display the debugging result.

[0013] Secondly, embodiments of this application provide a debugging method applied to a lower-level machine. The lower-level machine includes target bytecode and a debugging service. The target bytecode is bytecode with a unified format generated after compiling a first source code of an application in debug mode. The first source code is written in multiple languages. The method includes: when the debugging service receives a second debugging request, determining the debugging location and target language type in the target bytecode based on the second debugging request and the debugging information of the target bytecode; debugging the target bytecode according to the debugging location to obtain a first debugging result; and sending a debugging response to a higher-level machine through the debugging service. The debugging response includes the first debugging result and the target language type.

[0014] In the embodiments of this application, when the lower-level machine's debugging service receives a second debugging request, it determines the debugging location and target language type of the target bytecode based on the second debugging request and the debugging information of the target bytecode. Based on the debugging location, it debugs the target bytecode to obtain a first debugging result. Then, it sends a debugging response including the first debugging result and the target language type to the upper-level machine. Thus, the target bytecode of a multi-language mixed-development application can be debugged through a debugging service on the lower-level machine, which not only reduces resource consumption during debugging but also reduces debugging latency, thereby improving debugging efficiency.

[0015] According to the second aspect, in a first possible implementation of the debugging method, the debugging information of the target bytecode includes the correspondence between each bytecode segment in the target bytecode and the language type. Determining the debugging location and target language type in the target bytecode based on the second debugging request and the debugging information of the target bytecode includes: parsing the second debugging request according to a preset debugging protocol to determine the code location to be debugged indicated by the second debugging request; and determining the debugging location of the target bytecode based on the code location and the debugging information.

[0016] In the embodiments of this application, the second debugging request can be parsed according to a preset debugging protocol to determine the code location to be debugged indicated by the second debugging request. Then, based on the code location and debugging information, the debugging location of the target bytecode can be determined so as to perform debugging based on the debugging location in the target bytecode.

[0017] According to the first possible implementation of the second aspect, in the second possible implementation of the debugging method, determining the debugging location and target language type in the target bytecode based on the second debugging request and the debugging information of the target bytecode further includes: determining the target debugging information of the bytecode segment to which the debugging location belongs from the debugging information; and determining the target language type from the target debugging information.

[0018] In the embodiments of this application, the target debugging information of the bytecode segment to which the debugging location belongs can be determined first from the debugging information, and then the target language type can be determined from the target debugging information. This is simple, fast, and can improve processing efficiency.

[0019] Thirdly, embodiments of this application provide a debugging system, comprising: a host computer, the host computer including a debugger, the host computer being configured to implement one or more debugging methods of the first aspect or multiple possible implementations of the first aspect; and a slave computer, the slave computer including target bytecode and debugging services, the slave computer being configured to implement one or more debugging methods of the second aspect or multiple possible implementations of the second aspect.

[0020] In the embodiments of this application, when the debugger of the host computer receives a first debugging request for an application written in multiple languages, it can convert the language-type-related first debugging request into a language-type-independent second debugging request according to a preset debugging protocol, and then send it to the lower computer so that the debugging service of the lower computer can debug the target bytecode (bytecode with a unified format generated after compiling the first source code). When the debugger receives the debugging response sent by the debugging service of the lower computer corresponding to the second debugging request, it can convert the language-type-independent first debugging result in the debugging response into a second debugging result corresponding to the target language type according to the target language type in the debugging response, and display it. Thus, an application developed in multiple languages ​​can be debugged through a single debugger and debugging service, which can not only reduce resource consumption and debugging latency, but also improve the user experience during debugging, thereby achieving the integration and unification of debugging of applications developed in multiple languages.

[0021] Fourthly, embodiments of this application provide a debugging device applied to a host computer, the host computer including a debugger, the device comprising: a debugging request processing module, configured to, when the debugger receives a first debugging request for debugging an application, process the first debugging request according to a preset debugging protocol to obtain a second debugging request, wherein the first source code of the application is written in multiple types of languages; a debugging request sending module, configured to send the second debugging request to a lower-level machine, so that the debugging service of the lower-level machine debugs the target bytecode according to the second debugging request, wherein the target bytecode is bytecode with a unified format generated after compiling the first source code in debug mode; a debugging result conversion module, configured to, when the debugger receives a debugging response sent by the debugging service corresponding to the second debugging request, convert the first debugging result in the debugging response into a second debugging result corresponding to the target language type according to the target language type in the debugging response; and a display module, configured to display the second debugging result.

[0022] In the embodiments of this application, when the debugger of the host computer receives a first debugging request for an application written in multiple languages, it can convert the language-type-related first debugging request into a language-type-independent second debugging request according to a preset debugging protocol, and then send it to the lower computer so that the debugging service of the lower computer can debug the target bytecode (bytecode with a unified format generated after compiling the first source code). When the debugger receives the debugging response sent by the debugging service of the lower computer corresponding to the second debugging request, it can convert the language-type-independent first debugging result in the debugging response into a second debugging result corresponding to the target language type according to the target language type in the debugging response, and display it. Thus, an application developed in multiple languages ​​can be debugged through a single debugger and debugging service, which can not only reduce resource consumption and debugging latency, but also improve the user experience during debugging, thereby achieving the integration and unification of debugging of applications developed in multiple languages.

[0023] According to the fourth aspect, in a first possible implementation of the debugging device, the device further includes: a compilation module, used to compile the first source code in debug mode to obtain the target bytecode with a uniform format, wherein the debugging information of the target bytecode includes the correspondence between each bytecode segment in the target bytecode and the language type; and a push module, used to push the target bytecode to the lower-level machine.

[0024] In the embodiments of this application, the first source code can be compiled in debug mode to obtain a target bytecode with a uniform format, and the target bytecode is pushed to the lower-level machine, so that the debugging service on the lower-level machine can be debugged based on the target bytecode with a uniform format, thereby shielding the differences caused by different languages.

[0025] According to the fourth aspect or the first possible implementation of the fourth aspect, in the second possible implementation of the debugging device, the first source code includes a plurality of second source codes, each of the second source codes being source code of a language type in the first source code, and the compilation module is configured to: compile any second source code in debug mode using a compiler of the language type of the second source code to obtain first bytecode; convert the first bytecode into second bytecode according to the correspondence between the data type of the language type of the second source code and the data type of the target bytecode; and package the second bytecode of the plurality of second source codes to obtain target bytecode.

[0026] In the embodiments of this application, the first source code can be divided into multiple second source codes, and each second source code can be compiled and bytecode converted to obtain second bytecode with a uniform format. Then, the second bytecode of multiple second source codes is packaged to obtain the target bytecode. This not only makes full use of the existing compilers of each language, but also allows for the simultaneous compilation of each second source code, thereby improving compilation efficiency.

[0027] According to any one of the fourth aspect, the first possible implementation of the fourth aspect, and the second possible implementation of the fourth aspect, in the third possible implementation of the debugging device, the debugging result conversion module is used to: convert the first debugging result in the debugging response into a second debugging result corresponding to the target language type according to the correspondence between the data type of the target language type and the data type of the target bytecode.

[0028] In the embodiments of this application, a first debugging result based on the target bytecode and independent of the language type can be converted into a second debugging result corresponding to the target language type, which is simple, fast and convenient for the host computer to display the debugging result.

[0029] Fifthly, embodiments of this application provide a debugging device applied to a lower-level machine. The lower-level machine includes target bytecode and a debugging service. The target bytecode is bytecode with a unified format generated after compiling a first source code of an application in debug mode. The first source code is written in multiple languages. The device includes: a location and language type determination module, used to determine the debugging location and target language type in the target bytecode based on the second debugging request and the debugging information of the target bytecode when the debugging service receives a second debugging request; a debugging module, used to debug the target bytecode according to the debugging location to obtain a first debugging result; and a debugging response sending module, used to send a debugging response to the upper-level machine through the debugging service, the debugging response including the first debugging result and the target language type.

[0030] In the embodiments of this application, when the lower-level machine's debugging service receives a second debugging request, it determines the debugging location and target language type of the target bytecode based on the second debugging request and the debugging information of the target bytecode. Based on the debugging location, it debugs the target bytecode to obtain a first debugging result. Then, it sends a debugging response including the first debugging result and the target language type to the upper-level machine. Thus, the target bytecode of a multi-language mixed-development application can be debugged through a debugging service on the lower-level machine, which not only reduces resource consumption during debugging but also reduces debugging latency, thereby improving debugging efficiency.

[0031] According to the fifth aspect, in a first possible implementation of the debugging device, the debugging information of the target bytecode includes the correspondence between each bytecode segment in the target bytecode and the language type. The position and language type determination module is used to: parse the second debugging request according to a preset debugging protocol to determine the code position to be debugged indicated by the second debugging request; and determine the debugging position of the target bytecode according to the code position and the debugging information.

[0032] In the embodiments of this application, the second debugging request can be parsed according to a preset debugging protocol to determine the code location to be debugged indicated by the second debugging request. Then, based on the code location and debugging information, the debugging location of the target bytecode can be determined so as to perform debugging based on the debugging location in the target bytecode.

[0033] According to the first possible implementation of the fifth aspect, in the second possible implementation of the debugging device, the location and language type determination module is further configured to: determine the target debugging information of the bytecode segment to which the debugging location belongs from the debugging information; and determine the target language type from the target debugging information.

[0034] In the embodiments of this application, the target debugging information of the bytecode segment to which the debugging location belongs can be determined first from the debugging information, and then the target language type can be determined from the target debugging information. This is simple, fast, and can improve processing efficiency.

[0035] Sixthly, embodiments of this application provide a debugging apparatus, comprising: a processor; a memory for storing processor-executable instructions; wherein the processor is configured to implement one or more of the debugging methods of the first aspect or multiple possible implementations of the first aspect when executing the instructions, or to implement one or more of the debugging methods of the second aspect or multiple possible implementations of the second aspect.

[0036] In the embodiments of this application, when the debugger of the host computer receives a first debugging request for an application written in multiple languages, it can convert the language-type-related first debugging request into a language-type-independent second debugging request according to a preset debugging protocol, and then send it to the lower computer so that the debugging service of the lower computer can debug the target bytecode (bytecode with a unified format generated after compiling the first source code). When the debugger receives the debugging response sent by the debugging service of the lower computer corresponding to the second debugging request, it can convert the language-type-independent first debugging result in the debugging response into a second debugging result corresponding to the target language type according to the target language type in the debugging response, and display it. Thus, an application developed in multiple languages ​​can be debugged through a single debugger and debugging service, which can not only reduce resource consumption and debugging latency, but also improve the user experience during debugging, thereby achieving the integration and unification of debugging of applications developed in multiple languages.

[0037] In a seventh aspect, embodiments of this application provide a non-volatile computer-readable storage medium storing computer program instructions thereon, characterized in that, when the computer program instructions are executed by a processor, they implement one or more debugging methods of the first aspect or multiple possible implementations of the first aspect, or implement one or more debugging methods of the second aspect or multiple possible implementations of the second aspect.

[0038] In the embodiments of this application, when the debugger of the host computer receives a first debugging request for an application written in multiple languages, it can convert the language-type-related first debugging request into a language-type-independent second debugging request according to a preset debugging protocol, and then send it to the lower computer so that the debugging service of the lower computer can debug the target bytecode (bytecode with a unified format generated after compiling the first source code). When the debugger receives the debugging response sent by the debugging service of the lower computer corresponding to the second debugging request, it can convert the language-type-independent first debugging result in the debugging response into a second debugging result corresponding to the target language type according to the target language type in the debugging response, and display it. Thus, an application developed in multiple languages ​​can be debugged through a single debugger and debugging service, which can not only reduce resource consumption and debugging latency, but also improve the user experience during debugging, thereby achieving the integration and unification of debugging of applications developed in multiple languages.

[0039] Eighthly, embodiments of this application provide a computer program product including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code. When the computer-readable code is run in an electronic device, the processor in the electronic device executes one or more of the debugging methods of the first aspect or multiple possible implementations of the first aspect, or executes one or more of the debugging methods of the second aspect or multiple possible implementations of the second aspect.

[0040] In the embodiments of this application, when the debugger of the host computer receives a first debugging request for an application written in multiple languages, it can convert the language-type-related first debugging request into a language-type-independent second debugging request according to a preset debugging protocol, and then send it to the lower computer so that the debugging service of the lower computer can debug the target bytecode (bytecode with a unified format generated after compiling the first source code). When the debugger receives the debugging response sent by the debugging service of the lower computer corresponding to the second debugging request, it can convert the language-type-independent first debugging result in the debugging response into a second debugging result corresponding to the target language type according to the target language type in the debugging response, and display it. Thus, an application developed in multiple languages ​​can be debugged through a single debugger and debugging service, which can not only reduce resource consumption and debugging latency, but also improve the user experience during debugging, thereby achieving the integration and unification of debugging of applications developed in multiple languages.

[0041] These and other aspects of this application will become more apparent in the description of the following embodiments(s). Attached Figure Description

[0042] The accompanying drawings, which are included in and form part of this specification, illustrate exemplary embodiments, features, and aspects of this application together with the specification and serve to explain the principles of this application.

[0043] Figure 1 This diagram illustrates the debugging process of an application developed using a multilingual approach.

[0044] Figure 2 A schematic diagram illustrating an application scenario of a debugging method according to an embodiment of this application is shown.

[0045] Figure 3 A flowchart illustrating a debugging method according to an embodiment of this application is shown.

[0046] Figure 4 A schematic diagram illustrating the compilation process for generating target bytecode according to an embodiment of this application is shown.

[0047] Figure 5A flowchart illustrating a debugging method according to an embodiment of this application is shown.

[0048] Figure 6 A schematic diagram illustrating the processing flow of a debugging method according to an embodiment of this application is shown.

[0049] Figure 7 A block diagram of a debugging apparatus according to an embodiment of this application is shown.

[0050] Figure 8 A block diagram of a debugging apparatus according to an embodiment of this application is shown. Detailed Implementation

[0051] Various exemplary embodiments, features, and aspects of this application will now be described in detail with reference to the accompanying drawings. The same reference numerals in the drawings denote elements that have the same or similar functions. Although various aspects of the embodiments are shown in the drawings, they are not necessarily drawn to scale unless specifically indicated otherwise.

[0052] The term “exemplary” as used herein means “serving as an example, embodiment, or illustration.” Any embodiment illustrated herein as “exemplary” is not necessarily to be construed as superior to or better than other embodiments.

[0053] Furthermore, to better illustrate this application, numerous specific details are provided in the following detailed embodiments. Those skilled in the art should understand that this application can be implemented without certain specific details. In some instances, methods, means, components, and circuits well-known to those skilled in the art have not been described in detail in order to highlight the main points of this application.

[0054] Currently, multi-language hybrid development of applications has become the norm. For example, the front-end user interface (UI) of an Android application is implemented in JavaScript (for example, for graphical rendering and layout control), the business logic is implemented in Java, and the implementation of the business logic may also rely on third-party components implemented in C. Then, the modules implemented in different languages ​​are combined and packaged to obtain the complete application.

[0055] However, regardless of the language used to develop applications, debugging remains an essential and unavoidable step for developers. Application debugging involves tracing the application's execution process to pinpoint the causes of operational anomalies, resolving bugs that exist during development, and ensuring the correctness of the application's functionality.

[0056] Each language typically provides a corresponding debugger and debugging service (also known as a debug object, used to manage the bytecode of the application being debugged) to help developers debug. However, when debugging applications developed in multiple languages, it is usually necessary to start multiple debuggers on the host computer and multiple debugging services on the slave computer.

[0057] Figure 1 This diagram illustrates the debugging process of a multilingual application. Figure 1 As shown, developers develop applications within an integrated development environment (IDE) on a host computer (e.g., Android Studio, DevEco Studio, IntelliJ IDE, etc.). This application is written in three languages: Java, JavaScript, and Cangjie. Accordingly, the application's source code includes Java source code, JavaScript source code, and Cangjie source code.

[0058] After the application is developed, it is compiled in debug mode, for example, using the -g option, to obtain the application's bytecode (including Java bytecode, JavaScript bytecode, and Cangjie bytecode). The obtained application bytecode is then pushed to the lower-level machine.

[0059] When debugging the application (written in Java, JavaScript, and Cangjie), a debugger is started on the host computer for each language: a Java debugger, a JavaScript debugger, and a Cangjie debugger. On the slave computer, a debugging service is started for each language: a Java debugging service, a JavaScript debugging service, and a Cangjie debugging service. Each language's debugger connects to its corresponding debugging service over the network; the Java debugger connects to the Java debugging service, the JavaScript debugger connects to the JavaScript debugging service, and the Cangjie debugger connects to the Cangjie debugging service. This allows for remote debugging of the application.

[0060] For example, when debugging the Java source code in the application, the developer enters debugging instructions for the Java source code in the integrated development environment of the host computer. These debugging instructions are sent to the Java debugger. The Java debugger sends the debugging instructions to the Java debugging service on the lower computer 20 according to the Java debug wire protocol (JDWP). After receiving the debugging instructions, the Java debugging service debugs the Java bytecode of the application according to the debugging instructions and obtains the debugging results.

[0061] Depend on Figure 1 As can be seen, since each language provides its own debugger and debugging services, debugging multi-language applications typically involves a combination of multiple debuggers and debugging services. Furthermore, debugging cross-language function calls in multi-language applications requires setting breakpoints at the called function beforehand, making the debugging process complex and resulting in a poor user experience.

[0062] For example, in a multi-language application, function F1 written in language A calls function F2 written in language B. To debug this cross-language function call step-by-step, first, on the host computer, compile the application's source code in debug mode, for example, using the -g option, to obtain the application's bytecode. Then, open the source code containing function F1 and set breakpoints on the valid lines of code before the call to function F2, and open the source code containing function F2 and set breakpoints on the valid lines of code for function F2. Next, push the application's bytecode to the slave computer and start debugging services for language A and language B on the slave computer. Then, start debuggers for language A and language B on the host computer and connect them to the debugging services for language A and language B on the slave computer via network. Finally, run the application on the slave computer. When it reaches the breakpoint in function F1, the application pauses and debugging begins, which can be done by stepping through the code. (If you enter a sub-function, you will step into it and continue single-stepping through it.) This will enter function F2, triggering the breakpoints set in function F2. You can then continue single-stepping through function F2 using step-in, such as to view variables and the call stack.

[0063] As can be seen from the above, unlike the debugging method of function calls in the same language (directly entering through step in), debugging cross-language function calls not only requires setting breakpoints at the called function in advance, but also involves complex debugging steps that are not true single-step execution, resulting in a poor user experience. Furthermore, each language corresponds to a separate set of debuggers and debugging services, and the number of debuggers and debugging services is proportional to the number of language types, leading to high debugging resource consumption, especially making debugging difficult on resource-sensitive terminal devices.

[0064] In addition, there is competition for resources such as ports, network bandwidth, memory, and processor between multiple debuggers or debugging services. Lower-level devices (such as mobile phones, PADs, watches, and other smart home terminals) usually have limited resources. Too many debugging services will affect the normal operation of the application, resulting in slow debugging response, high debugging latency, and even inconsistencies in program operation due to excessive processor utilization, which may prevent the application from being scheduled in time.

[0065] In some technical solutions, to improve the user experience during debugging, special markers, such as special annotations, are added to the interface functions called by functions in other languages ​​within the programming framework of the host computer's integrated development environment (IDE). The IDE also adds parsing functionality for these special markers. During debugging, the IDE automatically adds hidden breakpoints at the code with the special markers, eliminating the need for users to manually set breakpoints.

[0066] For example, in a multi-language application, function F1 written in language A calls function F2 written in language B. When debugging this cross-language function call step by step, the IDE will automatically set a hidden breakpoint for F2. The user does not need to set it manually. When debugging reaches the breakpoint of function F1, since the IDE has set the hidden breakpoint in advance, you can directly enter function F2 for debugging by step in.

[0067] However, this method requires special marking of the interface functions of the programming framework (including newly added interface functions), and the host computer's integrated development environment needs to provide the function of parsing special markings and setting hidden breakpoints, which has significant limitations. Moreover, this method still requires starting multiple debuggers and multiple debugging services, which still results in problems such as high resource consumption and high debugging latency. In addition, this method still debugs cross-language function calls by setting breakpoints, rather than true single-step execution.

[0068] To address the aforementioned technical problems, this application provides a debugging method. This debugging method, according to embodiments of the application, is applied to a host computer, which includes a debugger. When the debugger receives a first debugging request to debug an application, it processes the first debugging request according to a preset debugging protocol to obtain a second debugging request. The first source code of the application is written in multiple languages. Then, the second debugging request is sent to a lower-level computer so that the lower-level computer's debugging service debugs the target bytecode according to the second debugging request. The target bytecode is bytecode with a unified format generated after compiling the first source code in debug mode. When the debugger receives a debugging response from the debugging service corresponding to the second debugging request, it converts the first debugging result in the debugging response into a second debugging result corresponding to the target language type, based on the target language type in the debugging response, and displays the second debugging result.

[0069] In this way, when the debugger on the host computer receives a first debugging request for an application written in multiple languages, it can convert the language-type-related first debugging request into a language-type-independent second debugging request according to a preset debugging protocol, and then send it to the lower-level computer so that the lower-level computer's debugging service can debug the target bytecode (bytecode with a unified format generated after compiling the first source code). When the debugger receives a debugging response from the lower-level computer's debugging service corresponding to the second debugging request, it can convert the language-type-independent first debugging result in the debugging response into a second debugging result corresponding to the target language type, and display it. Thus, a single debugger and debugging service can be used to debug applications developed in multiple languages, which not only reduces resource consumption and debugging latency, but also improves the user experience during debugging, thereby achieving unified debugging of applications developed in multiple languages.

[0070] Figure 2 A schematic diagram illustrating an application scenario of a debugging method according to an embodiment of this application is shown. For example... Figure 2 As shown, a debugging system is provided, which includes a host computer 10 and a slave computer 20.

[0071] The host computer 10 is a device for developers to debug code, including a debugger 12. The first source code 11 on the host computer 10 is the source code of the application to be debugged, and the first source code 11 is written in multiple languages. That is, the application to be debugged is an application developed in a mixed language.

[0072] The lower-level device 20 is a terminal device, such as a mobile phone or tablet, that runs the target bytecode 21 of the application to be debugged. The lower-level device 20 includes a debugging service 22, which manages the target bytecode 21 during the debugging process. The target bytecode 21 is generated by the upper-level device 10 in debug mode from the first source code 11, producing bytecode of a unified format, and then pushed to the lower-level device 20. The target bytecode 21 includes debugging information. The debugger 12 in the upper-level device 10 and the debugging service 22 in the lower-level device 20 can be connected via a network.

[0073] During debugging, developers can send a first debugging request to debug the application to the debugger 12 through the integrated development environment (IDE) on the host computer 10. The first debugging request may include the language type, file name, function name, line number, etc. of the code to be debugged, that is, the first debugging request is related to the language type of the first source code 11. After receiving the first debugging request, the debugger 12 processes the first debugging request according to the preset debugging protocol to obtain a second debugging request that is independent of the language type, and sends the second debugging request to the lower computer 20.

[0074] The lower-level machine 20 receives a second debugging request through the debugging service 22. When the debugging service 22 receives the second debugging request, it determines the debugging location and target language type in the target bytecode 21 according to the second debugging request and the debugging information of the target bytecode 21 of the application, and debugs the target bytecode according to the debugging location to obtain a first debugging result; then, the debugging service 22 sends a debugging response to the upper-level machine 10, which includes the first debugging result and the target language type.

[0075] The host computer 10 receives the debugging response through the debugger 12. After receiving the debugging response, the debugger 12 converts the first debugging result in the debugging response into a second debugging result corresponding to the target language type, and displays the second debugging result for developers to view.

[0076] The debugging method of this application embodiment is applicable not only to multilingual debugging in applications, but also to cross-language debugging in applications. Multilingual debugging refers to debugging the modules corresponding to each language in an application developed in a mix of languages, without involving cross-language function calls; cross-language debugging refers to debugging cross-language function calls in an application developed in a mix of languages, involving cross-language function calls and language switching.

[0077] Figure 3 A flowchart illustrating a debugging method according to an embodiment of this application is shown. The debugging method is applied to a host computer, which includes a debugger.

[0078] like Figure 3As shown, the debugging method includes:

[0079] Step S310: When the debugger receives a first debugging request to debug the application, it processes the first debugging request according to a preset debugging protocol to obtain a second debugging request.

[0080] The application's first source code is written in multiple languages. For example, the application's first source code is written in JavaScript, Java, and Cangjie. It should be noted that this application does not limit the type or number of languages ​​used to write the application's first source code.

[0081] In one possible implementation, the host computer provides an Integrated Development Environment (IDE) for developers to perform visual code development and debugging. The IDE supports multiple languages. Developers can use these languages ​​to write the initial source code of the application within the IDE.

[0082] In one possible implementation, after the initial source code of the application is written, it can be compiled in debug mode, for example, using the -g option, to obtain target bytecode. This target bytecode is a uniformly formatted bytecode, independent of language type. In other words, when compiling the initial source code, the format definitions of specific data types for each language can be converted into the format definitions in the target bytecode, thus enabling the compilation of initial source code developed in multiple languages ​​into uniformly formatted target bytecode. For example, initial source code written in JavaScript, Java, and Cangjie can generate uniformly formatted, language-independent target bytecode after compilation.

[0083] The target bytecode compiled in debug mode includes debugging information, which is generated according to the format defined for debugging information in the target bytecode. The debugging information also records the correspondence between each bytecode segment in the target bytecode and its language type. For example, for a function written in C in the first source code, the correspondence between the bytecode segment corresponding to the function and its language type (i.e., C) can be recorded in the Language field of the corresponding debugging information (MethodDebugInfo).

[0084] In one possible implementation, when compiling the first source code in debug mode to obtain the target bytecode, the first source code can be divided into multiple second source codes according to the language type of the first source code, and each second source code is a source code of one language type in the first source code.

[0085] For example, suppose the first source code has four language types: JavaScript, Java, Cangjie, and C. According to these four language types, the first source code includes four second source codes: the second source code with the language type JavaScript, the second source code with the language type Java, the second source code with the language type Cangjie, and the second source code with the language type C.

[0086] For any second source code, it can be compiled in debug mode using a compiler of the language type of that second source code to obtain the first bytecode. For example, for a second source code of language type C, it can be compiled in debug mode using a C language compiler to obtain the first bytecode corresponding to the second source code of language type C. In other words, the first bytecode is the bytecode related to the language type of the second source code.

[0087] Then, based on the correspondence between the data types of the language type in the second source code and the data types of the target bytecode, the first bytecode can be converted into the second bytecode. The correspondence (also known as the mapping relationship) between the data types of the language type in the second source code and the data types of the target bytecode can be preset.

[0088] For example, in C, a 64-bit floating-point number is represented by the data type `double`, while in the target bytecode, a 64-bit floating-point number is represented by `U64`. A correspondence can be pre-established between the C data type `double` and the target bytecode data type `U64`. Then, based on this correspondence, the `double` data type in the first bytecode is converted to `U64` to obtain the second bytecode. The second bytecode is based on the data type of the target bytecode and is independent of the language type of the second source code.

[0089] It should be noted that the above examples only use the data types double and U64 as examples to illustrate the correspondence between the data types of the language type of the second source code and the data types of the target bytecode. Those skilled in the art can set the correspondence between the data types of the language type of the second source code and the data types of the target bytecode according to the actual situation, and this application does not impose any restrictions.

[0090] Next, the second bytecode from multiple second source codes can be packaged to obtain the target bytecode of the application. Because bytecode conversion is performed based on the correspondence between the data types of the language types of the second source codes and the data types of the target bytecode, the resulting target bytecode is bytecode with a uniform format that is independent of the language type of the first source code.

[0091] Figure 4 A schematic diagram illustrating the compilation process for generating target bytecode according to an embodiment of this application is shown. Figure 4 As shown, the application is developed using a hybrid approach of Java and Cangjie. For example, the application develops a new upper-level module using Cangjie, which calls existing lower-level interfaces implemented in Java. The application's first source code includes two second source codes: Java source code 41 and Cangjie source code 45.

[0092] During the compilation phase of the application, the two second source codes can be compiled to obtain the second bytecode: Java source code 41 can be compiled using a Java compiler to obtain class bytecode 42 (first bytecode), and class bytecode 42 can be converted using a bytecode converter 43 to obtain Ark bytecode 44 (second bytecode); Cangjie source code can be compiled using a Cangjie language compiler to directly obtain Ark bytecode 46 (second bytecode) without the need for bytecode conversion.

[0093] In this example, Ark bytecode 44 and Ark bytecode 46 are bytecodes with a uniform format. Then, a packaging tool can be used to package Ark bytecode 44 and Ark bytecode 46 to obtain the application's uniform target bytecode 47.

[0094] It should be noted that the above only uses Java and Cangjie languages ​​as examples to illustrate the language type of the first source code of the application. Those skilled in the art can determine the language type of the first source code according to the actual situation, and this application does not impose any restrictions on it. The above only uses Ark bytecode as an example to illustrate the target bytecode with a uniform format. Those skilled in the art can set the format of the target bytecode according to the actual situation, and this application does not impose any restrictions on it.

[0095] By dividing the first source code into multiple second source codes and compiling and converting each second source code into bytecode, a second bytecode with a uniform format is obtained. Then, the second bytecodes of multiple second source codes are packaged to obtain the target bytecode. This not only makes full use of the existing compilers of various languages, but also allows for the simultaneous compilation of each second source code, thereby improving compilation efficiency.

[0096] In one possible implementation, after obtaining the target bytecode of the application, the target bytecode can be pushed to the lower-level machine so that the lower-level machine can deploy and / or install the target bytecode.

[0097] By using the above method, a uniform target bytecode can be obtained and pushed to the lower-level machine, so that the debugging service on the lower-level machine can perform debugging based on the uniform target bytecode, thereby shielding the differences caused by different languages.

[0098] In one possible implementation, when developers debug the application, they first start the debugger on the host computer and then start the debugging service on the slave computer. The debugger and debugging service are connected via a debugging channel (e.g., a network). The debugger can be integrated into an IDE or run independently; this application does not impose any restrictions on this.

[0099] Then, a first debugging request can be sent through the host computer's IDE. This first debugging request can include the language type, file name, function name, line number, etc., of the code requesting debugging; that is, the first debugging request is a language-type-related debugging request. After receiving the first debugging request, the debugger can process it according to a preset debugging protocol to obtain a second debugging request. The preset debugging protocol is a language-type-independent debugging protocol. For example, an open-source debugging protocol (debug adapter protocol, DAP) can be extended to obtain a language-type-independent debugging protocol. According to the preset debugging protocol, the language-type-related first debugging request can be processed through format conversion, encapsulation, etc., to obtain the language-type-independent second debugging request.

[0100] Step S320: Send the second debugging request to the lower-level machine so that the debugging service of the lower-level machine can debug the target bytecode according to the second debugging request.

[0101] After receiving the second debugging request, the lower-level machine can be sent the second debugging request so that the lower-level machine's debugging service can debug the target bytecode according to the second debugging request, obtain a debugging response, and send the debugging response to the upper-level machine.

[0102] Step S330: When the debugger receives the debug response sent by the debug service corresponding to the second debug request, the first debug result in the debug response is converted into a second debug result corresponding to the target language type according to the target language type in the debug response.

[0103] The debugging response sent by the debugging service in response to the second debugging request may include a first debugging result and a target language type. The first debugging result is a debugging result based on the target bytecode and independent of the language type; the target language type can be used to indicate the language type of the source code to which the first debugging result belongs, and can also be considered as the language type displayed on the host computer when the debugging result is shown.

[0104] When the debugger receives a debug response, it can convert the first debug result in the debug response into a second debug result corresponding to the target language type, so that the host computer can display the debug result. Optionally, the debugger can convert the first debug result in the debug response into a second debug result corresponding to the target language type, based on the correspondence between the data type of the target language type and the data type of the target bytecode.

[0105] For example, if the target language is C, where 64-bit floating-point numbers are represented by the data type double, and 64-bit floating-point numbers are represented by U64 in the target bytecode, then the data type U64 in the first debugging result can be converted to double according to the correspondence between the data type double in C and the data type U64 in the target bytecode, so as to obtain the second debugging result represented by the data type in C, so that the host computer can display the second debugging result.

[0106] It should be noted that this example only uses the data types double and U64 as examples to illustrate the correspondence between the data types of the target language type and the data types of the target bytecode. Those skilled in the art can set the correspondence between the data types of the target language type and the data types of the target bytecode according to the actual situation, and this application does not impose any restrictions.

[0107] In this way, the first debugging result, which is based on the target bytecode and is independent of the language type, can be converted into a second debugging result that corresponds to the target language type. This method is simple, fast, and convenient for the host computer to display the debugging results.

[0108] Step S340: Display the second debugging result.

[0109] The second debugging result can be displayed in the debugger or integrated development environment (IDE) of the host computer, so that users can view the debugging results such as variables and call stack. It should be noted that those skilled in the art can set the display position and display method of the second debugging result according to actual requests, and this application does not impose any restrictions on this.

[0110] In one possible implementation, to improve the user's debugging experience for multilingual applications, the debugger on the host computer can be a multilingual debugger, through which the user can perform cross-language or multilingual debugging of the application.

[0111] For example, the debugger can have corresponding type wrapper implementations in the user presentation layer for different language types. For instance, for Java, the threads implemented in the user presentation layer are Java threads with a 1:1 ratio to the operating system (OS) threads; for Cangjie, the threads implemented in the user presentation layer are lightweight threads with an M:N ratio to OS threads, where M and N are positive integers. The debugger can convert the first debug request related to the language type into a second debug request based on the target bytecode and independent of the language type, and send it to the debugging service on the lower-level machine through a debugging channel (e.g., network). After receiving the debug response from the debugging service, the debugger can restore the debug results in the debug response to the debug results corresponding to the target language type according to the target language type in the debug response and display them for the user to view.

[0112] Figure 5 A flowchart illustrating a debugging method according to an embodiment of this application is shown. The debugging method is applied to a lower-level machine, which includes target bytecode and a debugging service. The target bytecode is bytecode with a unified format generated after compiling a first source code of an application in debug mode. The first source code is written in multiple languages. The target bytecode includes debugging information, which includes the correspondence between each bytecode segment in the target bytecode and its corresponding language type.

[0113] like Figure 5 As shown, the debugging method includes:

[0114] Step S510: When the debugging service receives the second debugging request, it determines the debugging location and target language type of the target bytecode based on the second debugging request and the debugging information of the target bytecode.

[0115] In one possible implementation, when the lower-level machine receives the target bytecode of the application pushed by the upper-level machine, the target bytecode is deployed and / or installed so that the lower-level machine can run the application.

[0116] During debugging, the lower-level machine starts a debugging service, which connects to the debugger on the upper-level machine via a debugging channel (e.g., network). When the debugging service receives a second debugging request from the debugger on the upper-level machine, it can determine the debugging location and target language type in the target bytecode based on the second debugging request and the debugging information of the target bytecode.

[0117] In one possible implementation, the debugging service can parse the second debugging request according to a preset debugging protocol to obtain information such as the language type, file name, function name, and line number of the code to be debugged, and then determine the location of the code to be debugged indicated by the second debugging request; then, based on the code location and the debugging information of the target bytecode, the debugging location in the target bytecode is determined.

[0118] Then, based on the debugging information and the debugging location, the target language type can be determined. For example, the bytecode segment to which the debugging location belongs can be determined from the target bytecode, and the target debugging information corresponding to that bytecode segment can be determined from the debugging information. Then, the target language type can be determined from the target debugging information.

[0119] Step S520: Debug the target bytecode according to the debugging location to obtain the first debugging result.

[0120] Once the debugging location in the target bytecode is determined, the debugging service can use this location to debug the target bytecode through the underlying debugging control interface, obtaining the first debugging result. This first debugging result is based on the target bytecode and is independent of the language type.

[0121] Step S530: Send a debugging response to the host computer through the debugging service. The debugging response includes the first debugging result and the target language type.

[0122] After obtaining the initial debugging result and the target language type, the debugging service can send a debugging response to the host computer according to a preset debugging protocol. The debugging response includes the initial debugging result and the target language type.

[0123] In one possible implementation, to reduce resource consumption on the terminal device during debugging and enable resource-constrained or resource-sensitive terminal devices to support cross-language debugging, the debugging service on the lower-level machine can be improved as follows: The traditional model of encapsulating debugging services based on separate debugging protocols for each language is abandoned. For example, Java's debugging service is encapsulated based on the Java Debugging Protocol (JDWP), and JavaScript's debugging service is encapsulated based on the JavaScript Debugging Protocol (Chrome DevTools Protocol, CDP). The lower-level machine's debugging service is normalized to a multi-language data type based on the target bytecode's data type, thus masking multi-language differences during debugging. This results in a language-type-independent debugging service based on the target bytecode's data type. The multi-language differences are reflected through the target language type in the debugging response.

[0124] According to an embodiment of this application, when the lower-level machine's debugging service receives a second debugging request, it determines the debugging location and target language type of the target bytecode based on the second debugging request and the debugging information of the target bytecode. Based on the debugging location, it debugs the target bytecode to obtain a first debugging result. Then, it sends a debugging response including the first debugging result and the target language type to the upper-level machine. Thus, the target bytecode of a multi-language mixed-development application can be debugged through a single debugging service on the lower-level machine. This not only reduces resource consumption during debugging but also reduces debugging latency, thereby improving debugging efficiency.

[0125] Figure 6 A schematic diagram illustrating the processing flow of a debugging method according to an embodiment of this application is shown. Figure 6 As shown, the developers write the first source code 611 of the application in the integrated development environment 610 of the host computer 600. The first source code 611 is written in multiple languages ​​such as JavaScript, Java, and C. Accordingly, the first source code 611 includes JavaScript source code, Java source code, C language source code, etc.

[0126] After the first source code 611 is written, the host computer 600 compiles the first source code 611 in debug mode (e.g., via the -g compilation option) to generate target bytecode 710 with a uniform format and independent of language type. The target bytecode 710 is then pushed to the slave computer 700 for deployment and / or installation so that the slave computer can run the target bytecode 710 of the application.

[0127] When developers debug an application, they first start the debugger 620 on the host computer 600 and the debug service 720 on the slave computer 700, and connect the debugger 620 and the debug service 720 through a debugging channel (e.g., network). Then, the integrated development environment 610 of the host computer sends a first debugging request to debug the application. When the debugger 620 receives the first debugging request, the debug request processing unit 621 performs format conversion, encapsulation and other processing on the first debugging request related to the language type according to a preset debugging protocol, and obtains a second debugging request based on the target bytecode that is independent of the language type, and sends the second debugging request to the slave computer 700.

[0128] When the debugging service 720 of the lower-level machine 700 receives the second debugging request, it determines the debugging location and target language type in the target bytecode 710 based on the second debugging request and the debugging information of the target bytecode 710. Then, based on the debugging location, it debugs the target bytecode 710 through debugging-related configurations and components such as breakpoints, debugging control interfaces, and program control units to obtain the first debugging result. After that, the debugging service 720 sends a debugging response including the first debugging result and the target language type to the upper-level machine 600.

[0129] When the debugger 620 of the host computer 600 receives the debug response corresponding to the second debug request sent by the debug service 720, it can convert the first debug result in the debug response into the second debug result corresponding to the target language type through the multi-language-bytecode adaptation unit 622, and display the second debug result through the display 623 for the user to view.

[0130] It should be noted that, Figure 6 The debugging method described in this application is merely an example. Those skilled in the art can determine the types of multiple languages ​​used to write the first source code, the location of the display unit, etc., according to the actual situation. This application does not impose any restrictions on these aspects.

[0131] Verification has shown that in multi-language debugging scenarios for applications, taking the debugging of Cangjie and Java as examples, only one debugger and debugging service needs to be started, which can save about 50% of debugging resources; taking the debugging of Cangjie, Java and JavaScript as examples, only one debugger and debugging service needs to be started, which can save about 67% of debugging resources.

[0132] In cross-language debugging scenarios for applications, only one debugger and debugging service need to be started. The debugger can achieve a seamless debugging experience across multiple languages. Cross-language debugging operations do not require setting breakpoints in advance. Breakpoints, single-stepping, and call stack viewing can be performed on source code in different languages, resulting in a better user experience.

[0133] The debugging method of this application can solve the problems of high resource consumption and high debugging latency when debugging multi-language mixed-development applications on resource-sensitive terminal devices. It can also make cross-language debugging operations the same as single-language debugging operations. Users do not need to be aware of the cross-language function call process and do not need to set breakpoints in advance, which effectively improves the debugging experience of multi-language mixed-development applications.

[0134] Figure 7 A block diagram of a debugging apparatus according to an embodiment of this application is shown. The debugging apparatus is applied to a host computer, which includes a debugger.

[0135] like Figure 7 As shown, the debugging device includes:

[0136] The debug request processing module 710 is used to process the first debug request according to a preset debug protocol to obtain a second debug request when the debugger receives a first debug request to debug the application. The first source code of the application is written in multiple languages.

[0137] The debug request sending module 720 is used to send the second debug request to the lower-level machine so that the debug service of the lower-level machine can debug the target bytecode according to the second debug request. The target bytecode is bytecode with a unified format generated after compiling the first source code in debug mode.

[0138] The debugging result conversion module 730 is used to convert the first debugging result in the debugging response into a second debugging result corresponding to the target language type when the debugger receives the debugging response sent by the debugging service corresponding to the second debugging request.

[0139] Display module 740 is used to display the second debugging result.

[0140] In one possible implementation, the apparatus further includes: a compilation module, configured to compile the first source code in debug mode to obtain the target bytecode with a uniform format, wherein the debugging information of the target bytecode includes the correspondence between each bytecode segment in the target bytecode and the language type; and a push module, configured to push the target bytecode to the lower-level machine.

[0141] In one possible implementation, the first source code includes multiple second source codes, each of which is a source code of a language type in the first source code. The compilation module is configured to: compile any second source code in debug mode using a compiler of the language type of the second source code to obtain first bytecode; convert the first bytecode into second bytecode according to the correspondence between the data type of the language type of the second source code and the data type of the target bytecode; and package the second bytecode of the multiple second source codes to obtain target bytecode.

[0142] In one possible implementation, the debugging result conversion module 730 is configured to: convert the first debugging result in the debugging response into a second debugging result corresponding to the target language type, based on the correspondence between the data type of the target language type and the data type of the target bytecode.

[0143] Figure 8 A block diagram of a debugging apparatus according to an embodiment of this application is shown. The debugging apparatus is applied to a lower-level machine, which includes target bytecode and a debugging service. The target bytecode is bytecode of a uniform format generated after compiling a first source code of an application in debug mode. The first source code is written in multiple languages.

[0144] like Figure 8 As shown, the debugging device includes: The device includes:

[0145] The location and language type determination module 810 is used to determine the debugging location and target language type in the target bytecode based on the second debugging request and the debugging information of the target bytecode when the debugging service receives the second debugging request;

[0146] The debugging module 820 is used to debug the target bytecode according to the debugging location to obtain a first debugging result;

[0147] The debugging response sending module 830 is used to send a debugging response to the host computer through the debugging service. The debugging response includes the first debugging result and the target language type.

[0148] In one possible implementation, the debugging information of the target bytecode includes the correspondence between each bytecode segment in the target bytecode and the language type. The location and language type determination module 810 is used to: parse the second debugging request according to a preset debugging protocol to determine the code location to be debugged indicated by the second debugging request; and determine the debugging location of the target bytecode according to the code location and the debugging information.

[0149] In one possible implementation, the location and language type determination module 810 is further configured to: determine the target debugging information of the bytecode segment to which the debugging location belongs from the debugging information; and determine the target language type from the target debugging information.

[0150] An embodiment of this application provides a debugging apparatus, including: a processor and a memory for storing processor-executable instructions; wherein the processor is configured to implement the above-described method when executing the instructions.

[0151] Embodiments of this application provide a non-volatile computer-readable storage medium storing computer program instructions thereon, which, when executed by a processor, implement the above-described method.

[0152] Embodiments of this application provide a computer program product including computer-readable code, or a non-volatile computer-readable storage medium carrying computer-readable code, wherein when the computer-readable code is run in a processor of an electronic device, the processor in the electronic device performs the above-described method.

[0153] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example—but not limited to—electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), electrically programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), compact disc read-only memory (CD-ROM), digital video disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination of the foregoing.

[0154] The computer-readable program instructions or code described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge servers. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to the computer-readable storage media in the respective computing / processing device.

[0155] The computer program instructions used to perform the operations of this application may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as "C" or similar languages. The computer-readable program instructions may be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuits, such as programmable logic circuits, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), are personalized by utilizing state information from computer-readable program instructions. These electronic circuits can execute computer-readable program instructions to implement various aspects of this application.

[0156] Various aspects of this application are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.

[0157] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processor of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner; thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.

[0158] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.

[0159] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those shown in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved.

[0160] It should also be noted that each block in the block diagram and / or flowchart, as well as combinations of blocks in the block diagram and / or flowchart, can be implemented using hardware (such as circuits or ASICs (Application Specific Integrated Circuits)) that performs the corresponding function or action, or using a combination of hardware and software, such as firmware.

[0161] Although the invention has been described herein in conjunction with various embodiments, those skilled in the art will understand and implement other variations of the disclosed embodiments by reviewing the accompanying drawings, disclosure, and appended claims in carrying out the claimed invention. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "an" does not exclude a plurality. A single processor or other unit can implement several functions listed in the claims. While different dependent claims may recite certain measures, this does not mean that these measures cannot be combined to produce good results.

[0162] The various embodiments of this application have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or improvement of the technology in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

Claims

1. A debugging method, characterized in that, Applied to a host computer, the host computer including a debugger, the method includes: When the debugger receives a first debugging request to debug the application, it processes the first debugging request according to a preset debugging protocol to obtain a second debugging request. The first source code of the application is written in multiple languages. The second debugging request is sent to the lower-level machine so that the debugging service of the lower-level machine can debug the target bytecode according to the second debugging request. The target bytecode is bytecode with a unified format generated after compiling the first source code in debug mode. When the debugger receives a debug response from the debug service corresponding to the second debug request, it converts the first debug result in the debug response into a second debug result corresponding to the target language type, based on the target language type in the debug response. The second debugging result is displayed.

2. The method according to claim 1, characterized in that, The method further includes: The first source code is compiled in debug mode to obtain the target bytecode with a uniform format. The debugging information of the target bytecode includes the correspondence between each bytecode segment in the target bytecode and the language type. The target bytecode is pushed to the lower-level machine.

3. The method according to claim 1 or 2, characterized in that, The first source code includes multiple second source codes, each of which is source code in one of the languages ​​of the first source code. The step of compiling the first source code in debug mode to obtain the target bytecode includes: For any given second source code, compile the second source code in debug mode using a compiler of the language type of the second source code to obtain the first bytecode; Based on the correspondence between the data type of the language type of the second source code and the data type of the target bytecode, the first bytecode is converted into the second bytecode; The second bytecode of the plurality of second source codes is packaged to obtain the target bytecode.

4. The method according to claim 1, characterized in that, The step of converting the first debugging result in the debugging response into a second debugging result corresponding to the target language type, based on the target language type in the debugging response, includes: Based on the correspondence between the data type of the target language type and the data type of the target bytecode, the first debugging result in the debugging response is converted into a second debugging result corresponding to the target language type.

5. A debugging method, characterized in that, This is applied to a lower-level machine, which includes target bytecode and debugging services. The target bytecode is bytecode of a unified format generated after compiling the first source code of the application in debug mode. The first source code is written in multiple languages. The method includes: When the debugging service receives the second debugging request, it determines the debugging location and target language type in the target bytecode based on the second debugging request and the debugging information of the target bytecode. Based on the specified debugging location, the target bytecode is debugged to obtain a first debugging result; The debugging service sends a debugging response to the host computer, and the debugging response includes the first debugging result and the target language type.

6. The method according to claim 5, characterized in that, The debugging information of the target bytecode includes the correspondence between each bytecode segment in the target bytecode and the language type. The step of determining the debugging location and target language type in the target bytecode based on the second debugging request and the debugging information of the target bytecode includes: According to the preset debugging protocol, the second debugging request is parsed to determine the location of the code to be debugged indicated by the second debugging request; The debugging location of the target bytecode is determined based on the code location and the debugging information.

7. The method according to claim 6, characterized in that, The step of determining the debugging location and target language type in the target bytecode based on the second debugging request and the debugging information of the target bytecode further includes: From the debugging information, determine the target debugging information of the bytecode segment to which the debugging location belongs; The target language type is determined from the target debugging information.

8. A debugging system, characterized in that, include: A host computer, the host computer including a debugger, the host computer being configured to implement the method of any one of claims 1 to 4; The lower-level machine includes target bytecode and debugging services, and is configured to implement the method described in any one of claims 5 to 7.

9. A debugging device, characterized in that, Applied to a host computer, the host computer including a debugger, the device comprising: The debug request processing module is used to process the first debug request according to a preset debug protocol to obtain a second debug request when the debugger receives a first debug request to debug the application. The first source code of the application is written in multiple languages. The debug request sending module is used to send the second debug request to the lower-level machine so that the debug service of the lower-level machine can debug the target bytecode according to the second debug request. The target bytecode is bytecode with a unified format generated after compiling the first source code in debug mode. The debugging result conversion module is used to convert the first debugging result in the debugging response into a second debugging result corresponding to the target language type when the debugger receives the debugging response sent by the debugging service corresponding to the second debugging request; The display module is used to display the second debugging result.

10. The apparatus according to claim 9, characterized in that, The device further includes: The compilation module is used to compile the first source code in debug mode to obtain the target bytecode with a uniform format. The debugging information of the target bytecode includes the correspondence between each bytecode segment in the target bytecode and the language type. The push module is used to push the target bytecode to the lower-level machine.

11. The apparatus according to claim 10, characterized in that, The first source code includes multiple second source codes, each of which is source code in one of the languages ​​of the first source code. The compilation module is used for: For any given second source code, compile the second source code in debug mode using a compiler of the language type of the second source code to obtain the first bytecode; Based on the correspondence between the data type of the language type of the second source code and the data type of the target bytecode, the first bytecode is converted into the second bytecode; The second bytecode of the plurality of second source codes is packaged to obtain the target bytecode.

12. The apparatus according to any one of claims 9 to 11, characterized in that, The debugging result conversion module is used for: Based on the correspondence between the data type of the target language type and the data type of the target bytecode, the first debugging result in the debugging response is converted into a second debugging result corresponding to the target language type.

13. A debugging device, characterized in that, This is applied to a lower-level machine, which includes target bytecode and debugging services. The target bytecode is bytecode of a unified format generated after compiling the first source code of the application in debug mode. The first source code is written in multiple languages. The device includes: The location and language type determination module is used to determine the debugging location and target language type in the target bytecode based on the second debugging request and the debugging information of the target bytecode when the debugging service receives the second debugging request; The debugging module is used to debug the target bytecode according to the debugging location to obtain a first debugging result; The debugging response sending module is used to send a debugging response to the host computer through the debugging service. The debugging response includes the first debugging result and the target language type.

14. The apparatus according to claim 13, characterized in that, The debugging information of the target bytecode includes the correspondence between each bytecode segment in the target bytecode and the language type. The location and language type determination module is used for: According to the preset debugging protocol, the second debugging request is parsed to determine the location of the code to be debugged indicated by the second debugging request; The debugging location of the target bytecode is determined based on the code location and the debugging information.

15. The apparatus according to claim 14, characterized in that, The location and language type determination module is also used for: From the debugging information, determine the target debugging information of the bytecode segment to which the debugging location belongs; The target language type is determined from the target debugging information.

16. A debugging device, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured to implement the method of any one of claims 1 to 4 when executing the instructions, or to implement the method of any one of claims 5 to 7.

17. A non-volatile computer-readable storage medium storing computer program instructions thereon, characterized in that, When the computer program instructions are executed by the processor, they implement the method described in any one of claims 1 to 4, or the method described in any one of claims 5 to 7.

18. A computer program product comprising computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code, wherein when the computer-readable code is executed in an electronic device, a processor in the electronic device performs the method of any one of claims 1 to 4, or performs the method of any one of claims 5 to 7.