Device debugging method, device and storage medium

By setting breakpoints and hook functions in industrial equipment, the problem of low debugging efficiency in the existing technology is solved, real-time observation and parameter adjustment of multi-threaded debugging are realized, and the debugging efficiency is improved.

CN114489972BActive Publication Date: 2025-07-04QKM TECH (DONG GUAN) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111650812.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-30
Publication Date
2025-07-04
Estimated Expiration
2041-12-30

AI Technical Summary

Technical Problem

The existing industrial equipment tuning methods are inefficient, especially in the case of multi-threading, the tuning personnel cannot know the actual situation in real time, resulting in the inability to adjust the control parameters according to the real-time situation.

Method used

By setting a set of breakpoints and hook functions in industrial equipment, injecting the first breakpoint and first hook functions, multi-threaded debugging is realized and the debugging results are observed in real time.

Benefits of technology

It improves the efficiency of adjustment and measurement, and can observe the actual results of each adjustment in real time, which facilitates the adjustment of precise control parameters by adjusting the measurement personnel.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114489972B_ABST
    Figure CN114489972B_ABST
Patent Text Reader

Abstract

The present application provides a device debugging method, a device and a storage medium, which relate to the technical field of industrial control. The method includes: receiving a start debugging request; determining a plurality of first hook functions corresponding to the first task threads according to the start debugging request and the breakpoint set; injecting a plurality of first breakpoints applied to the corresponding first task threads into the first hook functions according to the breakpoint set; and responding to the debugging of the first hook functions. The device and the storage medium apply the device debugging method. Therefore, by setting the breakpoint set for debugging on the device, the device integrates the functions of debugging and actual operation. Furthermore, when performing debugging, the actual results of each debugging can be observed in real time, which is more convenient for debugging. By injecting the first breakpoints into the first hook functions of multiple first task threads, multi-threaded debugging can be achieved, thereby improving the debugging efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to, but are not limited to, the field of industrial control technology, and in particular, to a method for debugging an apparatus, an apparatus, and a storage medium. Background Art

[0002] In the field of industrial control technology, due to the complexity of automated industrial equipment, debugging is often required during machine production. When industrial equipment enters the formal production environment at the site, users may also control the application programs of industrial equipment, such as pausing, resuming, and single-step execution, according to the needs of the site. For industrial equipment with multi-threaded processing, debugging needs to be accurate to multi-threading. However, the existing debugging often uses a remote control platform to control industrial equipment. Taking a robot as an example, when using a remote platform for debugging, the debugger cannot know the actual situation in real time and thus cannot adjust the control parameters of the robot according to the real-time situation; therefore, the debugging efficiency is low. Summary of the Invention

[0003] The following is an overview of the subject matter described in detail herein. This overview is not intended to limit the scope of protection of the claims.

[0004] The embodiments of the present application provide a method for debugging an apparatus, an apparatus, and a storage medium, which can improve the debugging efficiency.

[0005] In a first aspect, the embodiments of the present application provide a method for debugging an apparatus, which is applied to an electronic device and includes:

[0006] Receiving a debugging start request;

[0007] Determining a plurality of first hook functions corresponding to a first task thread according to the debugging start request and a breakpoint set;

[0008] Injecting a plurality of first breakpoints applied to the corresponding first task thread into the first hook functions according to the breakpoint set;

[0009] Responding to the debugging of the first hook functions.

[0010] In a second aspect, the embodiments of the present application further provide an apparatus, including:

[0011] A receiving module, configured to receive a debugging start request;

[0012] A starting module, configured to determine a plurality of first hook functions corresponding to a first task thread according to the debugging start request and a breakpoint set;

[0013] A breakpoint setting module, configured to inject a plurality of first breakpoints applied to the corresponding first task thread into the first hook functions according to the breakpoint set;

[0014] A debugging module for responding to the debugging of the first hook function.

[0015] In a third aspect, an embodiment of the present application further provides an electronic device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, it performs the device debugging method according to any one of the first aspects.

[0016] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium storing computer-executable instructions for executing the device debugging method according to any one of the first aspects.

[0017] According to the above embodiments of the present application, there are at least the following beneficial effects: By setting the breakpoint set for debugging on the device, the device integrates the functions of debugging and actual operation. Therefore, during debugging, the actual results of each debugging can be observed in real time, which is more convenient for debugging. And by injecting the first breakpoint into the first hook functions of multiple first task threads, multi-threaded debugging can be achieved, thereby improving the debugging efficiency.

