CN114185803A - Page script debugging method and device, computer readable storage medium and server - Google Patents

Page script debugging method and device, computer readable storage medium and server Download PDF

Info

Publication number
CN114185803A
CN114185803A CN202111549120.3A CN202111549120A CN114185803A CN 114185803 A CN114185803 A CN 114185803A CN 202111549120 A CN202111549120 A CN 202111549120A CN 114185803 A CN114185803 A CN 114185803A
Authority
CN
China
Prior art keywords
page script
script
target
debugging
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111549120.3A
Other languages
Chinese (zh)
Inventor
范荣滨
王雄伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Property and Casualty Insurance Company of China Ltd
Original Assignee
Ping An Property and Casualty Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Property and Casualty Insurance Company of China Ltd filed Critical Ping An Property and Casualty Insurance Company of China Ltd
Priority to CN202111549120.3A priority Critical patent/CN114185803A/en
Publication of CN114185803A publication Critical patent/CN114185803A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/366Software debugging using diagnostics

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention belongs to the technical field of artificial intelligence, and particularly relates to a page script debugging method and device, a computer readable storage medium and a server. The method comprises the following steps: acquiring a target page script to be debugged, and adding a preset stack tracking identifier in each execution function of the target page script to obtain a rewritten page script; running the rewriting page script in a preset browser, and capturing the exception thrown by the rewriting page script in the running process; determining a function call path of the rewritten page script when the exception is thrown according to the stack trace identifier; determining a first position of an abnormal code in the rewriting page script according to the function calling path; and mapping codes according to the first position to obtain a second position of the abnormal code in the target page script. By the invention, a large amount of time and labor can be saved, and the working efficiency is greatly improved.

Description

