Log output redirection method, device and related equipment

By freezing and restoring applications on embedded devices and redirecting file descriptor paths, the problem of difficulty in log output during debugging of embedded devices is solved, and logs can be sent to remote devices without adding hardware modules. The effect is to simplify the debugging process.

CN112799902BActive Publication Date: 2024-10-18YUNDING NETWORK TECH BEIJING
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN201911111998.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-11-14
Publication Date
2024-10-18
Estimated Expiration
2039-11-14

AI Technical Summary

Technical Problem

When debugging existing embedded devices, it is difficult to effectively output application logs to remote devices, and when debugging locally, it is necessary to disconnect the device and connect physical cables, which is a cumbersome operation.

Method used

By freezing the target application running on the embedded device, saving its context, closing the file descriptor associated with the target application, redirecting the file descriptor path to the target log output path, and unfreezing it after restoring the context, it is achieved without Send application logs to remote devices with the addition of additional hardware modules.

Benefits of technology

It enables logs to be output to remote devices without affecting the running of the application, simplifying the local debugging process, avoiding the need to disassemble the device to connect physical cables, and saving cost and time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112799902B_ABST
    Figure CN112799902B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a log output redirection method, device and related equipment, which are applied to a debugging device, the debugging device is connected to the embedded device to be debugged, and the debugging device has the authority to remotely control the embedded device. A specific implementation of the method includes: freezing the target application running on the embedded device; saving the context of the target application; closing the file descriptor related to the target application; redirecting the file path corresponding to the file descriptor to the target log output path; opening the file descriptor; restoring the saved context on the embedded device, and unfreezing the target application. This implementation realizes sending the application log to the remote device without adding additional hardware modules. At the same time, when performing local debugging, this implementation is also very simple and convenient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a log output redirection method, apparatus, and related equipment. Background Art

[0002] The application log stores various information during the application running process, such as running time, running results, error type, etc. The application log is important information that is indispensable for device debugging and troubleshooting.

[0003] The embedded device is composed of an embedded processor, related supporting hardware and an embedded software system. The application log of the existing embedded device is output to the local through the serial port path.

[0004] How to better obtain application logs is still a technical problem that needs to be solved urgently by those skilled in the art. Summary of the invention

[0005] The embodiments of the present application provide a log output redirection method, apparatus and related equipment.

[0006] In a first aspect, an embodiment of the present application provides a log output redirection method, which is applied to a debugging device, the debugging device is communicatively connected with an embedded device to be debugged, and the debugging device has permission to remotely control the embedded device, and the method includes:

[0007] Freeze the target application running on the embedded device;

[0008] Save the context of the target application;

[0009] Close the file descriptor associated with the target application;

[0010] Redirect the file path corresponding to the file descriptor to the target log output path;

[0011] Open the file descriptor;

[0012] Restores the saved context on the embedded device, unfreezing the target application.

[0013] In some embodiments, freezing a target application running on the embedded device includes:

[0014] Use the system call function Linux ptrace to intercept the system's call to the target application's Sleep function to freeze the target application.

[0015] In some embodiments, the system call function Linux ptrace is used to intercept the system's call to the Sleep function of the target application to freeze the target application, including:

[0016] The system call function Linux ptrace is used to monitor the system's call to the target application's Sleep function. If detected, the call parameters of the Sleep function passed by the system to the target application are intercepted to freeze the target application.

[0017] In some embodiments, before freezing the target application running on the embedded device, the method further includes:

[0018] Obtain identification information of the target application;

[0019] Freezing a target application running on the embedded device, including: freezing the target application running on the embedded device according to the identification information.

[0020] In some embodiments, the debugging device is installed with a client application for implementing remote control, and the embedded device is installed with a server application corresponding to the client application, and the client application is communicatively connected with the server application.

[0021] In a second aspect, an embodiment of the present application provides a log output redirection device, which is applied to a debugging device, the debugging device is communicatively connected with an embedded device to be debugged, and the debugging device has the authority to remotely control the embedded device, and the device includes:

