CN111176986A - Thread script debugging method and device, computer equipment and storage medium - Google Patents

Thread script debugging method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN111176986A
CN111176986A CN201911292192.7A CN201911292192A CN111176986A CN 111176986 A CN111176986 A CN 111176986A CN 201911292192 A CN201911292192 A CN 201911292192A CN 111176986 A CN111176986 A CN 111176986A
Authority
CN
China
Prior art keywords
thread
debugging
breakpoint
position information
waiting state
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.)
Granted
Application number
CN201911292192.7A
Other languages
Chinese (zh)
Other versions
CN111176986B (en
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.)
Kingdee Software China Co Ltd
Original Assignee
Kingdee Software China Co 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 Kingdee Software China Co Ltd filed Critical Kingdee Software China Co Ltd
Priority to CN201911292192.7A priority Critical patent/CN111176986B/en
Publication of CN111176986A publication Critical patent/CN111176986A/en
Application granted granted Critical
Publication of CN111176986B publication Critical patent/CN111176986B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/4401Bootstrapping
    • G06F9/4418Suspend and resume; Hibernate and awake

Landscapes

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

Abstract

The application relates to a thread script debugging method and device, computer equipment and a storage medium. The method comprises the following steps: when a service operation request is received, acquiring a debugging identifier corresponding to the service operation request; acquiring a corresponding first thread lock through the first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state; when the second debugging thread transmits a starting command, the first debugging thread is awakened from a waiting state, a first thread lock corresponding to the first debugging thread is released, and the service script code is executed through the first debugging thread; and when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, wherein the breakpoint position information is set through the second debugging thread. By adopting the scheme, the safety of thread script debugging can be improved.

Description

Thread script debugging method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of debugging technologies, and in particular, to a thread script debugging method and apparatus, a computer device, and a storage medium.
Background
The development of the code can be carried out in a distributed environment, whether the developed code has errors or not can be checked through thread debugging.
However, in the conventional thread debugging method, a debugging client debugs a thread script by interrupting an interpretation executor through a script engine; in the debugging process, a plurality of service requests exist, namely, the debugging period comprises a plurality of requests, so that the debugging of the thread script is interfered by the mixed thread environment in the debugging process, and the debugging safety of the thread script is reduced.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a thread script debugging method, device, computer device, and storage medium capable of improving the security of thread script debugging.
A method of thread script debugging, the method comprising:
when a service operation request is received, acquiring a debugging identifier corresponding to the service operation request;
acquiring a corresponding first thread lock through a first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state;
when a second debugging thread transmits a start command, awakening the first debugging thread from the waiting state, releasing a first thread lock corresponding to the first debugging thread, and
executing a service script code through the first debugging thread;
and when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, wherein the breakpoint position information is set through the second debugging thread.
In one embodiment, the breakpoint location information is stored in a memory, which includes at least one breakpoint location information.
In one embodiment, the breakpoint location information is stored in a memory, which includes at least one breakpoint location information.
In one embodiment, before said waking up said first debugging thread from said waiting state when said second debugging thread delivers a start command, said method further comprises:
acquiring a corresponding second thread lock according to the debugging identifier through the second debugging thread so as to enable the second debugging thread to enter a waiting state;
and when the second debugging thread receives a starting command, awakening the second debugging thread from the waiting state and releasing a second thread lock corresponding to the second debugging thread.
In one embodiment, the execution result is put into a memory by the first debugging thread, and after the execution result is obtained when the execution reaches the code position corresponding to the breakpoint position information, the method further includes:
and sending the execution result to a terminal interface for rendering display through the second debugging thread.
In one embodiment, after the sending the execution result to a terminal interface for rendering and displaying through the second debugging thread, the method further includes:
acquiring a breakpoint adding instruction, wherein the breakpoint adding instruction carries breakpoint position information to be added;
and executing the breakpoint adding instruction, and storing the breakpoint position information to be added in the memory.
In one embodiment, the method further comprises:
receiving an ending instruction;
and executing closing operation on the first debugging thread and the second debugging thread according to the ending instruction.
A thread script debugging apparatus, the apparatus comprising:
the first acquisition module is used for acquiring a debugging identifier corresponding to a service operation request when the service operation request is received;
the second obtaining module is used for obtaining a corresponding first thread lock through the first debugging thread according to the debugging identification so as to enable the first debugging thread to enter a waiting state;
the releasing module is used for awakening the first debugging thread from the waiting state and releasing a first thread lock corresponding to the first debugging thread and the first debugging thread to execute the service script code when a second debugging thread transmits a starting command;
and the execution module is used for obtaining an execution result when the code position corresponding to the breakpoint position information is executed, wherein the breakpoint position information is set through the second debugging thread.
In one embodiment, the apparatus further comprises:
the instruction adding module is used for acquiring a breakpoint adding instruction, and the breakpoint adding instruction carries breakpoint position information to be added; and executing the breakpoint adding instruction, and storing the breakpoint position information to be added in the memory.
A computer device comprising a memory and a processor, the memory storing a computer program, the processor implementing the following steps when executing the computer program:
when a service operation request is received, acquiring a debugging identifier corresponding to the service operation request;
acquiring a corresponding first thread lock through a first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state;
when a second debugging thread transmits a start command, awakening the first debugging thread from the waiting state, releasing a first thread lock corresponding to the first debugging thread, and
executing a service script code through the first debugging thread;
and when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, wherein the breakpoint position information is set through the second debugging thread.
A computer-readable storage medium, on which a computer program is stored which, when executed by a processor, carries out the steps of:
when a service operation request is received, acquiring a debugging identifier corresponding to the service operation request;
acquiring a corresponding first thread lock through a first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state;
when a second debugging thread transmits a start command, awakening the first debugging thread from the waiting state, releasing a first thread lock corresponding to the first debugging thread, and
executing a service script code through the first debugging thread;
and when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, wherein the breakpoint position information is set through the second debugging thread.
According to the thread script debugging method, the thread script debugging device, the computer equipment and the storage medium, when a service operation request is received, a debugging identifier corresponding to the service operation request is obtained; acquiring a corresponding first thread lock through the first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state; when the second debugging thread transmits a starting command, the first debugging thread is awakened from a waiting state, a first thread lock corresponding to the first debugging thread is released, and the service script code is executed through the first debugging thread; and when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, wherein the breakpoint position information is set through the second debugging thread. The first debugging thread enters a waiting state only after the first thread lock corresponding to the debugging identification is obtained, the corresponding relation exists between the debugging identification and the first thread lock, the first debugging line executes the service script code after being awakened through the second debugging thread, namely, an execution result is obtained when a code position corresponding to the breakpoint position information is executed through the coordination interaction between the first debugging line and the second debugging line, the script debugging is completed, the interference of other service requests on corresponding threads is avoided, and the safety between the debugging of the thread script is improved.
Drawings
FIG. 1 is a diagram of an application environment for a method for debugging a thread script in one embodiment;
FIG. 2 is a flowchart illustrating a method for debugging a thread script according to an embodiment;
FIG. 3 is a functional block diagram of thread script debugging in one embodiment;
FIG. 4 is a flowchart illustrating a thread script debugging method according to another embodiment;
FIG. 5 is a block diagram showing the construction of a thread script debugging apparatus according to one embodiment;
FIG. 6 is a block diagram showing the construction of a thread script debugging apparatus in another embodiment;
FIG. 7 is a diagram illustrating an internal structure of a computer device according to an embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The thread script debugging method provided by the application can be applied to the application environment shown in FIG. 1. Wherein the terminal 102 communicates with the server 104 via a network. When receiving a service operation request from the terminal 102, the server 104 acquires a debugging identifier corresponding to the service operation request; acquiring a corresponding first thread lock through a first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state; when a second debugging thread transmits a starting command, awakening the first debugging thread from the waiting state, releasing a first thread lock corresponding to the first debugging thread, and executing a service script code through the first debugging thread; and when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, wherein the breakpoint position information is set through the second debugging thread. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, and tablet computers, and the server 104 may be implemented by an independent server or a server cluster formed by a plurality of servers.
It will be understood that the terms "first," "second," and the like as used herein may be used herein to describe various debugging threads, but these debugging threads are not limited by these terms. These terms are only used to distinguish a first debug thread from another debug thread. For example, a first debugging thread may be referred to as a second debugging thread, and similarly, a second debugging thread may be referred to as a first debugging thread, without departing from the scope of the present application. The first and second debug threads are both debug threads, but are not the same debug thread.
In one embodiment, as shown in fig. 2, a thread script debugging method is provided, which is described by taking the method as an example applied to the server 104 in fig. 1, and includes the following steps:
step 202, when receiving the service operation request, obtaining a debugging identifier corresponding to the service operation request.
The service operation request is a request for obtaining service data, and the service operation request may be a test request. For example, a data table is created in the server, and to test the accuracy of the data stored in the new data table, the terminal sends a test request for testing the accuracy of the data to the server. The terminal can simultaneously initiate a plurality of service operation requests to the server, the debugging identification corresponding to each service operation request is different, in the process of one service operation, each service operation request has at least one request, and the debugging identification corresponding to each request is the same.
The debugging identification is used for identifying the request thread corresponding to the service operation request, different operation requests can correspond to different request threads, the corresponding relation exists between the debugging identification and the request thread, and the debugging identification is used for identifying the request thread corresponding to the current service operation request. For example, the debugging mark may be a string of numbers or letters, a character string of numbers and letters, and the like. For example, when the server receives the service operation request a, the server acquires the debug identifier 1 of the request Thread 1 corresponding to the service operation request a (ThreadA), where the debug identifier 1 is "Thread a id ═ 123456". The form of the debug flag is not limited herein.
Specifically, in a debug mode (debug) is started, when a server receives a service operation request sent by a terminal and response information corresponding to the service operation request is preset response information, a request thread corresponding to the received service operation request is generated or called, a debug identifier of the request thread corresponding to the service operation request is obtained, and the service operation request is accessed to the corresponding debug thread through the request thread. The response information is a processing result obtained after the server processes the service operation request of the receiving terminal; the server can process the service operation request of the terminal through a response protocol; the received response message may be in the form of a binary value, for example, the returned response message may be 0000 or 0001.
And step 204, acquiring a corresponding first thread lock by the first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state.
Wherein the thread lock is the authority of the thread to access the shared resource. For example, ten threads access the same database, the database has a corresponding thread lock, one of the threads can access the database after acquiring the thread lock, and the other nine threads can access the database only after acquiring the thread lock and releasing the lock by the thread having the thread lock.
The debug thread is a processing unit that sequentially processes debug tasks according to a received debug instruction in a debug (debug) mode selected by the container. For example, when receiving a test instruction of whether the database is successfully connected, the terminal executes a corresponding test code, which includes detecting whether the connected database name is a target database name, whether the obtained login password is a preset login password, and the like. The container start needs to start a corresponding process, and one process may include multiple debugging threads, for example, in a debug mode, the debugging threads may include a first debugging thread and a second debugging thread, the first debugging thread may be used to acquire data in a script file, and the second debugging thread may be used to execute a corresponding thread script, where the first debugging thread and the second debugging thread are not specifically limited. The container (Docker) is an open-source application engine container engine, developed applications and dependency packages can be published to a terminal after being distributed to a portable storage image (registry) place, and a debug mode and a non-debug mode can be selected in the container under a distributed environment.
Specifically, a debug mode in a container is selected in a development process, a service operation request is accessed to a corresponding first debugging thread through a request thread, and a debugging identifier corresponding to the service operation request is obtained; and acquiring a corresponding first thread lock through the first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state.
Step 206, when the second debugging thread transmits the start command, the first debugging thread is waken up from the waiting state, the first thread lock corresponding to the first debugging thread is released, and the service script code is executed through the first debugging thread.
The second debugging thread is a debugging thread corresponding to the first debugging thread in a debug mode, and the debugging identification of the first debugging thread is the same as the debugging identification corresponding to the second debugging thread.
Specifically, in a debug mode, when a first debugging thread acquires a corresponding first thread lock according to a debugging identifier so that the first debugging thread enters a waiting state, a debugging request corresponding to a service operation request is triggered, the debugging thread corresponding to the first debugging thread is transmitted to a second debugging thread corresponding to the debugging operation request, when a second debugging thread transmits a start command, the first debugging thread is awakened from the waiting state, the first thread lock corresponding to the first debugging thread is released, and a service script code is executed through the first debugging thread; wherein the start command may be input through the terminal user interface to a start control instruction. For example, the first debugging thread is a thread a, the second debugging thread is a thread B, when the thread a acquires a corresponding first thread lock (lock), the waiting wait state is entered, the thread B acquires a debugging identifier corresponding to the thread a, when the thread B executes an aspect start command, the thread B injects a required callable into the thread a to wake up the thread a from the waiting state, and releases the first thread lock corresponding to the thread a.
And step 208, when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, wherein the breakpoint position information is set through the second debugging thread.
The breakpoint is a tracing point of the program code, and the breakpoint position information is a specific position of the tracing point in the program code. For example, in order to observe the values of variables or expressions on the 10 th and 30 th lines of the code, breakpoints are set on the 10 th and 30 th lines of the code, respectively, i.e., the 10 th and 30 th lines are breakpoint position information. The code of a program can set a plurality of breakpoints, that is, there can be a plurality of breakpoint position information. The breakpoint position information can be added by clicking a breakpoint adding button, double clicking the target breakpoint position for adding, and adding a breakpoint through an ADD instruction. The breakpoint position information can acquire a predication position information setting instruction input by the debugging interface through the second debugging thread.
Specifically, when the second debugging thread transmits a start command, the first debugging thread is awakened from the waiting state, a first thread lock corresponding to the first debugging thread is released, the service script code is executed through the first debugging thread, and the second debugging thread acquires the corresponding thread lock and enters the waiting state; when the first debugging thread executes to the code position corresponding to the breakpoint position information, obtaining an execution result, putting the execution result into a shared cache, enabling the first debugging thread to enter a waiting state, and awakening the second debugging thread; the execution result may be current frame information. For example, the first debugging Thread executes a run () method in a corresponding Thread class, acquires breakpoint position information of a service script code, executes a Thread script according to the breakpoint position information, obtains an execution result, and ends; when a plurality of breakpoint position information exists, the execution instruction, for example stepOver, can be obtained through the second debugging thread, and the next line is continuously executed until the execution of the received breakpoint position information is finished or the termination instruction is received.
In the thread script debugging method, when a service operation request is received, a debugging identifier corresponding to the service operation request is obtained; acquiring a corresponding first thread lock through the first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state; when the second debugging thread transmits a starting command, the first debugging thread is awakened from a waiting state, a first thread lock corresponding to the first debugging thread is released, and the service script code is executed through the first debugging thread; and when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, wherein the breakpoint position information is set through the second debugging thread. The first debugging thread enters a waiting state only after the first thread lock corresponding to the debugging identification is obtained, the corresponding relation exists between the debugging identification and the first thread lock, the first debugging line executes the service script code after being awakened through the second debugging thread, namely, an execution result is obtained when a code position corresponding to the breakpoint position information is executed through the coordination interaction between the first debugging line and the second debugging line, the script debugging is completed, the interference of other service requests on corresponding threads is avoided, and the safety of the thread script debugging is improved.
In one embodiment, the breakpoint location information is stored in a memory that includes at least one breakpoint location information.
The memory may be used for storing programs and data, and may be a buffer memory, a register, or a main memory. By setting the plurality of breakpoint position information, the first debugging thread can listen to the corresponding execution result obtained by the service script code corresponding to each breakpoint position information, and the accuracy of thread debugging is improved.
In one embodiment, the execution result is put into the memory through the first debugging thread, and after the execution result is obtained when the code position corresponding to the breakpoint position information is executed, the method further includes:
and sending the execution result to a terminal interface for rendering display through the second debugging thread.
The execution result may be a value of a function variable in the execution result or an actual value of a function expression in the execution result in the service script code. For example, the variables a-5 and a + b-8.
Specifically, the second debugging thread is awakened, the execution result is read from the shared cache through the interactive interface, and the execution result is sent to the terminal interface for rendering and displaying; the interactive interface is a transmission medium for transmitting data, and the transmitted data may be breakpoint position information, an execution result of a return thread script, a called function method, and the like. The debugging result can be checked by rendering and displaying the execution result, and the accuracy of thread script debugging is improved.
In one embodiment, when a service operation request is received, a debugging identifier corresponding to the service operation request is obtained; acquiring a corresponding first thread lock through the first debugging thread according to the debugging identifier so as to enable the first debugging thread to be suspended and enter a waiting state; when the second debugging thread transmits a starting command, the first debugging thread is awakened from a waiting state, the first debugging thread releases and releases the corresponding first thread lock, and after breakpoint position information is acquired from the memory through the first debugging thread, the service script code is executed; and when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, sending the execution result to a terminal interface for rendering and displaying through a second debugging thread, entering a waiting state by the second debugging thread, and waiting for receiving a next execution command, wherein the execution command can be instructions of resuming execution, executing a next line, tracing a function, appointing execution to an nth line, setting a breakpoint, viewing an expression, stopping and the like.
In one embodiment, after the execution result is sent to the terminal interface for rendering and displaying through the second debugging thread, the method further includes:
acquiring a breakpoint adding instruction, wherein the breakpoint adding instruction carries breakpoint position information to be added; and executing a breakpoint adding instruction, and storing breakpoint position information to be added in a memory.
Specifically, the breakpoint adding instruction is used for inputting a breakpoint position information adding instruction through a debugging interactive interface. When a breakpoint adding instruction input by a debugging interface is acquired, the breakpoint adding instruction is executed, added breakpoint position information is stored in a memory, and the breakpoint position information is added through the breakpoint adding instruction, so that debugging can be performed on abnormal errors occurring in the debugging process, and the thread debugging efficiency is improved.
In one embodiment, as shown in FIG. 3, a thread script debugging functional block diagram is provided, which comprises a business operation request 302, a requesting thread 304, a first debugging thread 306, a cache 308, a second debugging thread 310, a debugging requesting thread 312, and a debugging command request 314.
After the server request thread 304 receives the service operation request 302, acquiring a corresponding debugging identifier; accessing the service operation request 302 into the first debugging thread 306, acquiring a first thread lock corresponding to the debugging identifier by the first debugging thread 306, and enabling the first debugging thread 306 to enter a waiting state; after receiving the service operation request 302, triggering a debugging request thread 312 of a debugging command request 314 corresponding to the service operation request 302, transmitting a debugging identifier corresponding to the request thread 304 to the debugging request thread 312, when a second debugging thread 310 transmits a start command, waking up the first debugging thread 306 from a waiting state, releasing a first thread lock corresponding to the first debugging thread 306, reading debugging breakpoint position information from a cache 308 by the first debugging thread 306, executing a service script code through the first debugging thread 306, and when executing a code position corresponding to the breakpoint position information, obtaining an execution result; and sending the execution result to a terminal interface for rendering and displaying through a second debugging thread, wherein the request thread 304 can receive at least one service request operation at the same time, and the debugging request thread 312 can receive at least one debugging request operation at the same time. Through the coordination interaction between the first debugging thread 306 and the second debugging thread 308, the script debugging is completed, the interference of threads corresponding to other service operation requests is avoided, and the isolation and the safety of the thread script debugging are improved.
In another embodiment, as shown in fig. 4, a thread script debugging method is provided, which is described by taking the method as an example applied to the terminal 102 in fig. 1, and includes the following steps:
step 402, when a service operation request is received, a debugging identifier corresponding to the service operation request is obtained.
Step 404, the first debugging thread acquires a corresponding first thread lock according to the debugging identifier, so that the first debugging thread enters a waiting state.
And 406, acquiring a corresponding second thread lock according to the debugging identifier by the second debugging thread, so that the second debugging thread enters a waiting state.
Step 408, when the second debugging thread receives the start command, the second debugging thread is waken up from the waiting state, and the second thread lock corresponding to the second debugging thread is released.
Step 410, when the second debugging thread transmits the start command, the first debugging thread is waken up from the waiting state, the first thread lock corresponding to the first debugging thread is released, and the service script code is executed through the first debugging thread.
And step 412, when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, where the breakpoint position information is set by the second debugging thread.
In the thread script debugging method, when a service operation request is received, a debugging identifier corresponding to the service operation request is obtained; acquiring a corresponding first thread lock through the first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state; when the second debugging thread transmits a starting command, the first debugging thread is awakened from a waiting state, a first thread lock corresponding to the first debugging thread is released, and the service script code is executed through the first debugging thread; and when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, wherein the breakpoint position information is set through the second debugging thread. The first debugging thread enters a waiting state only after acquiring a first thread lock corresponding to the debugging identifier, and the debugging identifier and the first thread lock have a corresponding relation, the first debugging thread executes the service script code after being awakened by a second debugging thread, namely, an execution result is obtained when a code position corresponding to the breakpoint position information is executed through the coordination interaction between the first debugging thread and the second debugging thread, and the script debugging is completed; breakpoint position information is transmitted between the second debugging thread and the first debugging thread through the interactive interface, the breakpoint position information does not need to be transmitted through a port, interference of other threads is avoided, and isolation and safety of thread script debugging are improved.
In one embodiment, the method further comprises:
receiving an ending instruction; and executing closing operation on the first debugging thread and the second debugging thread according to the ending instruction.
And the ending instruction is used for ending the thread debugging. For example, the end instruction may be a stop instruction.
Specifically, after a second debugging thread ending instruction is transmitted to the first debugging thread, breakpoint position information stored in the cache is removed; the first debugging thread shields breakpoint position information, the service script codes are executed to obtain an execution result, the execution result is sent to a terminal interface through the second debugging thread to be rendered and displayed, the first debugging thread and the second debugging thread are closed, interference of other threads is avoided, and accuracy of the execution result is influenced.
In one embodiment, the first Debug Thread is Main-Debug-Thread and the second Debug Thread is CMD-Debug-Thread. In a debugging mode, when a request service thread of a server receives a service operation request, a debugging identifier corresponding to the service operation request is obtained; accessing a business operation request into a Thread Main-Debug-Thread through a request service Thread, acquiring a corresponding first Thread lock by the Thread Main-Debug-Thread according to a debugging identifier corresponding to the business operation request, and entering a waiting state; when a request service Thread of the server receives a debugging operation request corresponding to the service operation request, accessing the debugging operation request to a Thread CMD-Debug-Thread through the request service Thread, acquiring a debugging identifier corresponding to the service operation request and a second Thread lock corresponding to the debugging identifier by the CMD-Debug-Thread, and entering a waiting state; when the CMD-Debug-Thread executes the starting operation, the CMD-Debug-Thread enters an awakening state from the waiting state, awakens the Main-Debug-Thread from the waiting state, releases a first Thread lock corresponding to the Main-Debug-Thread, starts to execute the service script codes, obtains an execution result when the Main-Debug-Thread executes to a code position corresponding to the breakpoint position information, and puts the execution result into a cache; and the Main-Debug-Thread enters a waiting state from the awakening state, and the CMD-Debug-Thread acquires an execution result from the cache and sends the execution result to a terminal interface for rendering and displaying.
It should be understood that although the various steps in the flow charts of fig. 2-4 are shown in order as indicated by the arrows, the steps are not necessarily performed in order as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least some of the steps in fig. 2-4 may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternating with other steps or at least some of the sub-steps or stages of other steps.
In one embodiment, as shown in fig. 5, there is provided a thread script debugging apparatus 500, comprising: a first obtaining module 502, a second obtaining module 504, a lock releasing module 506, and an executing module 508, wherein:
the first obtaining module 502 is configured to obtain, when a service operation request is received, a debugging identifier corresponding to the service operation request.
The second obtaining module 504 is configured to obtain, by the first debugging thread according to the debugging identifier, the corresponding first thread lock, so that the first debugging thread enters a waiting state.
In one embodiment, the second obtaining module 504 is further configured to obtain, by the second debugging thread, a corresponding second thread lock according to the debugging identifier, so that the second debugging thread enters a waiting state.
A releasing module 506, configured to wake up the first debugging thread from the waiting state when the second debugging thread transmits the start command, release the first thread lock corresponding to the first debugging thread, and enable the first debugging thread to execute the service script code.
In one embodiment, the releasing module 506 is further configured to wake up the second debugging thread from the waiting state and release the second thread lock corresponding to the second debugging thread when the second debugging thread receives the start command.
And the executing module 508 is configured to obtain an execution result when the code position corresponding to the breakpoint position information is executed, where the breakpoint position information is set by the second debugging thread.
In the thread script debugging device, when a service operation request is received, a debugging identifier corresponding to the service operation request is obtained; acquiring a corresponding first thread lock through the first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state; when the second debugging thread transmits a starting command, the first debugging thread is awakened from a waiting state, a first thread lock corresponding to the first debugging thread is released, and the service script code is executed through the first debugging thread; and when the code position corresponding to the breakpoint position information is executed, obtaining an execution result. The breakpoint position information is set through a second debugging thread, the first debugging thread enters a waiting state only after a first thread lock corresponding to the debugging identification is obtained, a corresponding relation exists between the debugging identification and the first thread lock, the first debugging thread executes the service script code after being awakened through the second debugging thread, namely, an execution result is obtained when a code position corresponding to the breakpoint position information is executed through the coordination interaction between the first debugging thread and the second debugging thread, the script debugging is completed, the interference of threads corresponding to other service requests is avoided, and the interaction between the threads does not need to expose a debugging port; the isolation and the safety of the thread script debugging are improved.
In another embodiment, as shown in fig. 6, a thread script debugging apparatus 500 is provided, which includes, in addition to a first obtaining module 502, a second obtaining module 504, a lock releasing module 506 and an executing module 508: an instruction adding module 510, a rendering module 512, and a receiving module 514, wherein:
an instruction adding module 510, configured to obtain a breakpoint adding instruction, where the breakpoint adding instruction carries breakpoint position information to be added; and executing a breakpoint adding instruction, and storing breakpoint position information to be added in a memory.
Specifically, errors occurring in the debugging process add corresponding breakpoints through breakpoint adding instructions, timely process the errors according to newly added breakpoint position information, and improve the thread debugging efficiency.
And the rendering module 512 is configured to send the execution result to the terminal interface through the second debugging thread for rendering and displaying.
A receiving module 514, configured to receive an end instruction; and executing closing operation on the first debugging thread and the second debugging thread according to the ending instruction.
For the specific definition of the thread script debugging device, reference may be made to the above definition of the thread script debugging method, which is not described herein again. The modules in the thread script debugging device can be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 7. The computer device includes a processor, a memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a method of thread script debugging. The display screen of the computer equipment can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the architecture shown in fig. 7 is merely a block diagram of some of the structures associated with the disclosed aspects and is not intended to limit the computing devices to which the disclosed aspects apply, as particular computing devices may include more or less components than those shown, or may combine certain components, or have a different arrangement of components.
In one embodiment, a computer device is provided, comprising a memory and a processor, the memory having a computer program stored therein, the processor implementing the following steps when executing the computer program:
when a service operation request is received, acquiring a debugging identifier corresponding to the service operation request;
acquiring a corresponding first thread lock through the first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state;
when the second debugging thread transmits a start command, the first debugging thread is waken up from a waiting state, and a first thread lock corresponding to the first debugging thread is released, an
Executing the service script code through the first debugging thread;
and when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, wherein the breakpoint position information is set through the second debugging thread.
In one embodiment, the processor, when executing the computer program, further implements the following:
the breakpoint position information is stored in a memory, which includes at least one breakpoint position information.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
before waking up the first debugging thread from a wait state when the second debugging thread passes the start command, the method further comprises:
acquiring a corresponding second thread lock according to the debugging identifier through a second debugging thread so as to enable the second debugging thread to enter a waiting state;
and when the second debugging thread receives the starting command, the second debugging thread is awakened from the waiting state, and a second thread lock corresponding to the second debugging thread is released.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
the execution result is put into the memory through the first debugging thread, and after the execution result is obtained when the code position corresponding to the breakpoint position information is executed, the method further comprises the following steps:
and sending the execution result to a terminal interface for rendering display through the second debugging thread.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
after the execution result is sent to the terminal interface for rendering display through the second debugging thread, the method further comprises the following steps:
acquiring a breakpoint adding instruction, wherein the breakpoint adding instruction carries breakpoint position information to be added;
and executing a breakpoint adding instruction, and storing breakpoint position information to be added in a memory.
In one embodiment, the processor, when executing the computer program, further performs the steps of:
receiving an ending instruction;
and executing closing operation on the first debugging thread and the second debugging thread according to the ending instruction.
In one embodiment, a computer-readable storage medium is provided, having a computer program stored thereon, which when executed by a processor, performs the steps of:
when a service operation request is received, acquiring a debugging identifier corresponding to the service operation request;
acquiring a corresponding first thread lock through the first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state;
when the second debugging thread transmits a start command, the first debugging thread is waken up from a waiting state, and a first thread lock corresponding to the first debugging thread is released, an
Executing the service script code through the first debugging thread;
and when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, wherein the breakpoint position information is set through the second debugging thread.
In one embodiment, the computer program when executed by the processor further implements the following:
the breakpoint position information is stored in a memory, which includes at least one breakpoint position information.
In one embodiment, the computer program when executed by the processor further performs the steps of:
before waking up the first debugging thread from a wait state when the second debugging thread passes the start command, the method further comprises:
acquiring a corresponding second thread lock according to the debugging identifier through a second debugging thread so as to enable the second debugging thread to enter a waiting state;
and when the second debugging thread receives the starting command, the second debugging thread is awakened from the waiting state, and a second thread lock corresponding to the second debugging thread is released.
In one embodiment, the computer program when executed by the processor further performs the steps of:
the execution result is put into the memory through the first debugging thread, and after the execution result is obtained when the code position corresponding to the breakpoint position information is executed, the method further comprises the following steps:
and sending the execution result to a terminal interface for rendering display through the second debugging thread.
In one embodiment, the computer program when executed by the processor further performs the steps of:
after the execution result is sent to the terminal interface for rendering display through the second debugging thread, the method further comprises the following steps:
acquiring a breakpoint adding instruction, wherein the breakpoint adding instruction carries breakpoint position information to be added;
and executing a breakpoint adding instruction, and storing breakpoint position information to be added in a memory.
In one embodiment, the computer program when executed by the processor further performs the steps of:
receiving an ending instruction;
and executing closing operation on the first debugging thread and the second debugging thread according to the ending instruction.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (10)

1. A method of thread script debugging, the method comprising:
when a service operation request is received, acquiring a debugging identifier corresponding to the service operation request;
acquiring a corresponding first thread lock through a first debugging thread according to the debugging identifier so as to enable the first debugging thread to enter a waiting state;
when a second debugging thread transmits a start command, awakening the first debugging thread from the waiting state, releasing a first thread lock corresponding to the first debugging thread, and
executing a service script code through the first debugging thread;
and when the code position corresponding to the breakpoint position information is executed, obtaining an execution result, wherein the breakpoint position information is set through the second debugging thread.
2. The method of claim 1, wherein the breakpoint location information is stored in a memory, the memory including at least one breakpoint location information.
3. The method of claim 1, wherein before the waking up the first debugging thread from the wait state when the second debugging thread communicates a start command, the method further comprises:
acquiring a corresponding second thread lock according to the debugging identifier through the second debugging thread so as to enable the second debugging thread to enter a waiting state;
and when the second debugging thread receives a starting command, awakening the second debugging thread from the waiting state and releasing a second thread lock corresponding to the second debugging thread.
4. The method according to claim 1, wherein the execution result is put into a memory by the first debugging thread, and after the execution result is obtained when the execution reaches a code location corresponding to breakpoint location information, the method further comprises:
and sending the execution result to a terminal interface for rendering display through the second debugging thread.
5. The method of claim 4, after the sending the execution result to a terminal interface for rendering and displaying through the second debugging thread, the method further comprising:
acquiring a breakpoint adding instruction, wherein the breakpoint adding instruction carries breakpoint position information to be added;
and executing the breakpoint adding instruction, and storing the breakpoint position information to be added in the memory.
6. The method of claim 1, further comprising:
receiving an ending instruction;
and executing closing operation on the first debugging thread and the second debugging thread according to the ending instruction.
7. A thread script debugging apparatus, comprising:
the first acquisition module is used for acquiring a debugging identifier corresponding to a service operation request when the service operation request is received;
the second obtaining module is used for obtaining a corresponding first thread lock through the first debugging thread according to the debugging identification so as to enable the first debugging thread to enter a waiting state;
the releasing module is used for awakening the first debugging thread from the waiting state and releasing a first thread lock corresponding to the first debugging thread and the first debugging thread to execute the service script code when a second debugging thread transmits a starting command;
and the execution module is used for obtaining an execution result when the code position corresponding to the breakpoint position information is executed, wherein the breakpoint position information is set through the second debugging thread.
8. The apparatus of claim 7, further comprising:
the instruction adding module is used for acquiring a breakpoint adding instruction, and the breakpoint adding instruction carries breakpoint position information to be added; and executing the breakpoint adding instruction, and storing the breakpoint position information to be added in the memory.
9. A computer program, characterized in that the steps of the method of any of claims 1 to 6 are implemented when the computer program is executed by a processor.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 6.
CN201911292192.7A 2019-12-16 2019-12-16 Thread script debugging method and device, computer equipment and storage medium Active CN111176986B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911292192.7A CN111176986B (en) 2019-12-16 2019-12-16 Thread script debugging method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911292192.7A CN111176986B (en) 2019-12-16 2019-12-16 Thread script debugging method and device, computer equipment and storage medium

Publications (2)

Publication Number Publication Date
CN111176986A true CN111176986A (en) 2020-05-19
CN111176986B CN111176986B (en) 2023-12-29

Family

ID=70650227

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911292192.7A Active CN111176986B (en) 2019-12-16 2019-12-16 Thread script debugging method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111176986B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113342654A (en) * 2021-06-08 2021-09-03 广州博冠信息科技有限公司 Script language code debugging method and device, readable storage medium and electronic equipment
EP4027246A4 (en) * 2020-11-16 2022-09-21 Baidu Online Network Technology (Beijing) Co., Ltd. Method and apparatus for debugging applet, electronic device and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20140095932A1 (en) * 2012-09-28 2014-04-03 Stmicroelectronics S. R. I. Debug system, and related integrated circuit and method
US9405658B1 (en) * 2008-05-27 2016-08-02 Oracle America, Inc. Method and apparatus for debugging applications in development environments
CN106254436A (en) * 2016-07-28 2016-12-21 腾讯科技(深圳)有限公司 A kind of method of remote debugging, relevant device and system
CN107948317A (en) * 2017-12-26 2018-04-20 金蝶软件(中国)有限公司 Adjustment method, device, storage medium and the computer equipment of Distributed Services
CN109783342A (en) * 2017-11-10 2019-05-21 华为技术有限公司 Script debugging method, equipment and computer storage medium
CN110032512A (en) * 2019-03-28 2019-07-19 腾讯科技(深圳)有限公司 A kind of adjustment method of small routine, relevant device and terminal

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9405658B1 (en) * 2008-05-27 2016-08-02 Oracle America, Inc. Method and apparatus for debugging applications in development environments
US20140095932A1 (en) * 2012-09-28 2014-04-03 Stmicroelectronics S. R. I. Debug system, and related integrated circuit and method
CN106254436A (en) * 2016-07-28 2016-12-21 腾讯科技(深圳)有限公司 A kind of method of remote debugging, relevant device and system
CN109783342A (en) * 2017-11-10 2019-05-21 华为技术有限公司 Script debugging method, equipment and computer storage medium
CN107948317A (en) * 2017-12-26 2018-04-20 金蝶软件(中国)有限公司 Adjustment method, device, storage medium and the computer equipment of Distributed Services
CN110032512A (en) * 2019-03-28 2019-07-19 腾讯科技(深圳)有限公司 A kind of adjustment method of small routine, relevant device and terminal

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
木泽: "多线程的锁机制", 《知乎》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP4027246A4 (en) * 2020-11-16 2022-09-21 Baidu Online Network Technology (Beijing) Co., Ltd. Method and apparatus for debugging applet, electronic device and storage medium
CN113342654A (en) * 2021-06-08 2021-09-03 广州博冠信息科技有限公司 Script language code debugging method and device, readable storage medium and electronic equipment
CN113342654B (en) * 2021-06-08 2024-04-09 广州博冠信息科技有限公司 Script language code debugging method and device, readable storage medium and electronic equipment

Also Published As

Publication number Publication date
CN111176986B (en) 2023-12-29

Similar Documents

Publication Publication Date Title
CN108920354B (en) Embedded point management method and device, computer equipment and storage medium
US20220050769A1 (en) Program testing method and apparatus, computer device, and storage medium
WO2019169759A1 (en) Apparatus and method for creating analog interface, and computer-readable storage medium
CN108848000B (en) Network request testing method and device, computer equipment and storage medium
WO2016033966A1 (en) Protection method and device for application data
WO2015131804A1 (en) Call stack relationship acquiring method and apparatus
CN110659092A (en) Webpage screenshot method and device, computer equipment and storage medium
CN108418797B (en) Webpage access method and device, computer equipment and storage medium
CN111008132A (en) Application debugging method and device for Android system, computer equipment and storage medium
CN113220566A (en) Interface performance test script generation method and device and computer equipment
CN111176986A (en) Thread script debugging method and device, computer equipment and storage medium
US9176821B2 (en) Watchpoint support system for functional simulator
CN109542962B (en) Data processing method, data processing device, computer equipment and storage medium
CN110866011B (en) Data table synchronization method and device, computer equipment and storage medium
CN104487935A (en) Recording external processes
CN109976683B (en) Data printing method, device, equipment and storage medium
CN110232018A (en) Interface test method, device, computer equipment
KR20150096478A (en) Programmable controller, programmable controller system, and execute error information creation method
CN111371643B (en) Authentication method, device and storage medium
CN112650674A (en) Method for remotely acquiring and debugging webpage log, computer equipment and storage medium
CN112631949B (en) Debugging method and device, computer equipment and storage medium
CN111045891B (en) Monitoring method, device, equipment and storage medium based on java multithreading
CN113971124B (en) Sub-application debugging method and device, computer equipment and storage medium
CN111414525B (en) Method, device, computer equipment and storage medium for acquiring data of applet
CN110704218B (en) Data processing method, data processing 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
GR01 Patent grant
GR01 Patent grant
TG01 Patent term adjustment
TG01 Patent term adjustment