Page script debugging method and device, computer readable storage medium and server
Technical Field
The invention belongs to the technical field of artificial intelligence, and particularly relates to a page script debugging method and device, a computer readable storage medium and a server.
Background
With the development of computer technology, more and more users have chosen to obtain information by browsing pages on a browser. In the existing page design, page scripts programmed by JavaScript are more and more widely used, and the page scripts can not only reduce the scale of a page and improve the browsing speed of the page, but also enrich the content and the expression of the page, such as adding pictures, animations, sounds and the like.
In order to achieve the optimal page display effect, before the page script is formally put on line and put into use, debugging is generally required to be performed so that developers can find and repair the abnormality in time. However, since JavaScript is an interpreted language based on a browser, codes are compressed and then directly run on the browser, which makes it difficult to locate the source of an exception once the exception is thrown. In a conventional debugging process, when an error report of a console is received, a developer generally searches a source file from a resource panel of the console, and debugs the source file in the resource panel in a breakpoint manner, which consumes a lot of time and labor and has extremely low efficiency.
Disclosure of Invention
In view of this, embodiments of the present invention provide a page script debugging method and apparatus, a computer-readable storage medium, and a server, so as to solve the problems that the existing page script debugging method needs to consume a lot of time and labor, and has extremely low efficiency.
A first aspect of an embodiment of the present invention provides a page script debugging method, which may include:
acquiring a target page script to be debugged, and adding a preset stack tracking identifier in each execution function of the target page script to obtain a rewritten page script;
running the rewriting page script in a preset browser, and capturing the exception thrown by the rewriting page script in the running process;
determining a function call path of the rewritten page script when the exception is thrown according to the stack trace identifier;
determining a first position of an abnormal code in the rewriting page script according to the function calling path;
and mapping codes according to the first position to obtain a second position of the abnormal code in the target page script.
In a specific implementation manner of the first aspect, the determining, according to the stack trace identifier, a function call path of the rewritten page script when the exception is thrown may specifically include:
determining the sequence of each execution function from the stack top to the stack bottom in a preset stack when the exception is thrown according to the stack tracking identifier;
determining the function call path according to the sequence of each execution function in the stack; and calling the execution functions ordered at the N-1 th bit by the execution functions ordered at the N-th bit, wherein N is more than 1 and less than or equal to N, and N is the number of the execution functions.
In a specific implementation manner of the first aspect, the performing code mapping according to the first location to obtain a second location of the exception code in the target page script may specifically include:
acquiring a code mapping file corresponding to the target page script from a preset database, wherein the code mapping file is a file for recording the position corresponding relation between the target page script and each code in the rewritten page script;
querying a target position through the code mapping file, wherein the target position is a position corresponding to the first position in the target page script;
and determining the target position as a second position of the abnormal code in the target page script.
In a specific implementation manner of the first aspect, the running the rewritten page script in a preset browser may specifically include:
reading a preset data source indicator from a script configuration file corresponding to the target page script; wherein the data source indicator is used for indicating a data source of the debugging data;
acquiring target debugging data; the target debugging data is debugging data stored in a data source corresponding to the data source indicator;
and running the rewriting page script in the browser based on the target debugging data.
In a specific implementation manner of the first aspect, the obtaining target debug data may specifically include:
if the data source indicator is a preset first value, reading a local storage address from the script configuration file, and taking debugging data read from the local storage address as the target debugging data;
and if the data source indicator is a preset second value, reading a remote storage address from the script configuration file, and taking the debugging data read from the remote storage address as the target debugging data.
In a specific implementation manner of the first aspect, the setting process of the data source indicator may specifically include:
detecting a data transmission rate between the data transmission device and a preset remote data source;
if the data transmission rate is smaller than a preset rate threshold, setting the data source indicator as the first value;
and if the data transmission rate is greater than or equal to the rate threshold, setting the data source indicator to the second value.
In a specific implementation manner of the first aspect, the obtaining a target page script to be debugged may specifically include:
receiving a page script debugging instruction sent by terminal equipment, and extracting a page script identifier in the page script debugging instruction;
searching a script corresponding to the page script identification in a preset script library;
and determining the script corresponding to the page script identifier as the target page script.
A second aspect of an embodiment of the present invention provides a page script debugging apparatus, which may include:
the page script acquisition module is used for acquiring a target page script to be debugged and adding a preset stack tracking identifier in each execution function of the target page script to obtain a rewritten page script;
the page script running module is used for running the rewriting page script in a preset browser and capturing the exception thrown out by the rewriting page script in the running process;
a calling path determining module, configured to determine, according to the stack trace identifier, a function calling path of the rewritten page script when the exception is thrown;
the position determining module is used for determining a first position of an abnormal code in the rewriting page script according to the function calling path;
and the code mapping module is used for carrying out code mapping according to the first position to obtain a second position of the abnormal code in the target page script.
In a specific implementation manner of the second aspect, the call path determining module may specifically include:
the function sorting unit is used for determining the sorting of each execution function from the stack top to the stack bottom in a preset stack when the exception is thrown according to the stack tracking identifier;
a function call path determining unit, configured to determine the function call path according to the order of each execution function in the stack; and calling the execution functions ordered at the N-1 th bit by the execution functions ordered at the N-th bit, wherein N is more than 1 and less than or equal to N, and N is the number of the execution functions.
In a specific implementation manner of the second aspect, the code mapping module may specifically include:
a code mapping file obtaining unit, configured to obtain a code mapping file corresponding to the target page script from a preset database, where the code mapping file is a file that records a position corresponding relationship between the target page script and each code in the rewritten page script;
the query unit is used for querying a target position through the code mapping file, wherein the target position is a position corresponding to the first position in the target page script;
and the position determining unit is used for determining the target position as a second position of the abnormal code in the target page script.
In a specific implementation manner of the second aspect, the page script execution module may specifically include:
a data source indicator reading unit, configured to read a preset data source indicator from a script configuration file corresponding to the target page script; wherein the data source indicator is used for indicating a data source of the debugging data;
a debug data acquisition unit for acquiring target debug data; the target debugging data is debugging data stored in a data source corresponding to the data source indicator;
and the page script running unit is used for running the rewriting page script in the browser based on the target debugging data.
In a specific implementation manner of the second aspect, the debug data obtaining unit may be specifically configured to: if the data source indicator is a preset first value, reading a local storage address from the script configuration file, and taking debugging data read from the local storage address as the target debugging data; and if the data source indicator is a preset second value, reading a remote storage address from the script configuration file, and taking the debugging data read from the remote storage address as the target debugging data.
In a specific implementation manner of the second aspect, the page script execution module may further include a data source indicator setting unit. The data source indicator setting unit may be specifically configured to: detecting a data transmission rate between the data transmission device and a preset remote data source; if the data transmission rate is smaller than a preset rate threshold, setting the data source indicator as the first value; and if the data transmission rate is greater than or equal to the rate threshold, setting the data source indicator to the second value.
In a specific implementation manner of the second aspect, the page script obtaining module may specifically include:
the page script debugging instruction receiving unit is used for receiving a page script debugging instruction sent by the terminal equipment and extracting a page script identifier in the page script debugging instruction;
the script searching unit is used for searching a script corresponding to the page script identification in a preset script library;
and the target page script determining unit is used for determining the script corresponding to the page script identifier as the target page script.
A third aspect of the embodiments of the present invention provides a computer-readable storage medium, where a computer program is stored, and the computer program, when executed by a processor, implements the steps of any one of the above-mentioned page script debugging methods.
A fourth aspect of the embodiments of the present invention provides a server, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements any one of the steps of the page script debugging method when executing the computer program.
A fifth aspect of embodiments of the present invention provides a computer program product, which, when running on a server, causes the server to perform any of the steps of the page script debugging method described above.
Compared with the prior art, the embodiment of the invention has the following beneficial effects: the method comprises the steps of obtaining a target page script to be debugged, and adding preset stack tracking identifiers in each execution function of the target page script to obtain a rewritten page script; running the rewriting page script in a preset browser, and capturing the exception thrown by the rewriting page script in the running process; determining a function call path of the rewritten page script when the exception is thrown according to the stack trace identifier; determining a first position of an abnormal code in the rewriting page script according to the function calling path; and mapping codes according to the first position to obtain a second position of the abnormal code in the target page script. In the embodiment of the invention, page script debugging is not required to be carried out in a traditional breakpoint mode, but a function call path is determined when abnormal throwing out is carried out in a stack tracking identification adding mode, and accordingly, the positioning of abnormal codes is realized, a large amount of time and labor can be saved, and the working efficiency is greatly improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a flowchart of an embodiment of a method for debugging a page script according to an embodiment of the present invention;
FIG. 2 is a schematic flow diagram of running a rewrite page script in a default browser;
FIG. 3 is a block diagram of an embodiment of a page script debugging apparatus according to an embodiment of the present invention;
fig. 4 is a schematic block diagram of a server according to an embodiment of the present invention.
Detailed Description
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the embodiments described below are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The embodiment of the invention can acquire and process related data based on an artificial intelligence technology. Among them, Artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
The artificial intelligence infrastructure generally includes technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operation/interaction systems, mechatronics, and the like. The artificial intelligence software technology mainly comprises a computer vision technology, a robot technology, a biological recognition technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and the like.
The execution subject of the embodiment of the invention can be a server based on artificial intelligence, and is used for executing the page script debugging method in the embodiment of the invention. The server may be an independent server, or may be a cloud server that provides basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), a big data and artificial intelligence platform, and the like.
Referring to fig. 1, an embodiment of a method for debugging a page script according to an embodiment of the present invention may include:
step S101, a target page script to be debugged is obtained, and a preset stack tracking identifier is added to each execution function of the target page script to obtain a rewriting page script.
In the embodiment of the present invention, the target page script may be a page script programmed by using JavaScript. JavaScript is a high-level scripting Language belonging to the internet, has been widely used for web application development, is often used to add various dynamic functions to a hypertext Markup Language (HTML) web page, and provides a smoother and more beautiful browsing effect for a user.
When the page script is required to be debugged, a developer can send a page script debugging instruction to the server through preset terminal equipment, the page script debugging instruction carries a page script identifier, the page script identifier is used for indicating a page script to be debugged, and the page script identifiers corresponding to different page scripts are different. After receiving the page script debugging instruction sent by the terminal device, the server may extract the page script identifier in the page script debugging instruction, search for the script corresponding to the page script identifier in a preset script library, and determine the searched script as the target page script.
After the target page script is obtained, the server may use a page Assembly (Web Assembly, WASM) in a Virtual Machine (Virtual Machine) environment as a JavaScript language as an intermediate layer for connecting the target page script and a preset browser, where in the embodiment of the present invention, the intermediate layer may be loaded into the browser in a browser plug-in form. The WASM can realize the running of a program based on a stack machine model and a virtual instruction set, wherein the stack machine model is a common memory management structure and pushes data and operation characters into a stack and pops the data and the operation characters to be executed in sequence, and the virtual instruction set is a series of self-defined operation characters which are irrelevant to a platform. The browser may be any one of the browsers in the prior art, and may include, but is not limited to Chrome, Edge, Mozilla, Safari, Firefox, and the like.
In the embodiment of the present invention, the target page script may be processed by the browser plug-in first and then run in the browser. In this processing procedure, starting from the entry file of the target page script, a preset stack trace identifier may be added to each execution function of the target page script, and for convenience of distinction, the page script to which the stack trace identifier is added is recorded as a rewrite page script.
The stack trace identifier may be set according to an actual situation, and a console provided in JavaScript is preferably used as the stack trace identifier in the embodiment of the present invention, and of course, other stack trace identifiers may also be set according to an actual situation, which is not specifically limited in the embodiment of the present invention.
And S102, running the rewriting page script in a preset browser, and capturing the exception thrown by the rewriting page script in the running process.
Generally, the script needs to depend on specific debugging data when running, and in a specific implementation of the embodiment of the present invention, step S102 may specifically include a process as shown in fig. 2:
and step S1021, reading a preset data source indicator from the script configuration file corresponding to the target page script.
The data source indicator is used for indicating a data source of the debugging data, and specific values of the data source indicator can be set by a developer according to actual conditions and can also be automatically adjusted by the server.
For example, the server may detect a data transmission rate between itself and a preset remote data source, and set the data source indicator to a preset first value if the data transmission rate is smaller than a preset rate threshold; and if the data transmission rate is greater than or equal to the rate threshold, setting the data source indicator to be a preset second value. The rate threshold may be set according to actual conditions, and is not specifically limited in the embodiment of the present invention. The first value and the second value may both be set according to actual conditions, and in a specific implementation manner of the embodiment of the present invention, the first value may be set to 1, and the second value may be set to 0; in another specific implementation manner of the embodiment of the present invention, the first value may be set to 0, and the second value may be set to 1, and of course, other forms of setting may also be performed according to actual situations, which is not specifically limited in the embodiment of the present invention.
Step S1022, target debug data is acquired.
The target debugging data is debugging data stored in a data source corresponding to the data source indicator.
If the data source indicator is the first value, reading a local storage address from the script configuration file, and taking debugging data read from the local storage address as the target debugging data; and if the data source indicator is the second value, reading a remote storage address from the script configuration file, and taking debugging data read from the remote storage address as the target debugging data. The local storage address is a storage address of the server, and the remote storage address is a storage address of the remote data source.
And S1023, running the rewritten page script in the browser based on the target debugging data.
During the operation of the rewrite page script in the browser, some unexpected abnormal situation may occur due to the carelessness of the programming process, for example, a certain piece of code in the rewrite page script tries to open a non-existing file, etc. At this time, the abnormality thrown out in the process of running the rewritten page script in the browser can be captured by the browser plug-in, and step S103 to step S105 are executed.
It is easily understood that if the rewritten page script can be executed smoothly in the whole running process without throwing any exception, the debugging can be considered to be successful, and the steps S103 to S105 do not need to be executed again.
And S103, determining a function call path of the rewritten page script when the exception is thrown according to the stack tracking identifier.
And when the rewritten page script runs in the browser, the execution functions of the stack tracking identifier are sequentially pressed into a preset stack. The stack is a particular memory area or register that is fixed at one end (i.e., the bottom of the stack) and floating at the other end (i.e., the top of the stack). The data stored in the storage area of the stack is a special data structure. All data storage or retrieval can only be performed at the top of the stack, and access is strictly performed according to the principle of "first-in last-out", and elements located in the middle of the stack must be retrieved after elements on the upper part of the stack (last-in-stack) are removed one by one.
In the embodiment of the present invention, the function call path of the rewritten page script when the exception is thrown may be determined according to the sequence of each execution function in the stack where the stack trace identifier is located. Firstly, determining the sequence of each execution function from the top of the stack to the bottom of the stack when the exception is thrown according to the stack trace identification. Then, the function call path is determined according to the sequence of each execution function in the stack. And calling the execution functions ordered at the N-1 th bit by the execution functions ordered at the N-th bit, wherein N is more than 1 and less than or equal to N, and N is the number of the execution functions.
For example, if the exception is thrown, the execution functions are sequentially ordered from the top of the stack to the bottom of the stack in the stack as follows: a first function, a second function, a third function, a fourth function, and a fifth function, where the function call path at this time should be: the fifth function calls the fourth function, the fourth function calls the third function, the third function calls the second function, the second function calls the first function, namely: fifth function → fourth function → third function → second function → first function, and so on.
And step S104, determining a first position of an abnormal code in the rewriting page script according to the function calling path.
The abnormal code is a code which is executed by the rewriting page script when the abnormality is thrown, after the function calling path is determined, the abnormal code can be searched downwards layer by layer along the function calling path until the abnormal code is found, the position of the abnormal code in the rewriting page script is recorded, and the position is recorded as a first position for distinguishing.
And S105, mapping codes according to the first position to obtain a second position of the abnormal code in the target page script.
In the embodiment of the present invention, a preset code mapping file (Source Map) may be used to perform code mapping, where the code mapping file is a file that records a position correspondence between the target page script and each code in the rewritten page script, and the code mapping file may be stored in a preset database.
Specifically, in the process of converting the target page script into the rewritten page script, the position of each code in the target page script and the position of each code in the rewritten page script may be recorded, and a corresponding relationship between the two may be established. For example, if the position of a certain code in the target page script is marked as LineX, and the position in the rewritten page script is marked as LineX ', a corresponding relationship between LineX and LineX' may be established, and the corresponding relationship is recorded in the code mapping file.
After the first position is obtained, a code mapping file corresponding to the target page script may be obtained from the database, and a target position is queried through the code mapping file, where the target position is a position in the target page script corresponding to the first position. Finally, the target location is determined as the location of the exception code in the target page script, which is denoted herein as the second location for ease of distinction.
After the positioning of the abnormal code in the target page script is completed, a developer can repair the abnormal code in the target page script according to the actual situation, so that the repaired target page script is obtained. Then, the above page script debugging process can be performed on the repaired target page script again until no exception is thrown in the whole script running process, and then the debugging can be considered to be successful.
In summary, in the embodiments of the present invention, a target page script to be debugged is obtained, and a preset stack trace identifier is added to each execution function of the target page script to obtain a rewritten page script; running the rewriting page script in a preset browser, and capturing the exception thrown by the rewriting page script in the running process; determining a function call path of the rewritten page script when the exception is thrown according to the stack trace identifier; determining a first position of an abnormal code in the rewriting page script according to the function calling path; and mapping codes according to the first position to obtain a second position of the abnormal code in the target page script. In the embodiment of the invention, page script debugging is not required to be carried out in a traditional breakpoint mode, but a function call path is determined when abnormal throwing out is carried out in a stack tracking identification adding mode, and accordingly, the positioning of abnormal codes is realized, a large amount of time and labor can be saved, and the working efficiency is greatly improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
Fig. 3 shows a structure diagram of an embodiment of a page script debugging apparatus according to an embodiment of the present invention, which corresponds to the page script debugging method described in the foregoing embodiment.
In this embodiment, a page script debugging apparatus may include:
a page script obtaining module 301, configured to obtain a target page script to be debugged, and add a preset stack trace identifier to each execution function of the target page script to obtain a rewritten page script;
a page script running module 302, configured to run the rewritten page script in a preset browser, and capture an exception thrown by the rewritten page script in a running process;
a call path determining module 303, configured to determine, according to the stack trace identifier, a function call path of the rewritten page script when the exception is thrown;
a position determining module 304, configured to determine, according to the function call path, a first position of an exception code in the rewritten page script;
and a code mapping module 305, configured to perform code mapping according to the first position to obtain a second position of the abnormal code in the target page script.
In a specific implementation manner of the embodiment of the present invention, the call path determining module may specifically include:
the function sorting unit is used for determining the sorting of each execution function from the stack top to the stack bottom in a preset stack when the exception is thrown according to the stack tracking identifier;
a function call path determining unit, configured to determine the function call path according to the order of each execution function in the stack; and calling the execution functions ordered at the N-1 th bit by the execution functions ordered at the N-th bit, wherein N is more than 1 and less than or equal to N, and N is the number of the execution functions.
In a specific implementation manner of the embodiment of the present invention, the code mapping module may specifically include:
a code mapping file obtaining unit, configured to obtain a code mapping file corresponding to the target page script from a preset database, where the code mapping file is a file that records a position corresponding relationship between the target page script and each code in the rewritten page script;
the query unit is used for querying a target position through the code mapping file, wherein the target position is a position corresponding to the first position in the target page script;
and the position determining unit is used for determining the target position as a second position of the abnormal code in the target page script.
In a specific implementation manner of the embodiment of the present invention, the page script execution module may specifically include:
a data source indicator reading unit, configured to read a preset data source indicator from a script configuration file corresponding to the target page script; wherein the data source indicator is used for indicating a data source of the debugging data;
a debug data acquisition unit for acquiring target debug data; the target debugging data is debugging data stored in a data source corresponding to the data source indicator;
and the page script running unit is used for running the rewriting page script in the browser based on the target debugging data.
In a specific implementation manner of the embodiment of the present invention, the debug data obtaining unit may be specifically configured to: if the data source indicator is a preset first value, reading a local storage address from the script configuration file, and taking debugging data read from the local storage address as the target debugging data; and if the data source indicator is a preset second value, reading a remote storage address from the script configuration file, and taking the debugging data read from the remote storage address as the target debugging data.
In a specific implementation manner of the embodiment of the present invention, the page script execution module may further include a data source indicator setting unit. The data source indicator setting unit may be specifically configured to: detecting a data transmission rate between the data transmission device and a preset remote data source; if the data transmission rate is smaller than a preset rate threshold, setting the data source indicator as the first value; and if the data transmission rate is greater than or equal to the rate threshold, setting the data source indicator to the second value.
In a specific implementation manner of the embodiment of the present invention, the page script obtaining module may specifically include:
the page script debugging instruction receiving unit is used for receiving a page script debugging instruction sent by the terminal equipment and extracting a page script identifier in the page script debugging instruction;
the script searching unit is used for searching a script corresponding to the page script identification in a preset script library;
and the target page script determining unit is used for determining the script corresponding to the page script identifier as the target page script.
It can be clearly understood by those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described apparatuses, modules and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Fig. 4 shows a schematic block diagram of a server provided by an embodiment of the present invention, and for convenience of explanation, only the parts related to the embodiment of the present invention are shown.
In this embodiment, the server 4 may include: a processor 40, a memory 41, and computer readable instructions 42 stored in the memory 41 and executable on the processor 40, such as computer readable instructions to perform the page script debugging method described above. The processor 40, when executing the computer readable instructions 42, implements the steps in the various page script debugging method embodiments described above, such as steps S101-S105 shown in fig. 1. Alternatively, the processor 40, when executing the computer readable instructions 42, implements the functions of the modules/units in the above device embodiments, such as the functions of the modules 301 to 305 shown in fig. 3.
Illustratively, the computer readable instructions 42 may be partitioned into one or more modules/units that are stored in the memory 41 and executed by the processor 40 to implement the present invention. The one or more modules/units may be a series of computer-readable instruction segments capable of performing certain functions, which are used to describe the execution of the computer-readable instructions 42 in the server 4.
Those skilled in the art will appreciate that fig. 4 is merely an example of a server 4 and does not constitute a limitation of server 4 and may include more or fewer components than shown, or some components in combination, or different components, e.g., server 4 may also include input output devices, network access devices, buses, etc.
The Processor 40 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 41 may be an internal storage unit of the server 4, such as a hard disk or a memory of the server 4. The memory 41 may also be an external storage device of the server 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the server 4. Further, the memory 41 may also include both an internal storage unit of the server 4 and an external storage device. The memory 41 is used to store the computer readable instructions and other instructions and data required by the server 4. The memory 41 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/server and method may be implemented in other ways. For example, the above-described apparatus/server embodiments are merely illustrative, and for example, the division of the modules or units is only one logical division, and there may be other divisions when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method of the embodiments described above can be realized by a computer program, which can be stored in a computer-readable storage medium and can realize the steps of the embodiments of the methods described above when the computer program is executed by a processor. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable storage medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable storage medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable storage media that does not include electrical carrier signals and telecommunications signals in accordance with legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A page script debugging method is characterized by comprising the following steps:
acquiring a target page script to be debugged, and adding a preset stack tracking identifier in each execution function of the target page script to obtain a rewritten page script;
running the rewriting page script in a preset browser, and capturing the exception thrown by the rewriting page script in the running process;
determining a function call path of the rewritten page script when the exception is thrown according to the stack trace identifier;
determining a first position of an abnormal code in the rewriting page script according to the function calling path;
and mapping codes according to the first position to obtain a second position of the abnormal code in the target page script.
2. The method for debugging page scripts according to claim 1, wherein said determining the function call path of the rewritten page script at the time of the exception throwing according to the stack trace identifier comprises:
determining the sequence of each execution function from the stack top to the stack bottom in a preset stack when the exception is thrown according to the stack tracking identifier;
determining the function call path according to the sequence of each execution function in the stack; and calling the execution functions ordered at the N-1 th bit by the execution functions ordered at the N-th bit, wherein N is more than 1 and less than or equal to N, and N is the number of the execution functions.
3. The method for debugging page scripts according to claim 1, wherein said performing code mapping according to the first location to obtain a second location of the exception code in the target page script comprises:
acquiring a code mapping file corresponding to the target page script from a preset database, wherein the code mapping file is a file for recording the position corresponding relation between the target page script and each code in the rewritten page script;
querying a target position through the code mapping file, wherein the target position is a position corresponding to the first position in the target page script;
and determining the target position as a second position of the abnormal code in the target page script.
4. The page script debugging method of claim 1, wherein said running the rewritten page script in a preset browser comprises:
reading a preset data source indicator from a script configuration file corresponding to the target page script; wherein the data source indicator is used for indicating a data source of the debugging data;
acquiring target debugging data; the target debugging data is debugging data stored in a data source corresponding to the data source indicator;
and running the rewriting page script in the browser based on the target debugging data.
5. The page script debugging method of claim 4, wherein said obtaining target debugging data comprises:
if the data source indicator is a preset first value, reading a local storage address from the script configuration file, and taking debugging data read from the local storage address as the target debugging data;
and if the data source indicator is a preset second value, reading a remote storage address from the script configuration file, and taking the debugging data read from the remote storage address as the target debugging data.
6. The page script debugging method of claim 5, wherein said data source indicator setting process comprises:
detecting a data transmission rate between the data transmission device and a preset remote data source;
if the data transmission rate is smaller than a preset rate threshold, setting the data source indicator as the first value;
and if the data transmission rate is greater than or equal to the rate threshold, setting the data source indicator to the second value.
7. The page script debugging method according to any one of claims 1 to 6, wherein said obtaining a target page script to be debugged comprises:
receiving a page script debugging instruction sent by terminal equipment, and extracting a page script identifier in the page script debugging instruction;
searching a script corresponding to the page script identification in a preset script library;
and determining the script corresponding to the page script identifier as the target page script.
8. A page script debugging apparatus, comprising:
the page script acquisition module is used for acquiring a target page script to be debugged and adding a preset stack tracking identifier in each execution function of the target page script to obtain a rewritten page script;
the page script running module is used for running the rewriting page script in a preset browser and capturing the exception thrown out by the rewriting page script in the running process;
a calling path determining module, configured to determine, according to the stack trace identifier, a function calling path of the rewritten page script when the exception is thrown;
the position determining module is used for determining a first position of an abnormal code in the rewriting page script according to the function calling path;
and the code mapping module is used for carrying out code mapping according to the first position to obtain a second position of the abnormal code in the target page script.
9. A computer readable storage medium storing computer readable instructions, which when executed by a processor implement the steps of the page script debugging method of any one of claims 1 to 7.
10. A server comprising a memory, a processor and computer readable instructions stored in the memory and executable on the processor, wherein the processor when executing the computer readable instructions implements the steps of the page script debugging method of any one of claims 1 to 7.
CN202111549120.3A 2021-12-17 2021-12-17 Page script debugging method and device, computer readable storage medium and server Pending CN114185803A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111549120.3A CN114185803A (en) 2021-12-17 2021-12-17 Page script debugging method and device, computer readable storage medium and server

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111549120.3A CN114185803A (en) 2021-12-17 2021-12-17 Page script debugging method and device, computer readable storage medium and server