[0022] A program freezing unit, used to freeze the target application running on the embedded device;

[0023] A context saving unit, used to save the context of the target application;

[0024] A descriptor closing unit is used to close the file descriptors associated with the target application;

[0025] A path redirection unit is used to redirect the file path corresponding to the file descriptor to the target log output path;

[0026] Descriptor opening unit, used to open file descriptors;

[0027] The freeze unfreeze unit is used to restore the saved context on the embedded device and unfreeze the target application.

[0028] In some embodiments, the program freezing unit is specifically used to:

[0029] Use the system call function Linux ptrace to intercept the system's call to the target application's Sleep function to freeze the target application.

[0030] In some embodiments, the program freezing unit is specifically used to:

[0031] The system call function Linux ptrace is used to monitor the system's call to the target application's Sleep function. If detected, the call parameters of the Sleep function passed by the system to the target application are intercepted to freeze the target application.

[0032] In some embodiments, the apparatus further includes: an identification obtaining unit, configured to obtain identification information of the target application before the program freezing unit freezes the target application running on the embedded device;

[0033] The program freezing unit is specifically used to freeze the target application running on the embedded device according to the identification information.

[0034] In some embodiments, the debugging device is installed with a client application for implementing remote control, and the embedded device is installed with a server application corresponding to the client application, and the client application is communicatively connected with the server application.

[0035] In a third aspect, an embodiment of the present application provides a computer-readable medium having a computer program stored thereon, wherein the program, when executed by a processor, implements the method described in any implementation manner in the first aspect.

[0036] In a fourth aspect, an embodiment of the present application provides a processor for running a program, wherein the program, when running, executes the method described in any implementation manner in the first aspect.

[0037] In a fifth aspect, an embodiment of the present application provides a debugging device, including:

[0038] one or more processors;

[0039] a storage device having one or more programs stored thereon;

[0040] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner in the first aspect.

[0041] The log output redirection method, apparatus and related equipment provided in the embodiments of the present application freeze the target application running on the embedded device to be debugged, and then save the context of the target application, and then close the file descriptor related to the target application, and then redirect the file path corresponding to the file descriptor to the target log output path, and then open the file descriptor, and finally restore the saved context on the embedded device to unfreeze the target application. This can realize sending the application log to the remote device without adding additional hardware modules. At the same time, when performing local debugging, this implementation method is also very simple and convenient. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some examples or embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without creative work, and the present application can also be applied to other similar scenarios based on the provided drawings. Unless it is obvious from the language environment or otherwise explained, the same reference numerals in the figures represent the same structure or operation.

[0043] Figure 1 is an exemplary system architecture diagram to which some embodiments of the present application may be applied;

[0044] Figure 2 is a flow chart of an embodiment of a log output redirection method according to the present application;

[0045] Figure 3 is a flow chart of another embodiment of the log output redirection method according to the present application;

[0046] Figure 4 is a structural diagram of an embodiment of a log output redirection device according to the present application;

[0047] Figure 5 It is a structural diagram of a debugging device suitable for implementing some embodiments of the present application. DETAILED DESCRIPTION

[0048] The present application will be further described in detail below in conjunction with the accompanying drawings and examples. It will be understood that the specific embodiments described herein are only used to explain the relevant inventions, rather than to limit the invention. The described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application.

[0049] It should be noted that, for the convenience of description, only the parts related to the relevant invention are shown in the drawings. In the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other.

[0050] It should be understood that the "system", "device", "unit" and / or "module" used in this application is a method for distinguishing different components, elements, parts, portions or assemblies at different levels. However, if other words can achieve the same purpose, the word can be replaced by other expressions.

