Source code display method and device, electronic equipment and storage medium

By using debugging information and path association relationships, the precise positioning and display of error positions in binary files to corresponding source files in software engineering of component architecture is achieved, which solves the problem of difficult debugging and improves the debugging efficiency of developers.

CN119597593AActive Publication Date: 2025-03-11BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202411639063.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-15
Publication Date
2025-03-11
Estimated Expiration
2044-11-15

AI Technical Summary

Technical Problem

In software engineering of componentized architectures, when errors occur in components accessed in binary form, debugging becomes more difficult because developers can only see binary code, which is difficult to understand and read.

Method used

The generated debugging information determines the error position in the binary file of the component, and maps the path of the binary file to the path of the source code file based on the pre-generated path association relationship, so as to locate and display the source code to be debugged in the source code file.

Benefits of technology

It realizes precise positioning and display from the error position in the binary file to the corresponding source file, reducing the difficulty of debugging and improving the debugging efficiency of developers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119597593A_ABST
    Figure CN119597593A_ABST
Patent Text Reader

Abstract

The invention provides a source code display method and device, electronic equipment and a storage medium, and relates to the technical field of computers, in particular to the technical field of data processing. According to the specific implementation scheme, the method comprises the steps of determining an error reporting position in a binary file accessed to a first component of the software engineering in a binary form based on first debugging information generated by running the software engineering; determining a second path of a first source code file of a first component in source code files locally stored in the software engineering based on a first path of the source code file of the first component used when the binary file is generated and a path association relationship between a local path of the pre-generated first source code file and the first path, wherein the first path is recorded in the first debugging information; mapping the first path to a second path; and based on the mapping result and the error reporting position, positioning the to-be-debugged source code in the first source code file, and displaying the to-be-debugged source code. By applying the scheme provided by the embodiment of the invention, the source code corresponding to the error position in the binary file can be displayed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to the field of data processing technology. Background Art

[0002] In order to increase the code cohesion of software engineering, reduce the coupling between codes and improve the platformization of software development, more and more software engineering projects are implemented based on componentized architecture.

[0003] In current software projects with component-based architecture, components are mostly connected to the project in binary form. As a result, when running the software project, once an error occurs, and the error occurs in a component connected in binary form, only the binary code at the error location can be seen during debugging. The binary code is difficult to understand and read, which increases the difficulty of debugging. Summary of the invention

[0004] The present disclosure provides a source code display method, device, electronic device and storage medium.

[0005] According to one aspect of the present disclosure, a source code display method is provided, comprising:

[0006] Determine an error location in a binary file of a first component based on first debugging information generated by running the software project, wherein the first component is connected to the software project in binary form;

[0007] Based on the first path of the source code file of the first component recorded in the first debugging information and the pre-generated path association relationship, determine the second path of the first source code file of the first component in the source code files locally stored in the software project, wherein the path association relationship is: the association relationship between the local path of the first source code file and the first path, and the first path is: the path of the source code file of the first component used when generating the binary file;

[0008] mapping the first path to the second path;

[0009] Based on the mapping result and the error position, the source code to be debugged is located in the first source code file, and the source code to be debugged is displayed.

[0010] According to another aspect of the present disclosure, there is provided a source code display device, comprising:

[0011] An error location determination module, configured to determine an error location in a binary file of a first component based on first debugging information generated by running a software project, wherein the first component is connected to the software project in binary form;

[0012] a path determination module, configured to determine a second path of a first source code file of a first component in source code files locally stored in the software project based on a first path of the source code file of the first component recorded in the first debugging information and a pre-generated path association relationship, wherein the path association relationship is an association relationship between a local path of the first source code file and the first path, and the first path is a path of the source code file of the first component used when generating the binary file;

[0013] a path mapping module, configured to map the first path to the second path;

[0014] The source code display module is used to locate the source code to be debugged in the first source code file based on the mapping result and the error reporting position, and display the source code to be debugged.

[0015] According to another aspect of the present disclosure, there is provided an electronic device, comprising:

[0016] at least one processor; and

[0017] a memory communicatively connected to the at least one processor; wherein,

[0018] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned source code display method.

[0019] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the above-mentioned source code display method.

[0020] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein the computer program implements the above-mentioned source code display method when executed by a processor.