[0018] Other features and advantages of the present application will be described in the following specification. And, some of them will become obvious from the specification, or be understood by implementing the present application. The objectives and other advantages of the present application can be achieved and obtained through the structures specifically pointed out in the specification, claims, and drawings. Description of the Drawings

[0019] The drawings are used to provide a further understanding of the technical solutions of the present application, and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solutions of the present application, and do not constitute a limitation to the technical solutions of the present application.

[0020] Figure 1 It is a schematic diagram of the modules of a device proposed by an embodiment of the present application;

[0021] Figure 2 It is a schematic flowchart of a device debugging method proposed by an embodiment of the present application;

[0022] Figure 3 It is a schematic flowchart of performing a preset instruction operation of a device debugging method proposed by an embodiment of the present application;

[0023] Figure 4 It is a schematic diagram of the system structure for thread creation of an embodiment of the present application. Detailed Embodiments

[0024] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0025] It should be noted that although functional module division is performed in the device schematic diagram and the logical sequence is shown in the flowchart, in some cases, the steps shown or described can be executed in a different module division in the device or a different order in the flowchart. Terms such as "first" and "second" in the description, claims and the above-mentioned drawings are used to distinguish similar objects and do not necessarily need to describe a specific order or sequence.

[0026] In the field of industrial control technology, due to the complexity of automated industrial equipment, it is often necessary to perform debugging during machine production. When the industrial equipment enters the formal production environment on-site, the user may also control the application program of the industrial equipment, such as pausing, resuming, and single-step execution, according to the on-site needs. For industrial equipment with multi-threaded processing, debugging needs to be accurate to multi-threads. However, the existing debugging often relies on a remote control platform to control the industrial equipment. Taking a robot as an example, when using a remote platform for debugging, the debugging personnel cannot obtain the actual situation in real time and thus cannot adjust the control parameters of the robot according to the real-time situation; therefore, the debugging efficiency is relatively low. Based on this, the embodiments of the present application provide a debugging method, device and storage medium for equipment, which can improve the debugging efficiency.

[0027] Referring to Figure 1 the illustrated embodiment, the device includes a receiving module 110, a starting module 120, a breakpoint setting module 130, and a debugging module 140. The receiving module 110 is used to receive a debugging start request; the starting module 120 is used to determine a number of first hook functions corresponding to the first task threads according to the debugging start request and the breakpoint set; the breakpoint setting module 130 is used to inject a number of first breakpoints applied to the corresponding first task threads into the first hook functions according to the breakpoint set; the debugging module 140 is used to respond to the debugging of the first hook functions.

[0028] It should be noted that the first hook functions are injected through script functions. The device includes multiple second task threads for executing the operation instructions of the device. The first task thread represents the second task thread into which the first hook function is injected. For each device, the user can inject corresponding hook functions into at least one second task thread according to needs.

[0029] It should be noted that the device can be a machine tool or a robot, which is a device for actually completing an industrial control. Therefore, it is necessary for the debugging personnel to observe the specific operation results in real time and then adjust the control parameters.

[0030] Those skilled in the art can understand that Figure 1 the schematic diagram of the modules shown in Figure 1 does not limit the embodiments of the present application, and may include more or fewer modules than shown, or combine some modules, or have different module arrangements.

[0031] The method of the embodiments of the present application will be further described below with reference to the accompanying drawings.

[0032] Refer to Figure 2 As shown, an embodiment of the present application also provides a debugging method for a device, including:

[0033] Step S100, receiving a start debugging request.

[0034] Step S200, determining a number of first hook functions corresponding to the first task threads according to the start debugging request and the breakpoint set.

[0035] It should be noted that the breakpoint set is preset, and the first task thread refers to the second task thread where the breakpoints in the breakpoint set are set. The second task thread is a thread created by the device under test when executing actual instructions.

[0036] It should be noted that the breakpoint set is shared by all the second task threads of the device under test; thus, when multiple second task threads execute the same function, they can be interrupted, and then terminal debugging of multiple first task threads can be achieved.

[0037] It should be noted that the first hook function, that is, the Hook function, is used to filter all messages, events, etc. in the corresponding first task thread.

[0038] Step S300, injecting a number of first breakpoints applied to the corresponding first task threads into the first hook functions according to the breakpoint set.

[0039] It should be noted that one or more first breakpoints can be set in each first hook function, and then at least one function of the first task thread can be monitored.