[0051] As shown in this application and claims, unless the context clearly indicates an exception, the words "a", "an", "a kind" and / or "the" do not refer to the singular, but also include the plural. Generally speaking, the terms "include" and "comprise" only indicate the inclusion of clearly identified steps and elements, and these steps and elements do not constitute an exclusive list. The method or device may also include other steps or elements. The elements defined by the sentence "includes a..." do not exclude the existence of other identical elements in the process, method, commodity or device that includes the elements.

[0052] In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0053] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.

[0054] Flowcharts are used in the present application to illustrate the operations performed by the system according to the embodiments of the present application. It should be understood that the preceding or following operations are not necessarily performed accurately in order. On the contrary, the various steps may be processed in reverse order or simultaneously. At the same time, other operations may also be added to these processes, or one or more operations may be removed from these processes.

[0055] Figure 1 An exemplary system architecture is shown to which some embodiments of the log output redirection method or log output redirection device of the present application can be applied.

[0056] like Figure 1 As shown, the system architecture may include a debugging device 001 and an embedded device 002. The debugging device 001 and the embedded device 002 may communicate via a network interface 003, and the embedded device 002 includes a Universal Asynchronous Receiver / Transmitter (UART) 004. When the debugging device 001 is a remote device, the debugging device 001 may communicate with the network interface 003 of the embedded device 002 via the Internet.

[0057] The user can use the debugging device 001 to interact with the embedded device 002 through the network to receive logs or send commands, etc. The debugging device 001 is installed with a client application for implementing remote control, and the embedded device 002 is installed with a server application corresponding to the client application, and the client application is connected to the server application.

[0058] The debugging device 001 and the embedded device 002 can be hardware or software. When the debugging device 001 and the embedded device 002 are hardware, they can be various electronic devices, including but not limited to smart phones, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), e-book readers, MP3 (Moving Picture Experts Group Audio Layer III, dynamic image expert compression standard audio layer 3) players, MP4 (Moving Picture Experts Group Audio Layer IV, dynamic image expert compression standard audio layer 4) players, laptop computers, desktop computers, smart electric meters, smart water meters, smart cat eyes, gateways and other electronic devices. When the debugging device 001 and the embedded device 002 are software, they can be installed in the electronic devices listed above. It can be implemented as multiple software or software modules (for example, used to provide distributed services), or it can be implemented as a single software or software module. The embodiments of the present application do not impose any limitation on the specific type of electronic device.

[0059] It should be noted that the log output redirection method provided in the embodiment of the present application is generally executed by the debugging device 001, and accordingly, the log output redirection device is generally set in the debugging device 001.

[0060] It should be understood that Figure 1 The number of debugging devices 001 and embedded devices 002 in the embodiment is only for illustration. Any number of debugging devices and embedded devices may be provided according to implementation requirements.