[0021] As can be seen from the above, in the solution provided by the embodiment of the present disclosure, the error location in the binary file of the first component can be determined according to the first debugging information generated by running the software project, and then based on the path association relationship between the pre-generated local path and the first path, the local path associated with the first path of the source code file of the first component recorded in the first debugging information is determined as the second path. In this way, after mapping the first path to the second path, the first source code file of the first component stored locally in the software project can be accessed based on the mapping result, and then the source code to be debugged can be located in the first source code file, and the source code to be debugged can be displayed, so as to realize the display of the source code corresponding to the error location in the binary file.

[0022] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0024] Figure 1 It is a flow chart of a source code display method provided by an embodiment of the present disclosure;

[0025] Figure 2 It is a flowchart of a method for generating a path association relationship provided by an embodiment of the present disclosure;

[0026] Figure 3 is a structural schematic diagram of a source code display device provided by an embodiment of the present disclosure;

[0027] Figure 4 It is a block diagram of an electronic device used to implement the source code display method of the embodiment of the present disclosure. DETAILED DESCRIPTION

[0028] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0029] The following is a description of the execution subject of the solution provided by the embodiment of the present disclosure.

[0030] The solution provided by the embodiment of the present disclosure can be applied to electronic devices such as desktop computers and laptop computers. Specifically, the solution provided by the embodiment of the present disclosure can be applied to software engineering debugging tools installed in the above electronic devices. For ease of description, the execution subject of the source code display method provided by the embodiment of the present disclosure is collectively referred to as a debugging tool.

[0031] The following describes the application scenarios of the solutions provided by the embodiments of the present disclosure.

[0032] In current component-based software engineering, components are mostly connected to the project in binary form. In the context of platform-based software development, the binary files used to connect components to the project in binary form are usually obtained by packaging the source code files of the components with a file packaging device. The file packaging device is usually a device different from the electronic device to which the debugging tool belongs. The file packaging device can be accessed by devices used by multiple developers. In this way, the binary files generated by the file packaging device based on the source code files of the components can be used by multiple developers. In this way, the generated binary files can be reused, which is convenient for developers to use.

[0033] When components are connected to the project in binary form, when installing the binary files of the components, developers can download the required binary files of the components from the file packaging device through electronic devices, but will not download the source code files of the components from the file packaging device. When running the software project, once an error occurs, and the error occurs in the component connected in binary form, the developer can only see the binary code of the error location during debugging, but not the source code of the error location. The binary code is difficult to understand and read, which increases the difficulty of debugging.

[0034] Some concepts involved in the embodiments of the present disclosure are first described below.

[0035] The source code file of a component refers to a file containing implementation code written in the development language of the component, for example, the file may be a file with a file suffix of .m, etc. For example, the above development language may be JAVA, JavaScript, C++, Python, and many other different development languages.

[0036] The binary file of a component refers to a file containing the binary implementation code of the component, which may be a static library file. In addition, the binary file of a component may be a file generated by compiling, packaging, and other operations on the source code file of the component.

[0037] The source code display method provided by the embodiment of the present disclosure is described in detail below through specific embodiments.

[0038] In one embodiment of the present disclosure, see Figure 1 A flow chart of a source code display method is provided, wherein the method comprises the following steps S101-S104.

[0039] Step S101: determining an error location in a binary file of a first component based on first debugging information generated by running a software project.

[0040] The first component is connected to the software project in binary form. During the running of the software project, log information, variable values, code execution status, error reports, memory address symbol information, etc. of the software project can be recorded as the first debugging information.

[0041] Specifically, the debugging tool can identify the information belonging to the error report category in the first debugging information, determine the binary file of the first component where the error occurs from the information in the error report, and then determine the error position determined in the above binary file according to the information belonging to the error report category. The specific form of the error position may include the relative position of the position in the binary file, or may include the memory address where the error occurs recorded in the error report.

[0042] Step S102: Based on the first path of the binary file recorded in the first debugging information and the pre-generated path association relationship, determine the second path of the first source code file of the first component in the source code files stored locally in the software project.

[0043] Specifically, the debugging tool may search for a local path of the first source code file corresponding to the first path in the path association relationship as the second path.

[0044] The first path is described below.