[0040] Step S400, responding to the debugging of the first hook function.

[0041] It should be noted that responding to the debugging of the first hook function means starting all the second task threads. At this time, it can be determined whether the expected position is reached through the first breakpoints set in the first hook function, and then the debugging is completed.

[0042] Therefore, by setting a set of breakpoints for debugging on the device, the device integrates the functions of debugging and actual operation. Thus, during debugging, the actual results of each debugging can be observed in real time, which is more convenient for debugging. By injecting the first breakpoints into the first hook functions of multiple first task threads, multi-threaded debugging can be achieved, thereby improving the efficiency of debugging.

[0043] It can be understood that step S200, determining a number of first hook functions corresponding to the first task threads according to the start debugging request and the set of breakpoints, includes: when the set of breakpoints is not empty, performing breakpoint matching between the set of breakpoints and each second task thread in the task thread list to obtain a number of first task threads; starting the first hook functions corresponding to the first task threads according to the start debugging request; and determining a number of first hook functions according to the start result.

[0044] It should be noted that starting the first hook function corresponding to the first task thread means creating the corresponding first hook function when the first task thread does not have a first hook function set. Secondly, in some embodiments, during the non-debugging phase, the first hook function is closed to ensure the normal operation of each second task thread. Therefore, it needs to be reopened.

[0045] It can be understood that the method further includes: receiving a first debugging instruction update request from the user, where the first debugging instruction update request is used to request an update of the conditional breakpoint; and injecting the conditional breakpoint into the corresponding first task thread according to the first debugging instruction update request so that the corresponding first hook function obtains the conditional breakpoint.

[0046] It should be noted that the first debugging instruction update is called through the API of the program, so that new breakpoints can be added to the first thread or other second threads for debugging during the running process.

[0047] It should be noted that the conditional breakpoint is injected into the thread node information of the first task thread, and the first hook function actively obtains the conditional breakpoint information from the node information of the first task thread and suspends the first hook function through the conditional breakpoint.

[0048] It can be understood that step S400, responding to the debugging of the first hook function, includes: obtaining the variable value for conditional breakpoint judgment; when the program variable executed by the first task thread matches the variable value, pausing the first task thread and executing a preset instruction operation, where the instruction operation includes one of the first function functions preset in the conditional breakpoint or an external request.

[0049] It should be noted that the external request is an instruction customarily issued by the user. After the debugging user determines that the first hook function takes effect, the external request will be issued to achieve better debugging.

[0050] It should be noted that the first functional function is a library function in the debugging library applied by the first hook function. If the first hook function is implemented using Lua, the first functional function is a debugging (Debug) instruction in Lua or a functional function obtained by combining multiple debugging instructions.

[0051] It can be understood that, referring to Figure 3 As shown, when the instruction operation is the first functional function preset in the conditional breakpoint; performing the preset instruction operation includes:

[0052] Step S410: Extract the function information of the first functional function from the conditional breakpoint.

[0053] Step S420: Determine the first functional function from the preset function list according to the function information.

[0054] Step S430: Execute the first functional function.

[0055] It should be noted that the first functional function is preset by the user, and is obtained by combining multiple debugging instructions or corresponds to a library function in a debugging library.

[0056] It can be understood that the method further includes: receiving a second debugging instruction update request from the user, and the second debugging instruction update request is used to add the to-be-added second breakpoint to the breakpoint set.

[0057] It should be noted that the implementation of the first hook function is in the application program. At this time, when the script is updated, it does not affect the call of the first hook function. At this time, the device can update the breakpoint set by creating a communication thread to call the script file.

[0058] It should be noted that the debugging of the newly added breakpoint can be restarted the thread or directly dynamically added to the corresponding second task thread.

[0059] It can be understood that the method further includes: determining whether the second hook function is started in the third task thread corresponding to the second breakpoint; according to the determination result, determining whether to start the second hook function and adding the second breakpoint to the started second hook function.

[0060] It should be noted that when the second hook function is not started in the third task thread, the second hook function is started and then the second breakpoint is added to the third task thread. The third task thread is one of the second task threads.

[0061] It should be noted that the second breakpoint is not a conditional breakpoint, but an ordinary breakpoint, which is used to pause the third task thread when the third task thread executes to this breakpoint.

[0062] It is understandable that the method further includes: closing the first hook function of the first task thread, where the first hook function is empty.

