Disclosure of Invention
In order to solve the problems that a large amount of workload is generated when the operation log is analyzed, abnormal codes cannot be located in real time, and the intelligence is low in the related technology, the invention provides a code locating method and device and electronic equipment.
According to a first aspect of embodiments of the present invention, there is provided a code positioning method, the method including:
when detecting that a system is abnormal, acquiring abnormal information and abnormal data, wherein the abnormal information carries an abnormal code line number of an abnormal code in a source code of the system, and the abnormal data at least comprises an input parameter, an output parameter and an operation variable;
locating an exception code in the source code based on the exception code line number, the exception code being a code in a code line indicated by the exception code line number;
and acquiring the abnormal code, and generating and displaying an abnormal notification, wherein the abnormal notification carries the abnormal code, the abnormal information and the abnormal data.
In another embodiment, before collecting the abnormal information and the abnormal data when the system is detected to be abnormal, the method further comprises:
when receiving an access request of the system, establishing data connection with the system based on acquisition equipment;
and receiving the source code transmitted by the system based on acquisition equipment, and correspondingly storing the system identification of the system and the source code.
In another embodiment, said locating exception code in said source code based on said exception code line number comprises:
determining a code line number of at least one line of code in the source code;
and positioning the code line number of the at least one line of codes, and taking the code in the code line with the code line number consistent with the abnormal code line number as the abnormal code.
In another embodiment, after locating exception code in the source code based on the code line number, the method further comprises:
and marking the abnormal information and the abnormal data at the specified position of the abnormal code based on a preset marking mode.
In another embodiment, the obtaining the exception code and generating and presenting an exception notification includes:
acquiring the abnormal code, and determining a preset format, wherein the preset format is used for indicating the format of the abnormal notification;
combining the abnormal code, the abnormal information and the abnormal data according to the preset format to generate the abnormal notification;
and displaying the exception notification.
According to a second aspect of embodiments of the present invention, there is provided a code locating apparatus, the apparatus comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring abnormal information and abnormal data when detecting that the system is abnormal, the abnormal information carries an abnormal code line number of a code with the abnormality in a source code of the system, and the abnormal data at least comprises input parameters, output parameters and operation variables;
the positioning module is used for positioning an abnormal code in the source code based on the abnormal code line number, wherein the abnormal code is a code in a code line indicated by the abnormal code line number;
and the generating module is used for acquiring the abnormal code, generating and displaying an abnormal notification, wherein the abnormal notification carries the abnormal code, the abnormal information and the abnormal data.
In another embodiment, the apparatus further comprises:
the system comprises an establishing module, a data receiving module and a data transmitting module, wherein the establishing module is used for establishing data connection with the system based on acquisition equipment when receiving an access request of the system;
and the receiving module is used for receiving the source code transmitted by the system based on the acquisition equipment and correspondingly storing the system identifier of the system and the source code.
In another embodiment, the positioning module comprises:
the determining submodule is used for determining the code line number of at least one line of codes in the source codes;
and the positioning submodule is used for positioning in the code line number of the at least one line of codes and taking the code in the code line with the code line number consistent with the abnormal code line number as the abnormal code.
In another embodiment, the apparatus further comprises:
and the marking module is used for marking the abnormal information and the abnormal data at the specified position of the abnormal code based on a preset marking mode.
In another embodiment, the generating module comprises:
the determining submodule is used for acquiring the abnormal code and determining a preset format, and the preset format is used for indicating the format of the abnormal notification;
the combination submodule is used for combining the abnormal code, the abnormal information and the abnormal data according to the preset format to generate the abnormal notification;
and the display submodule is used for displaying the abnormal notification.
The technical scheme provided by the embodiment of the invention can have the following beneficial effects:
when the system is detected to be abnormal, acquiring abnormal information and abnormal data, positioning the abnormal code in the source code based on the abnormal code line number carried by the abnormal information, acquiring the abnormal code, and generating and displaying an abnormal notice carrying the abnormal code, the abnormal information and the abnormal data.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the invention, as claimed.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the invention, as detailed in the appended claims.
FIG. 1 is a flow chart illustrating a method of code location, as shown in FIG. 1, according to an exemplary embodiment, including the following steps.
In step 101, when detecting that the system is abnormal, acquiring abnormal information and abnormal data, where the abnormal information carries an abnormal code line number of the abnormal code in a source code of the system, and the abnormal data at least includes an input parameter, an output parameter, and an operation variable.
In step 102, an exception code is located in the source code based on the exception code line number, the exception code being code in the code line indicated by the exception code line number.
In step 103, an exception code is obtained, and an exception notification is generated and displayed, where the exception notification carries the exception code, exception information, and exception data.
According to the method provided by the embodiment of the invention, when the system is detected to be abnormal, the abnormal information and the abnormal data are collected, the abnormal code is positioned in the source code based on the abnormal code line number carried by the abnormal information, the abnormal code is obtained, and the abnormal notice carrying the abnormal code, the abnormal information and the abnormal data is generated and displayed.
In another embodiment, when an abnormality of the system is detected, before collecting abnormality information and abnormality data, the method further includes:
when receiving an access request of a system, establishing data connection with the system based on acquisition equipment;
and receiving the source code transmitted by the system based on the acquisition equipment, and correspondingly storing the system identification of the system and the source code.
In another embodiment, locating the exception code in the source code based on the exception code line number includes:
determining a code line number of at least one line of code in the source code;
and positioning the code line number of at least one line of codes, and taking the code in the code line with the code line number consistent with the abnormal code line number as the abnormal code.
In another embodiment, after locating the exception code in the source code based on the code line number, the method further comprises:
and marking the abnormal information and the abnormal data at the specified position of the abnormal code based on a preset marking mode.
In another embodiment, obtaining exception code and generating and presenting an exception notification includes:
acquiring an abnormal code, and determining a preset format, wherein the preset format is used for indicating the format of the abnormal notification;
combining the abnormal code, the abnormal information and the abnormal data according to a preset format to generate an abnormal notification;
and displaying the exception notification.
All the above-mentioned optional technical solutions can be combined arbitrarily to form the optional embodiments of the present invention, and are not described herein again.
Before explaining the embodiments of the present invention in detail, a brief description will be given to an implementation architecture of code location according to the embodiments of the present invention.
Referring to fig. 2, the implementation architecture of code location according to the present invention includes a terminal and a location system. The terminal can be connected with the positioning system through a wireless or wired network, the terminal can be an electronic device which can access and transmit data to the positioning system, the electronic device can be a computer, a smart phone, a tablet computer or other electronic devices, and the terminal is provided with the system and provides various services for users based on the system.
The positioning system is used for monitoring the system of the terminal in real time, and when the system of the terminal is detected to be abnormal, the positioning system collects abnormal information and abnormal data in the system of the terminal, and then positions codes of the system of the terminal, which are abnormal, based on the abnormal information and the abnormal data. In the practical application process, referring to fig. 2, the positioning system may include a collecting device and an analyzing device, where the collecting device is configured to establish a data connection with the terminal, receive a source code uploaded by the terminal, transmit the source code to the analyzing device, and transmit the abnormal information and the abnormal data to the analyzing device when the abnormal information and the abnormal data are collected. The analysis equipment receives and stores the source codes of the system uploaded by the acquisition equipment, receives the abnormal information and the abnormal data uploaded by the acquisition equipment when the acquisition equipment detects that the system of the terminal is abnormal, analyzes the abnormal information and the abnormal data, and then positions the codes with the abnormality in the source codes of the system.
FIG. 3 is a flow chart illustrating a method of code location, as shown in FIG. 3, according to an exemplary embodiment, including the following steps.
In step 301, when an access request of the system is received, a data connection with the system is established based on the acquisition device, and the receiving system stores a system identifier of the system corresponding to a source code based on the source code transmitted by the acquisition device.
In the embodiment of the present invention, the operation of the system is substantially a process of operating a plurality of programs in the system, the system includes at least one program, and when the system needs to provide a service for a user, the at least one program in the system starts to operate. Each program in at least one program corresponds to different source codes, and the program is compiled to run through the source codes. In order to locate the code with abnormality when detecting the abnormality of the system in the following, the locating system needs to acquire the source code in the system mounted on the terminal when detecting the access of the terminal.
When receiving the system request access of the terminal, the positioning system can establish data connection with the system of the terminal, receive the source code transmitted by the system, and correspondingly store the system identification of the system and the source code. In the actual application process, because the positioning system may include the acquisition device and the analysis device, the positioning system may receive an access request sent by a system of the terminal based on the acquisition device, establish a data connection with the system based on the acquisition device, receive a source code transmitted by the system by the acquisition device, and then transmit the received source code to the analysis device for storage. The embodiment of the present invention does not specifically limit the manner of establishing data connection between the positioning system and the manner of receiving the source code. In order to avoid confusion between the received source codes of the systems of the plurality of terminals, the system identification needs to be stored in correspondence with the source codes, considering that the systems of the plurality of terminals access the positioning system at the same time. In order to facilitate the storage of the system identifier corresponding to the source code, when the positioning system receives the source code, the positioning system may number the source code, generate a code number corresponding to the currently received source code, and store the code number corresponding to the system identifier. Wherein, the analysis device may generate a source code list as shown in table 1 when storing the correspondence between the source code and the system identifier. The embodiment of the present invention does not specifically limit the manner of the correspondence between the storage system identifier and the source code.
TABLE 1
| System identification
|
Code numbering
|
| System A
|
Source code 1
|
| System B
|
Source code 2
|
| …
|
… |
In step 302, when detecting that the system is abnormal, acquiring abnormal information and abnormal data, where the abnormal information carries an abnormal code line number of the abnormal code in the source code of the system, and the abnormal data at least includes an input parameter, an output parameter, and an operation variable.
In the embodiment of the invention, when the system is detected to be abnormal, in order to locate the abnormal code in the subsequent process, the abnormal information and the abnormal data in the system need to be collected immediately after the abnormality is detected. The essence of the system operation is program operation, the code of the program comprises a plurality of functions, and when the program is operated, the functions in the program generate data comprising input parameters, output parameters and operation variables during the operation, and the abnormal data definitely records the operation process of the program in the system, so that when the system is detected to be abnormal, the positioning system collects the abnormal data comprising the input parameters, the output parameters and the operation variables in the system.
In the practical application process, if the positioning system comprises the acquisition device and the analysis device, the positioning system can monitor the system of the accessed terminal in real time based on the acquisition device, acquire abnormal information and abnormal data in the system of the terminal by the acquisition device when the system monitoring the terminal is abnormal, and transmit the acquired abnormal information and abnormal data to the analysis device in the positioning system by the acquisition device in the subsequent process.
In step 303, the code line number of at least one line of code in the source code is determined, positioning is performed in the code line number of at least one line of code, and the code in the code line with the code line number consistent with the code line number of the exception code is taken as the exception code.
In the embodiment of the invention, the exception code is a code in a code line indicated by an exception code line number carried in the exception information. After the abnormal information of the system is collected, the abnormal code line number can be extracted from the abnormal information so as to determine the code indicated by the abnormal code line number in the source code of the system, and the code indicated by the abnormal code line number in the source code is taken as the abnormal code. The code in the source code is arranged in lines, so the code line number of at least one line of code in the source code can be determined first, and then the exception code is determined in the code line number of at least one line of code in the source code based on the exception code line number carried in the exception information. For example, if the exception code line number carried in the exception information is 116 lines, all codes in the 116 th line of at least one line of codes in the source code are taken as exception codes.
In step 304, based on a preset labeling manner, the abnormal information and the abnormal data are labeled at the specified position of the abnormal code.
In the embodiment of the invention, after the abnormal code is determined, because a plurality of codes which are abnormal at the same time are possible, developers can clearly acquire related data of the abnormal code when viewing the abnormal code, and then classify the current abnormal problem based on the abnormal code, the abnormal information and the abnormal data, therefore, after the abnormal code is determined, the abnormal information and the abnormal data can be marked at the specified position of the abnormal code based on a preset marking mode. The preset labeling mode can be label labeling, character labeling, line labeling and the like, and the designated positions can be the upper left corner, the upper right corner, the lower left corner and the like of the code line where the abnormal code is located.
In the practical application process, the positioning system can provide a label setting inlet on a terminal which is in data connection with the positioning system, when the label setting inlet is detected to be triggered by a user, a label mode selection frame, a label position selection frame and a confirmation button are displayed, when the confirmation button is detected to be triggered by the user, a label mode selected by the user in the label mode selection frame is obtained as a preset label mode, a label position selected by the user in the label position selection frame is obtained as an appointed position, and therefore when the subsequent system is detected to be abnormal, abnormal information and abnormal data collected when the system is abnormal are displayed based on the preset label mode and the appointed position.
In step 305, an exception code is obtained, a preset format is determined, the exception code, exception information and exception data are combined according to the preset format to generate an exception notification, and the exception notification is displayed, wherein the preset format is used for indicating the format of the exception notification.
In the embodiment of the invention, after the abnormal code is determined, an abnormal notification can be generated based on the abnormal code, the abnormal information and the abnormal data, so that the developer can be notified based on the abnormal notification. When the abnormal notification is generated, the abnormal code, the abnormal information and the abnormal data can be combined according to a fixed format in the positioning system to generate the abnormal notification; or a developer can set a preset format and combine the abnormal code, the abnormal information and the abnormal data according to the preset number to generate an abnormal notification. The preset format can be an embedded format, a labeling format, a detailed format and the like, if the preset format is the embedded format, the abnormal information and the abnormal data can be embedded into the abnormal code when the abnormal notification is generated, and then the abnormal notification is generated; if the preset format is the labeling format, a labeling frame comprising abnormal information and abnormal data can be generated when the abnormal notification is generated, and the labeling frame points to a specified position in the abnormal code; if the preset format is a detailed format, the exception code, the exception information and the exception data can be arranged and displayed in sequence when the exception notification is generated. The method of generating the abnormality notification according to the embodiment of the present invention is not particularly limited.
According to the method provided by the embodiment of the invention, when the system is detected to be abnormal, the abnormal information and the abnormal data are collected, the abnormal code is positioned in the source code based on the abnormal code line number carried by the abnormal information, the abnormal code is obtained, and the abnormal notice carrying the abnormal code, the abnormal information and the abnormal data is generated and displayed.
FIG. 4A is a block diagram illustrating a code location device according to an exemplary embodiment. Referring to fig. 4A, the apparatus includes an acquisition module 401, a location module 402 and a generation module 403.
The acquisition module 401 is configured to acquire, when detecting that the system is abnormal, abnormal information and abnormal data, where the abnormal information carries an abnormal code line number of an abnormal code in a source code of the system, and the abnormal data at least includes an input parameter, an output parameter, and an operation variable;
the positioning module 402 is configured to position an exception code in a source code based on an exception code line number, where the exception code is a code in a code line indicated by the exception code line number;
the generating module 403 is configured to obtain an exception code, generate and display an exception notification, where the exception notification carries the exception code, exception information, and exception data.
According to the device provided by the embodiment of the invention, when the system is detected to be abnormal, the abnormal information and the abnormal data are collected, the abnormal code is positioned in the source code based on the abnormal code line number carried by the abnormal information, the abnormal code is obtained, and the abnormal notice carrying the abnormal code, the abnormal information and the abnormal data is generated and displayed.
In another embodiment, referring to fig. 4B, the apparatus further comprises a establishing module 404 and a receiving module 405.
The establishing module 404 is configured to, when receiving an access request of a system, establish a data connection with the system based on an acquisition device;
the receiving module 405 is configured to receive a source code transmitted by the system based on the acquisition device, and store a system identifier of the system in correspondence with the source code.
In another embodiment, referring to FIG. 4C, the locate module 402 includes a determine sub-module 4021 and a locate sub-module 4022.
The determining submodule 4021 is configured to determine a code line number of at least one line of code in the source code;
the positioning sub-module 4022 is configured to position a code line number of at least one line of codes, and use a code in a code line with a code line number that is consistent with a code line number of an exception code as an exception code.
In another embodiment, referring to fig. 4D, the apparatus further comprises a labeling module 406.
The labeling module 406 is configured to label the abnormal information and the abnormal data at a specified position of the abnormal code based on a preset labeling manner.
In another embodiment, referring to fig. 4E, the generating module 403 includes a determining sub-module 4031, a combining sub-module 4032 and a presenting sub-module 4033.
The determining submodule 4031 is configured to obtain an exception code and determine a preset format, where the preset format is used to indicate a format of an exception notification;
the combining submodule 4032 is configured to combine the exception code, the exception information, and the exception data according to a preset format, and generate an exception notification;
the display sub-module 4033 is used for displaying an exception notification.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
Fig. 5 is a schematic structural diagram of an electronic device 500 according to an embodiment of the present invention. Referring to fig. 5, the electronic device 500 includes a communication bus, a processor, a memory, and a communication interface, and may further include an input/output interface and a display device, wherein the functional units may communicate with each other through the bus. The memory stores computer programs, and the processor is used for executing the programs stored in the memory and executing the video data processing method in the embodiment.
A bus is a circuit that connects the described elements and enables transmission between these elements. For example, the processor receives commands from other elements through the bus, decrypts the received commands, and performs calculations or data processing according to the decrypted commands. The memory may include program modules such as a kernel (kernel), middleware (middleware), an Application Programming Interface (API), and applications. The program modules may be comprised of software, firmware or hardware, or at least two of the same. The input-output interface forwards commands or data input by a user via an input-output device (e.g., sensor, keyboard, touch screen). The display device displays various information to a user. The communication interface connects the electronic device 500 with other network devices, user equipment, networks. For example, the communication interface may be connected to a network by wire or wirelessly to connect to external other network devices or user devices. The wireless communication may include at least one of: wireless Fidelity (WiFi), Bluetooth (BT), Near Field Communication (NFC), Global Positioning System (GPS) and cellular Communication (cellular Communication) (e.g., Long Term Evolution (LTE)), Long Term Evolution (Long Term Evolution) followed by Long Term Evolution (LTE-Advanced), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (CDMA, WCDMA), Universal Mobile telecommunications System (Universal Mobile telecommunications System, UMTS), Wireless Broadband Access (Wireless Broadband bro) and Global System for Mobile communications (GSM) may include at least one of the following Wireless Communication systems (WiFi), Wireless Multimedia Communication (Bluetooth, BT), Wireless Broadband Communication (GSM), Wireless Serial Communication (GSM), Wireless Multimedia Communication (HDMI, GSM), RS-232), and Plain Old Telephone Service (POTS). The network may be a telecommunications network and a communications network. The communication network may be a computer network, the internet of things, a telephone network. The electronic device 500 may be connected to a network through a communication Interface, and a protocol used for the electronic device 500 to communicate with other network devices may be supported by at least one of an Application, an Application Programming Interface (API), middleware, a kernel, and a communication Interface.
A1, a code positioning method, comprising:
when detecting that a system is abnormal, acquiring abnormal information and abnormal data, wherein the abnormal information carries an abnormal code line number of an abnormal code in a source code of the system, and the abnormal data at least comprises an input parameter, an output parameter and an operation variable;
locating an exception code in the source code based on the exception code line number, the exception code being a code in a code line indicated by the exception code line number;
and acquiring the abnormal code, and generating and displaying an abnormal notification, wherein the abnormal notification carries the abnormal code, the abnormal information and the abnormal data.
A2, the method according to claim 1, wherein before collecting abnormal information and abnormal data when detecting the system abnormality, the method further comprises:
when receiving an access request of the system, establishing data connection with the system based on acquisition equipment;
and receiving the source code transmitted by the system based on acquisition equipment, and correspondingly storing the system identification of the system and the source code.
A3 the method of claim 1, wherein locating exception code in the source code based on the exception code line number comprises:
determining a code line number of at least one line of code in the source code;
and positioning the code line number of the at least one line of codes, and taking the code in the code line with the code line number consistent with the abnormal code line number as the abnormal code.
A4, the method as recited in claim 1, wherein after locating exception code in the source code based on the code line number, the method further comprises:
and marking the abnormal information and the abnormal data at the specified position of the abnormal code based on a preset marking mode.
A5 the method according to claim 1, wherein the obtaining the exception code, generating and presenting an exception notification includes:
acquiring the abnormal code, and determining a preset format, wherein the preset format is used for indicating the format of the abnormal notification;
combining the abnormal code, the abnormal information and the abnormal data according to the preset format to generate the abnormal notification;
and displaying the exception notification.
A6, a code positioning device, comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring abnormal information and abnormal data when detecting that the system is abnormal, the abnormal information carries an abnormal code line number of a code with the abnormality in a source code of the system, and the abnormal data at least comprises input parameters, output parameters and operation variables;
the positioning module is used for positioning an abnormal code in the source code based on the abnormal code line number, wherein the abnormal code is a code in a code line indicated by the abnormal code line number;
and the generating module is used for acquiring the abnormal code, generating and displaying an abnormal notification, wherein the abnormal notification carries the abnormal code, the abnormal information and the abnormal data.
A7, the device of claim 6, wherein the device further comprises:
the system comprises an establishing module, a data receiving module and a data transmitting module, wherein the establishing module is used for establishing data connection with the system based on acquisition equipment when receiving an access request of the system;
and the receiving module is used for receiving the source code transmitted by the system based on the acquisition equipment and correspondingly storing the system identifier of the system and the source code.
A8, the device according to claim 6, wherein the positioning module comprises:
the determining submodule is used for determining the code line number of at least one line of codes in the source codes;
and the positioning submodule is used for positioning in the code line number of the at least one line of codes and taking the code in the code line with the code line number consistent with the abnormal code line number as the abnormal code.
A9, the device of claim 6, wherein the device further comprises:
and the marking module is used for marking the abnormal information and the abnormal data at the specified position of the abnormal code based on a preset marking mode.
A10, the apparatus of claim 6, wherein the generating module comprises:
the determining submodule is used for acquiring the abnormal code and determining a preset format, and the preset format is used for indicating the format of the abnormal notification;
the combination submodule is used for combining the abnormal code, the abnormal information and the abnormal data according to the preset format to generate the abnormal notification;
and the display submodule is used for displaying the abnormal notification.
A11, an electronic device, comprising the code positioning device of any one of claims 6 to 10.
A12, an electronic device, comprising: a memory for storing executable instructions;
and a processor in communication with the memory to execute the executable instructions to perform the operations of the code location method of any of claims 1 to 5.
Other embodiments of the invention will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the invention and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the invention being indicated by the following claims.
It will be understood that the invention is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the invention is limited only by the appended claims.