[0045] The first path is: the path of the source code file of the first component used when generating the binary file. Among them, the device used to generate the binary file is a device different from the electronic device to which the debugging tool belongs, that is, the first path is not a path in the electronic device to which the debugging tool belongs, nor is it a path for storing source code files locally in the software engineering. For example, if the binary file is generated by a file packaging device, then the source code files of each component need to be stored in the file packaging device. In the case where the file packaging device is required to generate a binary file of a specified component, the file packaging device compiles, packages, and other operations on the source code file of the specified component stored locally to obtain the binary file of the specified component. In this case, the above-mentioned first path is: the path of the source code file of the above-mentioned specified component stored in the file packaging device in the file packaging device.

[0046] The file packaging device needs to generate a binary file of the first component based on the source code file of the first component stored in the file packaging device. In this case, the first path is the path of the source code file stored by the file packaging device for generating the binary file of the component. In the binary file, the path of the source code file used to generate the binary file can be recorded. However, binary files are difficult to interpret, and it is difficult for debugging tools to read the recorded path directly from the binary file. Therefore, after the binary file of the first component is connected to the software project and the software project is run, the first path can be found in the first debugging information generated by running the software project. For example, if the error location includes the error address, iamgelookuo (a command for finding the file location) and the error address can be used to find the first path in the first debugging information.

[0047] The local path and the second path of the first source code file are described below.

[0048] The source code files corresponding to the components accessed in binary form can be stored locally in the software project. The local path is the path of the source code files stored locally in the software project.

[0049] In the process of executing the solution provided by the embodiment of the present disclosure, after obtaining the first path from the first debugging information, it is also necessary to obtain the local path of the source code file of the first component in the local software project. In the solution provided by the embodiment of the present disclosure, the source code file of the first component is not located by traversing the source code files of the components in the local software project, but the local path of the source code file corresponding to the obtained first path in the local software project is determined in the pre-generated path association relationship as the second path.

[0050] In the embodiments of the present disclosure, source code files may be downloaded to the local software project in different ways.

[0051] In one method, developers can manually download the source code files corresponding to each component connected in binary form to the local software project in advance.

[0052] In another way, the first source code file is downloaded to the local software project along with the first component in binary form. Specifically, when the software project is accessed in binary form, the first source code file can be downloaded to the local software project in response to a preset command. For example, the first source code file can be downloaded to the local software project along with the first component in binary form.

[0053] In addition, in the prior art, if an error occurs when running a software project, developers usually manually find the source code file of the component where the error occurs, and download the source code file to the local software project for storage. By applying the solution provided by the embodiment of the present disclosure, the first source code file can be downloaded to the local software project through a relatively simple process, without the developer having to download the source code file separately, reducing the difficulty of the developer's operation, making the developer unaware of the process of downloading the source code file, improving the developer's use experience, and improving the developer's debugging efficiency.

[0054] The path association relationship is described below.

[0055] The path association relationship is: the association relationship between the local path of the first source code file and the first path. The first source code file corresponding to the local path associated with the path association relationship and the source code file corresponding to the first path are the same source code file, and the difference between the two is only the different way of determining the path.

[0056] The method of pre-generating the path association relationship is described in the following embodiment and will not be described in detail here.

[0057] Step S103: Map the first path to the second path.

[0058] Specifically, after obtaining the first path and the second path of the source code file of the first component recorded in the first debugging information, the preset path mapping command can be used to map the first path to the second path. In this way, after completing the path mapping, the debugging tool can record the mapping relationship between the first path and the second path as the mapping result. If the debugging tool determines the source code file under the first path, it can no longer determine the source code file under the first path based on the mapping relationship between the first path and the second path, but determine the source code file under the second path, wherein the second path is the location of the source code file of the first component in the source code file stored locally in the software engineering, and the source code file of the first component is pre-stored in the local storage of the software engineering, so the debugging tool can successfully find the source code file of the first component under the second path.

[0059] For example, a source-map (a path mapping command) command may be used to map the first path to the second path.

[0060] For example, if the first path recorded in the first debugging information obtained by the debugging tool is:

[0061] " / Users / XXX / Documents / AAAA / StaticLibrary / StaticLibrary / StaticLibrary.m".

[0062] The debugging tool determines that the second path is:

[0063] " / Users / XXX / Documents / BBBB / StaticLibrary.m".

[0064] Then, mapping the first path to the second path can be achieved through the following source-map command:

[0065] "settingssettarget.source-map / Users / XXX / Documents / AAAA / StaticLibrary / StaticLibrary / StaticLibrary.m / Users / XXX / Documents / BBBB / StaticLibrar ym".

[0066] After the debugging tool executes the above command, it will record the mapping relationship between the first path and the second path. Assume that the debugging tool needs to determine the source code file in the following first path:

[0067] " / Users / XXX / Documents / AAAA / StaticLibrary / StaticLibrary / StaticLibrary.m".

[0068] Then, based on the recorded mapping relationship, the debugging tool no longer determines the source code file in the first path, and jumps to determine the source code file in the following second path:

[0069] " / Users / XXX / Documents / BBBB / StaticLibrary.m".

[0070] Step S104: based on the mapping result and the error position, the source code to be debugged is located in the first source code file, and the source code to be debugged is displayed.

[0071] In one implementation, the debugging tool can determine the relative position of the source code to be debugged in the first source code file based on the error position. Determine the absolute position of the source code to be debugged in the first source code file based on the mapping result and the relative position. Locate the source code to be debugged in the first source code file based on the absolute position. Display the source code to be debugged.

[0072] Specifically, the error position may include the relative position of the error position in the binary file. In the source code file corresponding to the binary file, the code at the same relative position is also the same. Therefore, the debugging tool can determine the relative position of the source code to be debugged in the first source code file based on the relative position in the binary file, and then determine the absolute position of the source code to be debugged according to the position of the first source code file in the second path mapped to the mapping result and the relative position of the source code to be debugged in the first source code file. Then, based on the absolute position, the debugging tool can locate the source code to be debugged corresponding to the error position in the first source code file, and then display the source code to be debugged.

[0073] In this way, by determining the relative position of the source code to be debugged in the first source code file, the accurate absolute position of the source code to be debugged in the first source code file is determined, and then the source code to be debugged in the first source code file can be located more accurately and quickly based on the absolute position.

[0074] As can be seen from the above, in the solution provided by the embodiment of the present disclosure, the error location in the binary file of the first component can be determined according to the first debugging information generated by running the software project, and then based on the path association relationship between the pre-generated local path and the first path, the local path associated with the first path of the source code file of the first component recorded in the first debugging information is determined as the second path. In this way, after mapping the first path to the second path, the first source code file of the first component stored locally in the software project can be accessed based on the mapping result, and then the source code to be debugged can be located in the first source code file, and the source code to be debugged can be displayed, so as to realize the display of the source code corresponding to the error location in the binary file.

[0075] In the prior art, developers can only see the unknown code at the error location, such as assembly code. The solution provided by the embodiment of the present disclosure can enable developers to see the source code corresponding to the error location, which is convenient for developers to debug and reduces the difficulty of debugging.

[0076] In another embodiment of the present disclosure, the above steps S101-S104 can be implemented by creating a preset source code display script, and then in actual use, developers can implement one-key operation by executing the above source code display script, making the developer operation easier. For example, the preset source code display script can be implemented by customizing LLDB (Low-Level Debugger, a lightweight high-performance debugger) to extend the python script.

[0077] In one embodiment of the present disclosure, a path association relationship may be generated in advance. Figure 2 A flow chart of a path association relationship generation method is provided, the method comprising the following steps S201-S203.

[0078] Step S201: After storing the first source code file of the first component locally in the software project, obtain the local path of the first source code file locally in the software project.

[0079] Specifically, after the source code files of each component are stored locally in the software project, the debugging tool can record the identifier of each component and the corresponding local path where the source code files are stored. When it is necessary to obtain the first source code file of the first component, the local path of the first source code file corresponding to the identifier of the first component can be searched for in the local software project according to the identifier of the first component.

[0080] Step S202: obtaining a path of a source code file of a first component used when generating a binary file as a first path.

[0081] An implementation method of obtaining the first path in step S202 is described below.

[0082] Specifically, the debugging tool may request the path of the source code file of the first component from the file packaging device, and receive the packaging source code path read by the file packaging device from the packaging directory of the binary file as the first path.

[0083] The packaged source code path is: the path of the source code file of the first component used by the file packaging device when generating the binary file.

[0084] Specifically, the debugging tool can send a path request to the file packaging device, which can carry the identifier of the first component. The file packaging device reads the packaging source code path corresponding to the first component from the packaging directory of the binary file according to the identifier of the first component, and then returns the packaging source code path to the debugging tool.

[0085] It can be seen that the packaged source code path read from the package directory of the binary file by the file packaging device is sent to the debugging tool. In this way, the debugging tool can reduce the need to parse the binary file, reduce the time for obtaining the path of the source code file, and improve the efficiency of pre-generating path association relationships.

[0086] The file packaging device needs to use the source code file of the first component when generating a binary file, and the file packaging device can determine the path of the source code file when generating the binary file and record the determined path. Then, the file packaging device can determine the path of the source code file when generating the binary file and save the path of the source code file to a file. Based on the above implementation, the packaged source code path can be stored in a file of a set type under the packaging directory. For example, the file of the set type can be a JSON (JavaScript Object Notation, a lightweight data exchange format) file.

[0087] In this way, the packaged source code path is stored in a file of a set type under the packaging directory of the file packaging device. When the binary files of the same component are connected to different software projects, the debugging tool can directly obtain the source code path from the file of a set type under the packaging directory of the packaging device. As the first path, the file of the set type can be reused, thereby reducing the repeated requests for the path of the source code file of the first component, saving time in reading the packaged source code path, and improving the efficiency of pre-generating path associations.

[0088] Another implementation of obtaining the first path in step S202 is described below.

[0089] Specifically, a binary file is loaded into a memory, and the binary file loaded into the memory is parsed to obtain debugging information recorded in the binary file and generated during the generation of the binary file as the second debugging information. In the second debugging information, a preset number of code lines in a statement of a preset format is determined, and characters of a preset field in the determined code lines are intercepted. Based on the intercepted characters, a first path of a source code file of a first component used when generating the binary file is obtained.

[0090] Generally, binary files are difficult to decipher, but in the above method, by loading the binary file into the memory and parsing the binary file loaded in the memory, the debugging information recorded in the binary file and generated in the process of generating the binary file can be obtained, and then by determining a preset number of code lines in a statement of a preset format, the preset field in the determined code line is intercepted to obtain the first path of characters.

[0091] For example, for a binary file in DWARF (Debug With Address Ranges, a binary file format) format, dwarfdump (a debugging information acquisition command) can be used to parse the binary file loaded in the memory to obtain the second debugging information, and then grep (a text search command) and head (a command for displaying the content of a file header) are used to determine a preset number of code lines in a statement of a preset format, and then cut (a cut command) is used to intercept characters of a preset field in the determined code line, and the intercepted characters are used as the first path.

[0092] In this way, the first path is obtained through the debugging information recorded in the binary file. The first path can be obtained without recording the path of the source code file used in the process of generating the binary file, which can improve the adaptability to various scenarios. In addition, the debugging information recorded in the binary file is more accurate, which can improve the accuracy of the obtained first path.

[0093] Step S203: Connect the local path and the first path to generate a path association relationship.

[0094] In one implementation, the local path and the first path may be connected through a soft connection command.

[0095] In another implementation manner, the local path and the first path may be connected by recording a corresponding relationship between the local path and the first path.

[0096] From the above, it can be seen that by obtaining the local path after storing the first source code file of the first component locally in the software engineering, and obtaining the path of the source code file of the first component used when generating the binary file, the path of the same source code file on two different devices can be accurately obtained, and a path association relationship can be generated, so that the debugging tool can accurately implement source code display based on the path association relationship.

[0097] In this way, by downloading the source code files of the components to the local software project in advance, and then generating the path association relationship, performing a large amount of advance preparation can make it possible that when displaying the source code, only the second path associated with the first path of the source code file of the first component recorded in the debugging information needs to be determined through the path association relationship. This process is simple and fast, and the source code file of the first component in the source code file stored locally in the software project can be quickly determined. The speed of determining the local source code file is improved, the speed of displaying the source code is improved, and the speed of developers debugging is improved.

[0098] In another embodiment of the present disclosure, a preset path association script can be inserted into the process of component access to the software project. In this way, the above path association script can be triggered when the software project is accessed, and then in actual use, the path association relationship is generated by the path association script during the process of component access to the software project. Among them, the path association script can implement the method of steps S201-S203 above. For example, the preset path association script can be inserted into the process of component access to the software project through a custom "Hookpost_integrate" (a command to execute a custom operation). In this way, developers can be unaware of the process of generating path association relationships, making the operation simpler, improving the developer's user experience, and improving the efficiency of developers in debugging.

[0099] In addition, in the prior art, if the source code file of the component in which the error occurs is in an encrypted state, the developer needs to use the source code file decoding command to execute the decoding of the source code file. In the solution provided by the embodiment of the present disclosure, the source code file can be decoded after being downloaded to the local software project in advance, and the process of re-decoding the source code file of the component is reduced in the process of the developer debugging the project. In addition, in the prior art, when switching components, the developer needs to use the debugging tool to input the parameters required for the component to access the software project, and the developer manually inputs the parameters and is prone to errors. In the solution provided by the embodiment of the present disclosure, the preset path association script can be inserted into the process of the component accessing the software project, reducing the situation of manually inputting parameters when switching components. In this way, hot switching from binary files to source code can be achieved, simplifying the operation of developers, reducing the difficulty of debugging, and improving the efficiency of developers debugging code and locating code errors.

[0100] Corresponding to the above-mentioned source code display method, the embodiment of the present disclosure also provides a source code display device.

[0101] In one embodiment of the present disclosure, see Figure 3 A schematic diagram of the structure of a source code display device is provided, the device comprising:

[0102] The error location determination module 301 is used to determine the error location in the binary file of the first component based on the first debugging information generated by running the software project, wherein the first component is connected to the software project in binary form;

[0103] A path determination module 302 is used to determine a second path of a first source code file of the first component in the source code files locally stored in the software project based on the first path of the source code file of the first component recorded in the first debugging information and a pre-generated path association relationship, wherein the path association relationship is an association relationship between a local path of the first source code file and the first path, and the first path is a path of the source code file of the first component used when generating a binary file;

[0104] A path mapping module 303, used to map the first path to the second path;

[0105] The source code display module 304 is used to locate the source code to be debugged in the first source code file based on the mapping result and the error position, and display the source code to be debugged.

[0106] As can be seen from the above, in the solution provided by the embodiment of the present disclosure, the error location in the binary file of the first component can be determined according to the first debugging information generated by running the software project, and then based on the path association relationship between the pre-generated local path and the first path, the local path associated with the first path of the source code file of the first component recorded in the first debugging information is determined as the second path. In this way, after mapping the first path to the second path, the first source code file of the first component stored locally in the software project can be accessed based on the mapping result, and then the source code to be debugged can be located in the first source code file, and the source code to be debugged can be displayed, so as to realize the display of the source code corresponding to the error location in the binary file.

[0107] In one embodiment of the present disclosure, the path association relationship is pre-generated in the following manner:

[0108] After storing the first source code file of the first component locally in the software project, obtaining a local path of the first source code file locally in the software project;

[0109] Obtaining a path of a source code file of a first component used when generating a binary file as a first path;

[0110] The local path and the first path are connected to generate a path association relationship.

[0111] From the above, it can be seen that by obtaining the local path after storing the first source code file of the first component locally in the software engineering, and obtaining the path of the source code file of the first component used when generating the binary file, the path of the same source code file on two different devices can be accurately obtained, and a path association relationship can be generated, so that the debugging tool can accurately implement source code display based on the path association relationship.

[0112] In one embodiment of the present disclosure, obtaining a path of a source code file of a first component used when generating a binary file as a first path includes:

[0113] Requesting the file packaging device for the path of the source code file of the first component;

[0114] A packaging source code path read by a file packaging device from a packaging directory of a binary file is received as a first path, wherein the packaging source code path is: a path of a source code file of a first component used by the file packaging device when generating a binary file.

[0115] It can be seen that the packaged source code path read from the package directory of the binary file by the file packaging device is sent to the debugging tool. In this way, the debugging tool can reduce the need to parse the binary file, reduce the time for obtaining the path of the source code file, and improve the efficiency of pre-generating path association relationships.

[0116] In one embodiment of the present disclosure, the packaged source code path is stored in a file of a set type under the package directory.

[0117] In this way, the packaged source code path is stored in a file of a set type under the packaging directory of the file packaging device. When the binary files of the same component are connected to different software projects, the debugging tool can directly obtain the source code path from the file of a set type under the packaging directory of the packaging device. As the first path, the file of the set type can be reused, thereby reducing the repeated requests for the path of the source code file of the first component, saving time in reading the packaged source code path, and improving the efficiency of pre-generating path associations.

[0118] In one embodiment of the present disclosure, obtaining a path of a source code file of a first component used when generating a binary file as a first path includes:

[0119] Load the binary file into memory;

[0120] Parsing the binary file loaded in the memory, obtaining debugging information recorded in the binary file and generated in the process of generating the binary file as second debugging information;

[0121] In the second debugging information, determining a preset number of code lines in a statement of a preset format;

[0122] Intercepting characters of a preset field in the determined code line;

[0123] Based on the intercepted characters, a first path of a source code file of a first component used when generating a binary file is obtained.

[0124] In this way, the first path is obtained through the debugging information recorded in the binary file. The first path can be obtained without recording the path of the source code file used in the process of generating the binary file, which can improve the adaptability to various scenarios. In addition, the debugging information recorded in the binary file is more accurate, which can improve the accuracy of the obtained first path.

[0125] In one embodiment of the present disclosure, the first source code file is connected to the software project in binary form along with the first component and downloaded to the local software project.

[0126] In this way, the first source code file can be downloaded to the local software project through a relatively simple process, and the developer does not need to manually download the source code file again, which reduces the operating difficulty of the developer and makes the developer unaware of the process of downloading the source code file, thereby improving the developer's user experience and the developer's debugging efficiency.

[0127] In one embodiment of the present disclosure, the source code display module is specifically used to: determine the relative position of the source code to be debugged in the first source code file based on the error position; determine the absolute position of the source code to be debugged in the first source code file based on the mapping result and the relative position; locate the source code to be debugged in the first source code file based on the absolute position; and display the source code to be debugged.

[0128] In this way, by determining the relative position of the source code to be debugged in the first source code file, the accurate absolute position of the source code to be debugged in the first source code file is determined, and then the source code to be debugged in the first source code file can be located more accurately and quickly based on the absolute position.

[0129] In the technical solution of this disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals. For example, the user personal information involved may include the path information mentioned above.

[0130] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0131] According to another aspect of the present disclosure, there is provided an electronic device, comprising:

[0132] at least one processor; and

[0133] a memory communicatively connected to the at least one processor; wherein,

[0134] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the above-mentioned source code display method.

[0135] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the above-mentioned source code display method.

[0136] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, wherein the computer program implements the above-mentioned source code display method when executed by a processor.

[0137] Figure 4A schematic block diagram of an example electronic device 400 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0138] like Figure 4 As shown, the device 400 includes a computing unit 401, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 402 or a computer program loaded from a storage unit 408 into a random access memory (RAM) 403. In the RAM 403, various programs and data required for the operation of the device 400 can also be stored. The computing unit 401, the ROM 402, and the RAM 403 are connected to each other via a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0139] A number of components in the device 400 are connected to the I / O interface 405, including: an input unit 406, such as a keyboard, a mouse, etc.; an output unit 407, such as various types of displays, speakers, etc.; a storage unit 408, such as a disk, an optical disk, etc.; and a communication unit 409, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 409 allows the device 400 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0140] The computing unit 401 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 401 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 401 performs the various methods and processes described above, such as method source code display. For example, in some embodiments, the method source code display may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 408. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 400 via ROM 402 and / or communication unit 409. When the computer program is loaded into RAM 403 and executed by the computing unit 401, one or more steps of the method source code display described above may be performed. Alternatively, in other embodiments, the computing unit 401 may be configured to perform method source code display in any other appropriate manner (e.g., by means of firmware).

[0141] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0142] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0143] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0144] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0145] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0146] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.

[0147] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0148] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A source code display method, comprising: Determine an error location in a binary file of a first component based on first debugging information generated by running the software project, wherein the first component is connected to the software project in binary form; Based on the first path of the source code file of the first component recorded in the first debugging information and the pre-generated path association relationship, determine the second path of the first source code file of the first component in the source code files locally stored in the software project, wherein the path association relationship is: the association relationship between the local path of the first source code file and the first path, and the first path is: the path of the source code file of the first component used when generating the binary file; mapping the first path to the second path; Based on the mapping result and the error position, the source code to be debugged is located in the first source code file, and the source code to be debugged is displayed.

2. The method according to claim 1, wherein: The path association relationship is pre-generated in the following manner: After the first source code file of the first component is stored locally in the software project, a local path of the first source code file in the local software project is obtained; Obtaining a path of a source code file of the first component used when generating the binary file as a first path; The local path and the first path are connected to generate the path association relationship.