[0061] like Figure 2 As shown, it shows the process of an embodiment of the log output redirection method according to the present application, which is applied to the debugging device (for example Figure 1 The debugging device 001 shown in the figure is connected to the embedded device to be debugged (eg Figure 1The embedded device 002 shown in the figure is in communication connection, and the debugging device has the authority to remotely control the embedded device. The method may include:

[0062] S100, freeze the target application running on the embedded device;

[0063] In an optional implementation, the debugging device can be connected to the embedded device to be debugged through a network interface (such as an Ethernet interface). The debugging device can be a local debugging device or a remote debugging device. The embedded device can have a network interface. Optionally, the embedded device can include: UART. The specific physical manifestation of UART is an independent modular chip, or as a peripheral device integrated in a microprocessor. UART is generally of RS-232C specification, and is paired with a standard signal amplitude conversion chip such as Maxim's MAX232 as an interface for connecting external devices.

[0064] Among them, the debugging device can control the embedded device to complete Figure 2 The method shown has multiple specific control modes, such as the debugging device controls the embedded device to execute corresponding actions (such as freezing the application, saving context, closing file descriptors, redirecting file paths, opening file descriptors, restoring contexts, unfreezing the application, etc.) according to the commands by issuing commands to the embedded device. Another example: the embedded device stores program codes for executing certain actions or the embedded device installs applications for executing certain actions, and the program codes or applications can be controlled by the debugging device to start executing corresponding actions (such as freezing the application, saving context, closing file descriptors, redirecting file paths, opening file descriptors, restoring contexts, unfreezing the application, etc.).

[0065] In an optional implementation, the debugging device is installed with a client application for implementing remote control, and the embedded device is installed with a server application corresponding to the client application, and the client application is communicatively connected with the server application.

[0066] The client application may be a Telnet client application or an SSH (Secure Shell) client application. Telnet is a standard protocol and main method for Internet remote login services, which provides users with the ability to complete remote host work on local computers. SSH is a protocol designed to provide security for remote login sessions and other network services. Optionally, the target application is different from the above-mentioned client application, and the target application is different from the above-mentioned server application.

[0067] In an optional implementation manner, step S100 may specifically include:

[0068] Use the system call function Linux ptrace to intercept the system's call to the target application's Sleep function to freeze the target application.

[0069] Among them, the target application runs on an embedded device.

[0070] Among them, Linux ptrace provides a way for the parent process to monitor and control other processes. It can also change the registers and kernel images in the child process, thereby realizing breakpoint debugging and system call tracking.

[0071] In an optional implementation, the embedded device may be a Linux embedded device.

[0072] The Sleep function can put an application (process, task or thread) into sleep mode, making it inactive for a period of time. The Sleep function is ubiquitous in various applications, so the present application can freeze the target application by intercepting the system's call to the function of the target application. Of course, in other embodiments, the present application can also freeze the target application by intercepting the system's call to other functions of the target application, and the present application does not limit this.

[0073] Further, the above-mentioned use of the system call function Linux ptrace to intercept the system's call to the Sleep function of the target application to freeze the target application may include:

[0074] The system call function Linux ptrace is used to monitor the system's call to the target application's Sleep function. If detected, the call parameters of the Sleep function passed by the system to the target application are intercepted to freeze the target application.

[0075] Since it is impossible to know when the system will call the Sleep function of the target application, this application can first monitor it, and then intercept it if it is detected.

[0076] S200, saving the context of the target application;

[0077] It is understandable that the context of an application is the environmental information of the application (such as the application state and variable state), and the context saves the values ​​of the CPU (Central Processing Unit) registers, which include: the execution address of the application, the function flow return value, etc. After saving the context of the target application, the present application can restore the target application according to the context.

[0078] Optionally, the context can be saved in the embedded device or in the debug device.

[0079] S300: Close the file descriptor related to the target application.

[0080] Among them, the kernel can use file descriptors to access files. File descriptors are non-negative integers. When opening an existing file or creating a new file, the kernel will return a file descriptor. Here, the file descriptor related to the target application can be a standard file descriptor, and the standard file descriptors can include: 0, 1, 2, etc. 0 is the standard input descriptor (stdin), 1 is the standard output descriptor (stdout), and 2 is the standard error output descriptor (stderr). Among them, different standard file descriptors can correspond to different types of paths. For example: in the Linux system, the path corresponding to 0 is the standard input path, the path corresponding to 1 is the standard output path, and the path corresponding to 2 is the standard error output path.

[0081] Optionally, different applications may use the same or different file descriptors, for example, the system maintains a file descriptor group for each application, or the system maintains a file descriptor group for each process (generally one application corresponds to one process). The above file descriptor group may include at least one of a standard input descriptor, a standard output descriptor, and a standard error output descriptor. Specifically, the paths corresponding to the same type of descriptors in the file descriptor groups corresponding to different applications or processes may be different. For example, the path corresponding to the standard output descriptor in the file descriptor group corresponding to the first application is path 1, and the path corresponding to the standard output descriptor in the file descriptor group corresponding to the second application is path 2, and path 1 and path 2 are different.

[0082] In other embodiments, the system may also set the same file descriptor group for each application / process it manages, so that the paths corresponding to the same type of descriptors in the file descriptor groups corresponding to different applications or processes are the same. For example, the path corresponding to the standard output descriptor in the file descriptor group corresponding to the first application is path 1, and the path corresponding to the standard output descriptor in the file descriptor group corresponding to the second application is also path 1.

[0083] Optionally, the present application can close file descriptors that are related to the target application and belong to a preset type (such as at least one of standard input, standard output, and standard error output). For example: in an optional embodiment, step S300 can only close file descriptor 1, that is, the standard output descriptor. In this way, the standard output path corresponding to the standard output descriptor is closed. In another optional embodiment, step S300 can close file descriptor 1 and close file descriptor 2. In another optional embodiment, step S300 can close file descriptors 0, 1, and 2.

[0084] S400, redirecting the file path corresponding to the file descriptor to the target log output path;

[0085] After closing the file descriptor in step S300, the present application may modify the file path corresponding to the closed file descriptor to redirect the file path.

[0086] The target log output path may be a network path of an electronic device that needs to obtain the log in the embedded device. Optionally, the electronic device may be a local device or a remote device. In an optional implementation, the target log output path is a network path of a debugging device, that is, the electronic device is a debugging device.

[0087] Specifically, the log is a virtual file simulated by the system. Although the log is a virtual file, it still has a path. Therefore, after redirecting the file path corresponding to the file descriptor to the target log output path, the log can be output to the above electronic device.

[0088] The target log output path can be the Telnet login path or the SSH login path.

[0089] Among them, the Telnet login path of this application is the login path of the network service program Telnet.

[0090] S500, open a file descriptor;

[0091] It is understandable that the path can be used again and the file path redirected in step S400 can take effect only after the previously closed file descriptor is opened.

[0092] S600: Restore the saved context on the embedded device and unfreeze the target application.

[0093] Since the present application has redirected the file path corresponding to the file descriptor to the target log output path, the application log will be sent to the electronic device through the target log output path after the application resumes execution.

[0094] When it is necessary to debug the embedded device locally, the debugging device of the present application can be located locally in the embedded device. After the debugging device is connected to the embedded device through the network interface, the debugging device can perform the processing of the above steps S100 to S600. When the target log output path is the network path of the debugging device, the log in the embedded device will be output to the debugging device through the network interface. In this case, the present application does not need to view the log through UART, and the problem of needing to disassemble the device to connect the physical cable when viewing the log through UART is avoided. It can be seen that when the solution of the present application is applied in the process of local debugging, there is no need to disassemble the device to connect the physical cable, which is convenient and fast.

[0095] When it is necessary to remotely debug an embedded device, the debugging device of the present application can be located at the far end of the embedded device. After the debugging device is connected to the embedded device through a network interface, the debugging device can perform the above-mentioned steps S100 to S600. When the target log output path is the network path of the debugging device, the log in the embedded device will be output to the debugging device through the network interface. In this case, the present application can realize the sending of logs to a remote debugging device via the Internet without adding another hardware module locally to the embedded device. The present application solves the problem that an additional hardware module must be deployed during remote debugging of an embedded device in order to forward logs to a remote debugging device.

[0096] At the same time, the present application realizes local and remote debugging by deploying software for device debugging in embedded devices, without the need for additional hardware modules, thus saving costs and time, and without any negative interference to running applications.

[0097] Furthermore, since the present application does not use UART for log transmission, when UART cannot transmit logs, the present application can restore the output of the application's logs without affecting the operation of the application, that is, outputting the logs through the network interface.

[0098] In an optional specific implementation, the present application can be implemented based on a MIPS CPU. MIPS is a very popular RISC (Reduced Instruction Set Computing) processor in the world. If it is implemented on other CPU platforms, such as ARM, x86, etc., it is only necessary to adapt the program context saving and restoring parts, which is very convenient.

[0099] like Figure 3 As shown, it shows the process of another embodiment of the log output redirection method according to the present application, which is applied to a debugging device (such as Figure 1The debugging device 001 shown in the figure is connected to the embedded device to be debugged (eg Figure 1 The embedded device 002 shown in the figure is in communication connection, and the debugging device has the authority to remotely control the embedded device. The method may include:

[0100] S001. Obtain identification information of the target application;

[0101] The identification of the target application may be an ID (Identity Document) of the target application. Here, the Chinese name of the ID may be an identity identification number. It should be noted that the identification information may be received by the debugging device from other devices, modules or apparatuses, and this embodiment does not impose any limitation on the source of the identification information.

[0102] S101. Freeze a target application running on an embedded device according to the identification information.

[0103] Among them, step S101 is Figure 2 A specific implementation manner of step S100 in the method shown.

[0104] S200, saving the context of the target application;

[0105] S300, closing the file descriptor related to the target application;

[0106] S400, redirecting the file path corresponding to the file descriptor to the target log output path;

[0107] S500, open a file descriptor;

[0108] S600: Restore the saved context on the embedded device and unfreeze the target application.

[0109] Steps S200 to S600 have been Figure 2 The method is described in detail and will not be repeated here.

[0110] The log output redirection method provided in this embodiment can implement the log output redirection operation for a specific application by first acquiring identification information and then executing steps S101-S600 for the application indicated by the identification information.

[0111] and Figure 2 Corresponding to the method shown, an embodiment of the present application also provides a log output redirection device.

[0112] like Figure 4As shown, it shows a log output redirection device provided by an embodiment of the present application, which is applied to a debugging device, the debugging device is communicatively connected with an embedded device to be debugged, and the debugging device has the authority to remotely control the embedded device, and the device may include:

[0113] A program freezing unit 100 is used to freeze a target application running on an embedded device;

[0114] A context saving unit 200, used to save the context of the target application;

[0115] A descriptor closing unit 300, used to close the file descriptor related to the target application;

[0116] A path redirection unit 400 is used to redirect the file path corresponding to the file descriptor to a target log output path;

[0117] A descriptor opening unit 500 is used to open a file descriptor;

[0118] The freeze release unit 600 is used to restore the saved context on the embedded device and release the freeze on the target application.

[0119] In an optional implementation manner, the program freezing unit 100 is specifically used for:

[0120] Use the system call function Linux ptrace to intercept the system's call to the target application's Sleep function to freeze the target application.

[0121] Among them, the target application runs on an embedded device.

[0122] In an optional implementation manner, the program freezing unit 100 is specifically used for:

[0123] The system call function Linux ptrace is used to monitor the system's call to the target application's Sleep function. If detected, the call parameters of the Sleep function passed by the system to the target application are intercepted to freeze the target application.

[0124] In an alternative embodiment, Figure 4 The device shown also includes: an identification obtaining unit, which is used to obtain identification information of the target application before the program freezing unit 100 freezes the target application running on the embedded device;

[0125] The program freezing unit 100 is specifically used to freeze the target application running on the embedded device according to the above identification information.

[0126] In an optional implementation, the debugging device is installed with a client application for implementing remote control, and the embedded device is installed with a server application corresponding to the client application, and the client application is communicatively connected with the server application.

[0127] When it is necessary to debug the embedded device locally, the debugging device of the present application can be located locally in the embedded device. After the debugging device is connected to the embedded device through the network interface, the debugging device can perform the above processing. When the target output path is the network path of the debugging device, the log in the embedded device will be output to the debugging device through the network interface. In this case, the present application does not need to view the log through UART, which avoids the problem of needing to disassemble the device to connect the physical cable when viewing the log through UART. It can be seen that when the solution of the present application is applied in the process of local debugging, there is no need to disassemble the device to connect the physical cable, which is convenient and fast.

[0128] When it is necessary to remotely debug an embedded device, the debugging device of the present application can be located at the remote end of the embedded device. After the debugging device is connected to the embedded device through a network interface, the debugging device can perform the above processing. When the target output path is the network path of the debugging device, the log in the embedded device will be output to the debugging device through the network interface. In this case, the present application can realize the sending of logs to a remote debugging device via the Internet without adding another hardware module locally to the embedded device. The present application solves the problem that an additional hardware module must be deployed during remote debugging of an embedded device in order to forward logs to a remote debugging device.

[0129] In this embodiment, the specific processing of the program freezing unit 100, the context saving unit 200, the descriptor closing unit 300, the path redirection unit 400, the descriptor opening unit 500 and the freezing release unit 600 and the technical effects thereof can be referred to respectively. Figure 2 The relevant descriptions of the embodiments of step S100 to step S600 in the corresponding embodiments are not repeated here.

[0130] It should be noted that the log output redirection device can be a chip, component or module. The log output redirection device includes a processor and a memory. The program freezing unit 100, the context saving unit 200, the descriptor closing unit 300, the path redirection unit 400, the descriptor opening unit 500 and the freeze release unit 600 are all stored in the memory as program units, and the processor executes the above program units stored in the memory to implement corresponding functions.

[0131] The processor may include a kernel, which calls the corresponding program unit from the memory. The kernel may be set with one or more kernel parameters to redirect the log output.

[0132] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.

[0133] like Figure 5 As shown, the debugging device 001 may include a processor 701, a memory 702, a communication interface 703, an input unit 704, an output unit 705, and a communication bus 706. The processor 701 and the memory 702 are connected to each other via the communication bus 706. The communication interface 703, the input unit 704, and the output unit 705 are also connected to the communication bus 706.

[0134] The communication interface 703 may be an interface of a communication module, such as an interface of a GSM module. The communication interface 703 may be used to obtain logs sent by an embedded device, and the communication interface 703 may also be used to send commands to the embedded device.

[0135] In the embodiment of the present application, the processor 701 may be a central processing unit, an application-specific integrated circuit (ASIC), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, etc.

[0136] In one possible implementation, the memory 702 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, and applications required for at least one function (such as an application freezing function, an output path redirection function, etc.); the data storage area may store data created during the use of the computer, such as logs, application identification information, etc.

[0137] In addition, the memory 702 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device or other volatile solid-state storage device.

[0138] The processor 701 may call the program stored in the memory 702. Specifically, the processor 701 may execute the following Figures 1 to 2 The log output redirection method shown in any of the embodiments.

[0139] The memory 702 is used to store one or more programs, which may include program codes, and the program codes include computer operation instructions. In the embodiment of the present application, the memory 702 at least stores programs for implementing the following functions:

[0140] Freeze the target application running on the embedded device;

[0141] Save the context of the target application;

[0142] Close the file descriptor associated with the target application;

[0143] Redirect the file path corresponding to the file descriptor to the target log output path;

[0144] Open the file descriptor;

[0145] Restores the saved context on the embedded device, unfreezing the target application.

[0146] The present application may further include an input unit 704, which may include at least one of a touch sensing unit for sensing touch events on the touch display panel, a keyboard, a mouse, a camera, a microphone, and the like.

[0147] The output unit 705 may include: at least one of a display, a speaker, a vibration mechanism, a lamp and other devices. The display may include a display panel, such as a touch display panel, etc. In one possible case, the display panel may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. The vibration mechanism may cause the debugging device 001 to displace when working. In one possible implementation, the vibration mechanism includes a motor and an eccentric vibrator, and the motor drives the eccentric vibrator to rotate to generate vibration. The brightness and / or color of the lamp is adjustable. In one possible implementation, different information may be reflected by at least one of the on and off, brightness, and color of the lamp, such as reflecting alarm information by the lamp emitting red light.

[0148] certainly, Figure 5 The structure of the debugging device 001 shown does not constitute a limitation on the debugging device in the embodiment of the present application. In actual applications, the debugging device may include Figure 5 More or fewer components than shown, or combinations of certain components.

[0149] An embodiment of the present application provides a computer-readable medium having a computer program stored thereon, wherein when the program is executed by a processor, the log output redirection method described in the above method embodiments is implemented.

[0150] An embodiment of the present application provides a processor, which is used to run a program, wherein the log output redirection method described in the above method embodiments is implemented when the program is running.

[0151] The present application also provides a computer program product, which, when executed on a data processing device, enables the data processing device to implement the log output redirection method described in the above method embodiments.

[0152] Among them, the debugging equipment, processor, computer-readable medium or computer program product provided in the above embodiments of the present application can all be used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here.

[0153] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0154] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0155] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0156] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0157] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0158] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0159] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.

[0160] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used, and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. The scope of the invention involved in the present application is not limited to the technical solution formed by a specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalent features without departing from the above-mentioned inventive concept. For example, a technical solution formed by replacing the above-mentioned features with the technical features with similar functions disclosed in this application (but not limited to).

Claims

1. A log output redirection method, characterized in that: The method is applied to a debugging device, the debugging device is in communication connection with an embedded device to be debugged, and the debugging device has the authority to remotely control the embedded device, and the method includes: Freezing a target application running on the embedded device; Saving the context of the target application; Close the file descriptor associated with the target application; Modify the file path corresponding to the file descriptor and redirect it to the target log output path, where the target log output path is the network path of the electronic device that needs to obtain the log in the embedded device; Opening the file descriptor; The saved context is restored on the embedded device, and the target application is unfrozen, so that the log of the target application is sent to the electronic device through the target log output path after the target application resumes execution.

2. The method according to claim 1, characterized in that Freezing the target application running on the embedded device comprises: The system call function Linux ptrace is used to intercept the system's call to the Sleep function of the target application to freeze the target application.

3. The method according to claim 2, characterized in that The method of using the system call function Linux ptrace to intercept the system's call to the Sleep function of the target application to freeze the target application comprises: The system call function Linux ptrace is used to monitor the system's call to the Sleep function of the target application. If detected, the call parameters of the Sleep function passed by the system to the target application are intercepted to freeze the target application.

4. The method according to any one of claims 1 to 3, characterized in that Before freezing the target application running on the embedded device, the method further includes: Obtaining identification information of the target application; The freezing the target application running on the embedded device includes: freezing the target application running on the embedded device according to the identification information.

5. The method according to any one of claims 1 to 3, characterized in that The debugging device is installed with a client application for realizing remote control, and the embedded device is installed with a server application corresponding to the client application, and the client application is connected in communication with the server application.

6. A log output redirection device, characterized in that: The device is applied to a debugging device, the debugging device is communicatively connected with an embedded device to be debugged, and the debugging device has the authority to remotely control the embedded device, and the device includes: A program freezing unit, used for freezing a target application running on the embedded device; A context saving unit, used to save the context of the target application; A descriptor closing unit, used for closing the file descriptor related to the target application; A path redirection unit, used to modify the file path corresponding to the file descriptor and redirect it to a target log output path, where the target log output path is a network path of an electronic device that needs to obtain the log in the embedded device; A descriptor opening unit, used for opening the file descriptor; The freeze release unit is used to restore the saved context on the embedded device and release the freeze on the target application so that the log of the target application is sent to the electronic device through the target log output path after the target application resumes execution.

7. The device according to claim 6, characterized in that The program freezing unit is specifically used for: The system call function Linux ptrace is used to intercept the system's call to the Sleep function of the target application to freeze the target application.

8. A computer readable medium having a computer program stored thereon, wherein: When the program is executed by a processor, the log output redirection method according to any one of claims 1 to 5 is implemented.

9. A processor for running a program, wherein: When the program is running, the log output redirection method according to any one of claims 1 to 5 is implemented.

10. A debugging device, comprising: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the log output redirection method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Process debugging method and device based on virtual file system and computer equipment

    CN109491759A

  • Remote debugging method and system

    CN109660399A

  • Dynamically redirecting a file descriptor

    US20130081017A1