[0063] It should be noted that when the breakpoints in the breakpoint set are cleared, it will be synchronously determined whether all the debugging instructions such as the first breakpoint and conditional breakpoints in the corresponding first task thread are cleared. When all are cleared, that is, the first hook function is empty, then the first hook function of the first task thread is closed. At this time, the triggered task threads can be reduced, thereby reducing consumption and improving execution efficiency.

[0064] It is understandable that before step S100, the method further includes: creating thread node information for each created second task thread, where the thread node information is used to manage the thread data and conditional breakpoint data of the second task thread; combining multiple thread node information to obtain a task thread list.

[0065] By storing conditional breakpoints and ordinary breakpoints separately, each second task thread can be better debugged.

[0066] It is understandable that the first hook function is implemented in Lua language.

[0067] It should be noted that by embedding the first hook function set in Lua language in the programming language, the development efficiency of the first hook function can be improved by virtue of the understandability of the Lua language. At the same time, a debugging library is provided in Lua, and the debugging instructions in the debugging library can be directly called for debugging, with higher efficiency.

[0068] It is understandable that the method further includes: creating a main thread; the main thread creates a second task thread through the Lanes library and sets a corresponding third hook function for the second task thread.

[0069] It should be noted that the main thread creates a second task thread through the Lanes library, which is equivalent to creating a virtual machine for each second task thread. At this time, each third hook function runs independently and does not affect each other. Therefore, independent control of each second task thread can be achieved.

[0070] It should be noted that the first hook function and the second hook function are also the third hook function. Here, it is only for distinction.

[0071] It is understandable that the method further includes: creating a main hook function for the main thread; monitoring the life cycle of the main thread through the main hook function to empty the corresponding task thread list when the life cycle of the main thread ends.

[0072] Exemplarily, referring to Figure 4The schematic diagram of the thread creation system structure shown creates the main thread through the API layer. At this time, the main thread creates virtual machine objects for each second task thread through the lanes library. The API layer (application layer) creates thread node information in each virtual machine object at this time, adds the thread node information to the task thread list, and adds Hook functions to each second task thread. When the life cycle of the child thread of the second task thread ends, the Hook function of the main thread is triggered. When all the second task threads end, the life cycle of the main thread of the main thread ends. At this time, the task thread list is cleared.

[0073] It should be noted that the breakpoint set can be loaded or updated by setting a breakpoint file and loading the breakpoint file through a lua script.

[0074] It should be noted that in some embodiments, receiving the start debugging request means responding to the loading of the lua script. When all the breakpoints in the breakpoint set are cleared and all the debugging instructions (such as conditional breakpoints) are cleared, the device enters the normal execution state. It should be noted that in some other cases, there is a button or instruction to start debugging, and the device will enter the debugging state only after it is turned on.

[0075] It should be noted that multiple lua scripts can be set, and the device can be debugged by loading different lua scripts or loading multiple lua scripts at the same time.

[0076] It can be understood that the present application also proposes an electronic device, including: a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the debugging method of the above device is implemented.

[0077] As a non-transitory computer-readable storage medium, the memory can be used to store non-transitory software programs and non-transitory computer-executable programs. In addition, the memory can include high-speed random access memory, and can also include non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state storage devices. In some embodiments, the memory may optionally include a memory remotely set relative to the processor, and these remote memories can be connected to the processor through a network. Examples of the above network include but are not limited to the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.

[0078] It should be noted that the electronic device in this embodiment can be applied as the device in Figure 1 the embodiment shown. The electronic device in this embodiment and the debugging method of the device shown in Figure 2 have the same inventive concept, so these embodiments have the same implementation principle and technical effects, which will not be elaborated here.

[0079] The non-transitory software program and instructions required to implement the information processing method of the above embodiments are stored in a memory. When executed by a processor, the information processing method in the above embodiments is executed. For example, the Figure 2 corresponding method steps are executed.

[0080] It can be understood that the present application also provides a computer-readable storage medium storing computer-executable instructions for executing the debugging method of the above device.

[0081] Those of ordinary skill in the art can understand that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and appropriate combinations thereof. Some physical components or all physical components can be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or can be implemented as hardware, or can be implemented as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include a computer storage medium (or non-transitory medium) and a communication medium (or transitory medium). As is well known to those of ordinary skill in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassette, tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, as is well known to those of ordinary skill in the art, a communication medium typically contains computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery medium.

[0082] The above is a specific description of the preferred embodiments of the present application, but the present application is not limited to the above embodiments. Those skilled in the art can make various equivalent deformations or substitutions without departing from the spirit of the present application, and these equivalent deformations or substitutions are all included within the scope defined by the claims of the present application.

Claims

1. A debugging method for an industrial device, characterized in that, The method includes: Receiving a start debugging request; When the breakpoint set is not empty, matching the breakpoint set with each second task thread in the task thread list to obtain a number of first task threads; According to the start debugging request, starting a first hook function corresponding to the first task thread; Determining a number of the first hook functions according to the start result; According to the breakpoint set, injecting a number of first breakpoints applied to the corresponding first task thread into the first hook function; Obtaining a variable value for conditional breakpoint judgment; wherein, the conditional breakpoint is injected into the thread node information of the first task thread, and the first hook function actively obtains the conditional breakpoint information from the thread node information of the first task thread and suspends the first hook function through the conditional breakpoint; When the program variable executed by the first task thread matches the variable value, suspending the first task thread and executing a preset instruction operation; Receiving a second debugging instruction update request from a user, and adding a to-be-added second breakpoint to the breakpoint set according to the second debugging instruction update request; Wherein, when the instruction operation is a first function in the preset conditional breakpoint, the executing the preset instruction operation includes: Extracting function information of the first function from the conditional breakpoint; Determining the first function from a preset function list according to the function information; Executing the first function.

2. The method according to claim 1, characterized in that, The method further includes: Receiving a first debugging instruction update request from a user, where the first debugging instruction update request is used to request an update of the conditional breakpoint; According to the first debugging instruction update request, injecting the conditional breakpoint into the corresponding first task thread so that the corresponding first hook function obtains the conditional breakpoint.

3. The method according to claim 2, characterized in that, Wherein, The instruction operation further includes an external request.

4. The method according to claim 1, wherein The method further includes: Judging whether a second hook function is started for a third task thread corresponding to the second breakpoint; According to the judgment result, judging whether to start the second hook function and adding the second breakpoint to the started second hook function.

5. The method according to any one of claims 1 to 4, characterized in that The method further includes: Closing the first hook function of the first task thread, where the first hook function is empty.

6. The method according to claim 1, characterized in that Before receiving the start debugging request, it further includes: Creating thread node information for each created second task thread, where the thread node information is used to manage the thread data and conditional breakpoint data of the second task thread; Combining a plurality of the thread node information to obtain a task thread list.

7. The method according to claim 6, wherein The first hook function is implemented by Lua language.

8. The method according to claim 6, wherein The method further includes: Creating a main thread; The main thread creates the second task thread through the Lanes library and sets a corresponding third hook function for the second task thread.

9. The method according to claim 8, wherein The method further includes: Creating a main hook function for the main thread; Monitoring the life cycle of the main thread through the main hook function to empty the corresponding task thread list when the life cycle of the main thread ends.

10. An industrial device, characterized in that, Including: A receiving module, configured to receive a start debugging request; A startup module, configured to, when the breakpoint set is not empty, match the breakpoint set with each second task thread in the task thread list to obtain a number of first task threads; According to the startup debugging request, start the first hook function corresponding to the first task thread; determine a number of the first hook functions according to the startup result; A breakpoint setting module, configured to select at least one first breakpoint from the breakpoint set and set it in the first hook function; wherein, the first breakpoint is applied to the first task thread; and receive a second debugging instruction update request from a user, and add a to-be-added second breakpoint to the breakpoint set according to the second debugging instruction update request; A debugging module, configured to obtain a variable value for conditional breakpoint judgment and, when a program variable executed by the first task thread matches the variable value, pause the first task thread and execute a preset instruction operation; wherein, the conditional breakpoint is injected into thread node information of the first task thread, and the first hook function actively obtains conditional breakpoint information from the thread node information of the first task thread and suspends the first hook function through the conditional breakpoint; Wherein, when the instruction operation is a first function function preset in the conditional breakpoint, the execution of the preset instruction operation includes: Extract function information of the first function function from the conditional breakpoint; Determine the first function function from a preset function list according to the function information; Execute the first function function.

11. An electronic device, characterized in that, Including: A memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the computer program, it is the debugging method of the industrial device according to any one of claims 1 to 9.

12. A computer-readable storage medium, characterized in that, Stored with computer-executable instructions, the computer-executable instructions are used to execute at least the debugging method of the industrial device according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Code debugging method and device

    CN106681897A

  • Thread-oriented debugging

    CN1335962A