3. The method according to claim 2, wherein: The obtaining, as a first path, a path of a source code file of the first component used when generating the binary file includes: Requesting the file packaging device for the path of the source code file of the first component; A packaging source code path read by the file packaging device from the packaging directory of the binary file is received as a first path, wherein the packaging source code path is: a path of the source code file of the first component used by the file packaging device when generating the binary file.

4. The method according to claim 3, wherein: The packaged source code path is stored in a file of a set type under the package directory.

5. The method according to claim 2, wherein: The obtaining, as a first path, a path of a source code file of the first component used when generating the binary file includes: Loading the binary file into memory; Parsing the binary file loaded in the memory, and obtaining debugging information recorded in the binary file and generated in the process of generating the binary file as second debugging information; In the second debugging information, determining a preset number of code lines in a statement of a preset format; Intercepting characters of a preset field in the determined code line; Based on the intercepted characters, a first path of a source code file of the first component used when generating the binary file is obtained.

6. The method according to any one of claims 1 to 5, wherein: The first source code file is connected to the software project in binary form along with the first component and downloaded to the local computer of the software project.

7. The method according to any one of claims 1 to 5, wherein: The locating the source code to be debugged in the first source code file based on the mapping result and the error position, and displaying the source code to be debugged, comprises: Based on the error reporting position, determining the relative position of the source code to be debugged in the first source code file; Based on the mapping result and the relative position, determining the absolute position of the source code to be debugged in the first source code file; Based on the absolute position, locating the source code to be debugged in the first source code file; The source code to be debugged is displayed.

8. A source code display device, comprising: An error location determination module, configured to determine an error location in a binary file of a first component based on first debugging information generated by running a software project, wherein the first component is connected to the software project in binary form; a path determination module, configured to determine a second path of a first source code file of a first component in source code files locally stored in the software project based on a first path of the source code file of the first component recorded in the first debugging information and a pre-generated path association relationship, wherein the path association relationship is an association relationship between a local path of the first source code file and the first path, and the first path is a path of the source code file of the first component used when generating the binary file; a path mapping module, configured to map the first path to the second path; The source code display module is used to locate the source code to be debugged in the first source code file based on the mapping result and the error reporting position, and display the source code to be debugged.

9. The device according to claim 8, wherein: The path association relationship is pre-generated in the following manner: After the first source code file of the first component is stored locally in the software project, a local path of the first source code file in the local software project is obtained; Obtaining a path of a source code file of the first component used when generating the binary file as a first path; The local path and the first path are connected to generate the path association relationship.

10. The device according to claim 9, wherein: The obtaining, as a first path, a path of a source code file of the first component used when generating the binary file includes: Requesting the file packaging device for the path of the source code file of the first component; A packaging source code path read by the file packaging device from the packaging directory of the binary file is received as a first path, wherein the packaging source code path is: a path of the source code file of the first component used by the file packaging device when generating the binary file.

11. The device according to claim 10, wherein: The packaged source code path is stored in a file of a set type under the package directory.

12. The device according to claim 9, wherein: The obtaining, as a first path, a path of a source code file of the first component used when generating the binary file includes: Loading the binary file into memory; Parsing the binary file loaded in the memory, and obtaining debugging information recorded in the binary file and generated in the process of generating the binary file as second debugging information; In the second debugging information, determining a preset number of code lines in a statement of a preset format; Intercepting characters of a preset field in the determined code line; Based on the intercepted characters, a first path of a source code file of the first component used when generating the binary file is obtained.

13. The device according to any one of claims 8 to 12, wherein: The first source code file is connected to the software project in binary form along with the first component and downloaded to the local software project.

14. The device according to any one of claims 8 to 12, wherein: The source code display module is specifically used to: determine the relative position of the source code to be debugged in the first source code file based on the error reporting position; determine the absolute position of the source code to be debugged in the first source code file based on the mapping result and the relative position; Based on the absolute position, locating the source code to be debugged in the first source code file; The source code to be debugged is displayed.

15. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.

16. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-7.

17. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Data processing method and apparatus, electronic device and storage medium

    CN109344051A

  • Error code positioning method and device, storage medium and electronic equipment

    CN111090582A

  • Method and device for positioning source code in production environment and computer equipment

    CN112306872A

  • Source code debugging method and device, storage medium and computer equipment

    CN115587035A

  • Small program front-end error monitoring and early warning method, system and equipment and medium

    CN116340115A