Publications (1)

Publication Number Publication Date
CN114185803A true CN114185803A (en) 2022-03-15

Family

ID=80544254

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111549120.3A Pending CN114185803A (en) 2021-12-17 2021-12-17 Page script debugging method and device, computer readable storage medium and server

Country Status (1)

Country Link
CN (1) CN114185803A (en)

Similar Documents

Publication Publication Date Title
US11494181B2 (en) Automating generation of library suggestion engine models
CN110704304B (en) Application program testing method and device, storage medium and server
CN114116496A (en) Automatic testing method, device, equipment and medium
CN110851756A (en) Page loading method and device, computer readable storage medium and terminal equipment
CN104182548A (en) Webpage updating and processing method and device
CN112948233A (en) Interface testing method, device, terminal equipment and medium
CN112559088A (en) Configuration file optimization method, device, server and storage medium
CN111090593A (en) Method, device, electronic equipment and storage medium for determining crash attribution
CN112671878B (en) Block chain information subscription method, device, server and storage medium
CN110580220A (en) method for measuring execution time of code segment and terminal equipment
CN117033249A (en) Test case generation method and device, computer equipment and storage medium
CN109902001B (en) Method for detecting uninitialized variable and terminal equipment
CN109189671B (en) Layer-by-layer approximation type variable positioning method and system and terminal equipment
CN109324838B (en) Execution method and execution device of single chip microcomputer program and terminal
CN114185803A (en) Page script debugging method and device, computer readable storage medium and server
CN110209572A (en) Ui testing method, ui testing system and terminal
CN115309661A (en) Application testing method and device, electronic equipment and readable storage medium
CN112003837B (en) Intelligent equipment adaptation method and device based on Modbus protocol and storage medium
CN114727100A (en) Joint debugging method and device for monitoring equipment
CN113806231A (en) Code coverage rate analysis method, device, equipment and medium
CN107506299B (en) Code analysis method and terminal equipment
CN111274143A (en) Buried point testing method, device, equipment and storage medium
CN111475505A (en) Data acquisition method and equipment
CN115840682B (en) Operation and maintenance monitoring method and device for BIOS (basic input output system) level sampling based on SW64 instruction set
CN113656044B (en) Android installation package compression method and device, computer equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination