CN112799902A - Log output redirection method and device and related equipment - Google Patents

Log output redirection method and device and related equipment Download PDF

Info

Publication number
CN112799902A
CN112799902A CN201911111998.1A CN201911111998A CN112799902A CN 112799902 A CN112799902 A CN 112799902A CN 201911111998 A CN201911111998 A CN 201911111998A CN 112799902 A CN112799902 A CN 112799902A
Authority
CN
China
Prior art keywords
application program
target application
embedded
program
equipment
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201911111998.1A
Other languages
Chinese (zh)
Inventor
刘华生
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Yunding Network Technology Beijing Co Ltd
Original Assignee
Yunding Network Technology Beijing 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 Yunding Network Technology Beijing Co Ltd filed Critical Yunding Network Technology Beijing Co Ltd
Priority to CN201911111998.1A priority Critical patent/CN112799902A/en
Publication of CN112799902A publication Critical patent/CN112799902A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3065Monitoring arrangements determined by the means or processing involved in reporting the monitored data
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3089Monitoring arrangements determined by the means or processing involved in sensing the monitored data, e.g. interfaces, connectors, sensors, probes, agents
    • G06F11/3093Configuration details thereof, e.g. installation, enabling, spatial arrangement of the probes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2201/00Indexing scheme relating to error detection, to error correction, and to monitoring
    • G06F2201/865Monitoring of software

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The embodiment of the application discloses a log output redirection method, a log output redirection device and related equipment, which are applied to debugging equipment, wherein the debugging equipment is in communication connection with embedded equipment to be debugged, and the debugging equipment has the authority of remotely controlling the embedded equipment. One embodiment of the method comprises: freezing a target application program running on the embedded equipment; saving a context of the target application; closing a file descriptor associated with the target application; redirecting a file path corresponding to the file descriptor to a target log output path; opening a file descriptor; and restoring the saved context on the embedded equipment and releasing the freezing of the target application program. The implementation mode realizes that the application program log is sent to the remote equipment on the premise of not adding an additional hardware module, and meanwhile, the implementation mode is very simple and convenient when local debugging is carried out.

Description

Log output redirection method and device and related equipment
Technical Field
The embodiment of the application relates to the technical field of computers, in particular to a log output redirection method, a log output redirection device and related equipment.
Background
The application log stores various information such as running time, running result, error type, etc. during the running of the application. Application logs are important information essential for device debugging and troubleshooting.
The embedded device consists of an embedded processor, related supporting hardware and an embedded software system, and an application program log of the existing embedded device is output to the local through a serial port path.
How to better obtain the application program log is still a technical problem to be solved urgently by technical personnel in the field.
Disclosure of Invention
The embodiment of the application provides a log output redirection method, a log output redirection device and related equipment.
In a first aspect, an embodiment of the present application provides a log output redirection method, where 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 a right to remotely control the embedded device, and the method includes:
freezing a target application program running on the embedded equipment;
saving a context of the target application;
closing a file descriptor associated with the target application;
redirecting a file path corresponding to the file descriptor to a target log output path;
opening a file descriptor;
and restoring the saved context on the embedded equipment and releasing the freezing of the target application program.
In some embodiments, freezing a target application running on an embedded device comprises:
and intercepting the call of the system to the Sleep function of the target application program by using a system call function Linux ptrace to freeze the target application program.
In some embodiments, intercepting a call by the system to a Sleep function of a target application using a system call function Linux ptrace to freeze the target application comprises:
and monitoring the calling of the Sleep function of the target application program by using a system calling function Linux ptrace, and if the calling is monitored, intercepting and capturing calling parameters of the Sleep function transmitted to the target application program by the system to freeze the target application program.
In some embodiments, prior to freezing the target application running on the embedded device, the method further comprises:
acquiring identification information of a target application program;
freezing a target application running on an embedded device, comprising: and freezing the target application program running on the embedded equipment according to the identification information.
In some embodiments, the debugging device is provided with a client application program for realizing remote control, the embedded device is provided with a server application program corresponding to the client application program, and the client application program is in communication connection with the server application program.
In a second aspect, an embodiment of the present application provides a log output redirection apparatus, where the apparatus 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 a right to remotely control the embedded device, and the apparatus includes:
the program freezing unit is used for freezing a target application program running on the embedded equipment;
a context saving unit for saving a context of a target application;
a descriptor closing unit for closing a file descriptor related to the target application;
the path redirection unit is used for redirecting the file path corresponding to the file descriptor to a target log output path;
a descriptor opening unit for opening a file descriptor;
and the freeze removing unit is used for recovering the saved context on the embedded equipment and removing the freeze of the target application program.
In some embodiments, the program freezing unit is specifically configured to:
and intercepting the call of the system to the Sleep function of the target application program by using a system call function Linux ptrace to freeze the target application program.
In some embodiments, the program freezing unit is specifically configured to:
and monitoring the calling of the Sleep function of the target application program by using a system calling function Linux ptrace, and if the calling is monitored, intercepting and capturing calling parameters of the Sleep function transmitted to the target application program by the system to freeze the target application program.
In some embodiments, the apparatus further comprises: the identification obtaining unit is used for obtaining the identification information of the target application program before the program freezing unit freezes the target application program running on the embedded equipment;
the program freezing unit is specifically used for: and freezing the target application program running on the embedded equipment according to the identification information.
In some embodiments, the debugging device is provided with a client application program for realizing remote control, the embedded device is provided with a server application program corresponding to the client application program, and the client application program is in communication connection with the server application program.
In a third aspect, the present application provides a computer readable medium, on which a computer program is stored, where the program, when executed by a processor, implements the method as described in any implementation manner of the first aspect.
In a fourth aspect, the present application provides a processor, where the processor is configured to execute a program, where the program executes to perform the method described in any implementation manner of the first aspect.
In a fifth aspect, an embodiment of the present application provides a debugging apparatus, including:
one or more processors;
a storage device having one or more programs stored thereon;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the method as described in any implementation of the first aspect.
According to the log output redirection method, the log output redirection device and the related equipment, the target application program running on the embedded equipment to be debugged is frozen, the context of the target application program is stored, the file descriptor related to the target application program is closed, the file path corresponding to the file descriptor is redirected to the target log output path, the file descriptor is opened, the stored context is restored on the embedded equipment, the freezing of the target application program is removed, the application program log can be sent to the remote equipment on the premise that no additional hardware module is added, and meanwhile, when local debugging is conducted, the implementation mode is very simple and convenient.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below. It is obvious that the drawings in the following description are only some examples or embodiments of the present application, and that for a person skilled in the art, other drawings can be obtained from the provided drawings without inventive effort, and that the present application can also be applied to other similar scenarios from the provided drawings. Unless otherwise apparent from the context, or otherwise indicated, like reference numbers in the figures refer to the same structure or operation.
FIG. 1 is an exemplary system architecture diagram to which some embodiments of the present application may be applied;
FIG. 2 is a flow diagram for one embodiment of a log output redirection method according to the present application;
FIG. 3 is a flow diagram of yet another embodiment of a log output redirection method according to the present application;
FIG. 4 is a schematic block diagram illustrating one embodiment of a log output redirection device according to the present application;
fig. 5 is a schematic diagram of a commissioning device suitable for implementing some embodiments of the present application.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the relevant invention and not restrictive of the invention. The described embodiments are only some embodiments of the present application and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
It should be noted that, for convenience of description, only the portions related to the related invention are shown in the drawings. The embodiments and features of the embodiments in the present application may be combined with each other without conflict.
It should be understood that "system", "apparatus", "unit" and/or "module" as used herein is a method for distinguishing different components, elements, parts or assemblies at different levels. However, other words may be substituted by other expressions if they accomplish the same purpose.
As used in this application and the appended claims, the terms "a," "an," "the," and/or "the" are not intended to be inclusive in the singular, but rather are intended to be inclusive in the plural unless the context clearly dictates otherwise. In general, the terms "comprises" and "comprising" merely indicate that steps and elements are included which are explicitly identified, that the steps and elements do not form an exclusive list, and that a method or apparatus may include other steps or elements. An element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in the process, method, article, or apparatus that comprises the element.
In the description of the embodiments herein, "/" means "or" unless otherwise specified, for example, a/B may mean a or B; "and/or" herein is merely an association describing an associated object, and means that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, in the description of the embodiments of the present application, "a plurality" means two or more than two.
In the following, the terms "first", "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 technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature.
Flow charts are used herein to illustrate operations performed by systems according to embodiments of the present application. It should be understood that the preceding or following operations are not necessarily performed in the exact order in which they are performed. Rather, the various steps may be processed in reverse order or simultaneously. Meanwhile, other operations may be added to the processes, or a certain step or several steps of operations may be removed from the processes.
Fig. 1 illustrates an exemplary system architecture to which some embodiments of the log output redirection method or log output redirection apparatus of the present application may be applied.
As shown in fig. 1, the system architecture may include a debug device 001 and an embedded device 002. The debugging device 001 and the embedded device 002 can communicate through the 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 through the internet.
The user may interact with the embedded device 002 over a network using the commissioning device 001 to receive logs or send commands, etc. The debugging device 001 is provided with a client application program for realizing remote control, the embedded device 002 is provided with a server application program corresponding to the client application program, and the client application program is in communication connection with the server application program.
The debugging device 001 and the embedded device 002 may be hardware or software. When the debugging device 001 and the embedded device 002 are hardware, they may 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), electronic book readers, MP3(Moving Picture Experts Group Audio Layer III, dynamic image compression standard Audio Layer 3) players, MP4(Moving Picture Experts Group Audio Layer IV, dynamic image expert compression standard Audio Layer 4) players, laptop portable computers, desktop computers, smart meters, smart water meters, smart cat eyes, gateways, and other electronic devices. When the debug device 001 and the embedded device 002 are software, they can be installed in the electronic devices listed above. It may be implemented as multiple pieces of software or software modules (e.g., to provide distributed services) or as a single piece of software or software module. The embodiment of the present application does not set any limit to the specific type of the electronic device.
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 apparatus is generally disposed in the debugging device 001.
It should be understood that the number of debug devices 001 and embedded devices 002 in fig. 1 is merely illustrative. There may be any number of debug devices and embedded devices, as desired for implementation.
As shown in fig. 2, a flowchart of an embodiment of a log output redirection method according to the present application is shown, where the method is applied to a debugging device (e.g., the debugging device 001 shown in fig. 1), the debugging device is communicatively connected to an embedded device to be debugged (e.g., the embedded device 002 shown in fig. 1), and the debugging device has a right to remotely control the embedded device. The method can comprise the following steps:
s100, freezing a target application program running on the embedded equipment;
in an optional embodiment, the debugging device may be communicatively connected to the embedded device to be debugged through a network interface (e.g., an ethernet interface), and the debugging device may be a local debugging device or a remote debugging device. The embedded device may have a network interface. Optionally, the embedded device may include: a UART. UART embodiments are embodied as a stand-alone modular chip or as a peripheral device integrated into a microprocessor. The UART is generally of RS-232C specification, and is used in conjunction with a standard signal amplitude conversion chip such as MAX232 like Maxim as an interface for connecting external devices.
The debugging device may control the embedded device to complete the method shown in fig. 2, and the specific control manner includes various manners, for example, the debugging device controls the embedded device to execute corresponding actions according to the command by issuing a command to the embedded device (for example, freezing an application program, saving a context, closing a file descriptor, redirecting a file path, opening a file descriptor, restoring a context, releasing the freezing of the application program, and the like). The following steps are repeated: the embedded device stores program code for performing certain actions or installs an application program for performing certain actions, and the program code or the application program can be controlled by the debugged device to start performing corresponding actions (such as freezing the application program, saving the context, closing the file descriptor, redirecting the file path, opening the file descriptor, restoring the context, releasing the freezing of the application program, and the like).
In an optional embodiment, the debugging device is provided with a client application program for implementing remote control, the embedded device is provided with a server application program corresponding to the client application program, and the client application program is in communication connection with the server application program.
The client application may be a Telnet client application or an SSH (Secure Shell) client application. Telnet is a standard protocol and main mode of Internet remote login service, and provides a capability of completing remote host work on a local computer for a user. SSH is a protocol that is specific to providing security for telnet sessions and other web services. Optionally, the target application program is different from the client application program, and the target application program is different from the server application program.
In an optional embodiment, step S100 may specifically include:
and intercepting the call of the system to the Sleep function of the target application program by using a system call function Linux ptrace to freeze the target application program.
Wherein the target application runs on the embedded device.
The Linux ptrace provides a mode for enabling a parent process to monitor and control other processes, and can also change registers and kernel images in child processes, so that breakpoint debugging and tracking of system call can be realized.
In an alternative embodiment, the embedded device may be a Linux embedded device.
The Sleep function may put an application (process, task or thread) into Sleep, leaving it inactive for a period of time. The Sleep function is ubiquitous in all the applications, so that the method and the device can freeze the target application by intercepting the call of the system to the function of the target application. Of course, in other embodiments, the target application may also be frozen by intercepting calls of the system to other functions of the target application, which is not limited in this application.
Further, the intercepting, by the system call function Linux ptrace, a call of the system to the Sleep function of the target application program to freeze the target application program may include:
and monitoring the calling of the Sleep function of the target application program by using a system calling function Linux ptrace, and if the calling is monitored, intercepting and capturing calling parameters of the Sleep function transmitted to the target application program by the system to freeze the target application program.
Since the time when the system calls the Sleep function of the target application program cannot be known, the method and the system can firstly monitor and then intercept if the monitoring is carried out.
S200, saving the context of the target application program;
it is understood that the context of an application is the environment information of the application (such as the application state and variable state), and the context holds the values of the CPU (Central Processing Unit) registers, which include: the execution address of the application program, the function flow return value, and the like. After the context of the target application program is saved, the target application program can be restored according to the context.
Optionally, the context may be saved in the embedded device or in the debugging device.
S300, closing the file descriptor related to the target application program.
Wherein the kernel (kernel) may access the file using a file descriptor (file descriptor). The file descriptor is a non-negative integer and the kernel returns a file descriptor when an existing file or a new file is opened. Here, the file descriptor related to the target application may be a standard file descriptor, and the standard file descriptor may 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). Wherein different standard file descriptors may correspond to different types of paths. For example: in the Linux system, the path corresponding to 0 is a standard input path, the path corresponding to 1 is a standard output path, and the path corresponding to 2 is a standard error output path.
Alternatively, different applications may use the same or different file descriptors, such as: the system maintains a set of file descriptors for each application, or the system maintains a set of file descriptors for each process (typically one application for each process). The set of file descriptors may include: at least one of a standard input descriptor, a standard output descriptor, and a standard error output descriptor. Specifically, paths corresponding to the same type of descriptor in the file descriptor set corresponding to different applications or processes may be different. For example: the path corresponding to the standard output descriptor in the file descriptor set corresponding to the first application program is path 1, the path corresponding to the standard output descriptor in the file descriptor set corresponding to the second application program is path 2, and path 1 and path 2 are different.
In other embodiments, the system may also set the same file descriptor set for each application/process it manages, so that paths corresponding to the same type of descriptors in the file descriptor sets corresponding to different applications or processes are the same. For example: the path corresponding to the standard output descriptor in the file descriptor set corresponding to the first application program is path 1, and the path corresponding to the standard output descriptor in the file descriptor set corresponding to the second application program is also path 1.
Optionally, the application may close a file descriptor associated with the target application and belonging to a predetermined type (e.g., at least one of standard input, standard output, and standard error output). For example: in an alternative embodiment, step S300 may close only file descriptor 1, i.e. the standard output descriptor. Thus, the standard output path corresponding to the standard output descriptor is closed. In another alternative embodiment, step S300 may close file descriptor 1 and close file descriptor 2. In another alternative embodiment, step S300 may close file descriptors 0, 1, and 2.
S400, redirecting a file path corresponding to the file descriptor to a target log output path;
after the file descriptor is closed in step S300, the present application may modify a file path corresponding to the closed file descriptor to perform file path redirection.
The target log output path may be a network path of the 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 alternative embodiment, the target log output path is a network path of the debugging device, i.e. the electronic device is a debugging device.
Specifically, the log is a virtual file simulated by the system, and although the log is a virtual file, the log still has a path. Therefore, after the file path corresponding to the file descriptor is redirected to the target log output path, the log can be output to the electronic device.
The target log output path may be a Telnet login path or an SSH login path.
The Telnet login path is a login path of a network service program Telnet.
S500, opening a file descriptor;
it will be appreciated that the path can be reused after opening the previously closed file descriptor, and the redirected file path of step S400 can take effect.
S600, restoring the stored context on the embedded equipment and releasing the freezing of the target application program.
Since the application has redirected the file path corresponding to the file descriptor to the target log output path, the log of the application program is sent to the electronic device through the target log output path after the application program resumes execution.
When the embedded device needs to be locally debugged, the debugging device of the application can be located locally in the embedded device. After the debugging device is connected to the embedded device through the network interface in a communication manner, the debugging device may perform the processing from step S100 to step S600. When the target log output path is the network path of the debugging equipment, the log in the embedded equipment is output to the debugging equipment through the network interface. Under the condition, the log does not need to be checked through the UART, and the problem that the equipment is required to be disassembled to connect the physical cable when the log is checked through the UART is avoided. Therefore, when the scheme of the application is applied to the process of local debugging, the equipment does not need to be disassembled to connect the physical cable, and the method is convenient and fast.
When the embedded device needs to be remotely debugged, the debugging device of the application can be located at the far end of the embedded device. After the debugging device is connected to the embedded device through the network interface in a communication manner, the debugging device may perform the processing from step S100 to step S600. When the target log output path is the network path of the debugging equipment, the log in the embedded equipment is output to the debugging equipment through the network interface. Under the condition, the log can be sent to the remote debugging equipment through the Internet without adding a hardware module locally on the embedded equipment. The method and the device solve the problem that the logs can be forwarded to the remote debugging device only by deploying an additional hardware module when the embedded device is remotely debugged.
Meanwhile, local and remote debugging is realized by deploying software for equipment debugging in the embedded equipment, no additional hardware module is needed, the cost and the time are saved, and no negative interference is caused to the running application program.
Furthermore, because the UART is not used for log transmission, when the UART cannot transmit the log, the application can resume the output of the log of the application without affecting the running of the application, that is: and outputting the log through a network interface.
In an alternative embodiment, the present application may be performed based on MIPS CPU. Among them, MIPS is a RISC (Reduced Instruction Set computer) processor which is popular in the world. If on other CPU platforms, such as: ARM, x86, etc. only need to make the program context saving and restoring part adaptive, which is very convenient.
As shown in fig. 3, a flowchart of another embodiment of a log output redirection method according to the present application is shown, where the method is applied to a debugging device (e.g., the debugging device 001 shown in fig. 1), the debugging device is communicatively connected to an embedded device to be debugged (e.g., the embedded device 002 shown in fig. 1), and the debugging device has a right to remotely control the embedded device. The method can comprise the following steps:
s001, obtaining identification information of a target application program;
the identifier of the target application may be an id (identity document) of the target application. Here, the chinese name of the ID may be an identification number. It should be noted that the identification information may be received by the debugging device from other devices, modules, or apparatuses, and the source of the identification information is not limited in this embodiment.
And S101, freezing the target application program running on the embedded equipment according to the identification information.
Step S101 is a specific implementation manner of step S100 in the method shown in fig. 2.
S200, saving the context of the target application program;
s300, closing a file descriptor related to the target application program;
s400, redirecting a file path corresponding to the file descriptor to a target log output path;
s500, opening a file descriptor;
s600, restoring the stored context on the embedded equipment and releasing the freezing of the target application program.
Steps S200 to S600 are already described in the method shown in fig. 2, and are not described again.
In the log output redirection method provided in this embodiment, the identification information is obtained first, and then the steps S101 to S600 are executed for the application program indicated by the identification information, so that the log output redirection operation can be executed for a specific application program.
Corresponding to the method shown in fig. 2, an embodiment of the present application further provides a log output redirection apparatus.
As shown in fig. 4, which illustrates a log output redirection apparatus provided in an embodiment of the present application, where the apparatus 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 a right to remotely control the embedded device, the apparatus may include:
a program freezing unit 100 for freezing a target application program running on the embedded device;
a context saving unit 200 for saving a context of a target application;
a descriptor closing unit 300 for closing a file descriptor related to the target application;
a path redirection unit 400, configured to redirect a file path corresponding to the file descriptor to a target log output path;
a descriptor opening unit 500 for opening a file descriptor;
and a freeze release unit 600, configured to restore the saved context on the embedded device and release the freezing of the target application program.
In an alternative embodiment, the program freezing unit 100 is specifically configured to:
and intercepting the call of the system to the Sleep function of the target application program by using a system call function Linux ptrace to freeze the target application program.
Wherein the target application runs on the embedded device.
In an alternative embodiment, the program freezing unit 100 is specifically configured to:
and monitoring the calling of the Sleep function of the target application program by using a system calling function Linux ptrace, and if the calling is monitored, intercepting and capturing calling parameters of the Sleep function transmitted to the target application program by the system to freeze the target application program.
In an alternative embodiment, the apparatus shown in fig. 4 further comprises: an identification obtaining unit configured to obtain identification information of a target application program running on the embedded device before the program freezing unit 100 freezes the target application program;
the program freezing unit 100 is specifically configured to: and freezing the target application program running on the embedded equipment according to the identification information.
In an optional embodiment, the debugging device is provided with a client application program for implementing remote control, the embedded device is provided with a server application program corresponding to the client application program, and the client application program is in communication connection with the server application program.
When the embedded device needs to be locally debugged, the debugging device of the application can be located locally in the embedded device. After the debugging equipment is in communication connection with the embedded equipment through the network interface, the debugging equipment can perform the processing. When the target output path is the network path of the debugging equipment, the log in the embedded equipment is output to the debugging equipment through the network interface. Under the condition, the log does not need to be checked through the UART, and the problem that the equipment is required to be disassembled to connect the physical cable when the log is checked through the UART is avoided. Therefore, when the scheme of the application is applied to the process of local debugging, the equipment does not need to be disassembled to connect the physical cable, and the method is convenient and fast.
When the embedded device needs to be remotely debugged, the debugging device of the application can be located at the far end of the embedded device. After the debugging equipment is in communication connection with the embedded equipment through the network interface, the debugging equipment can perform the processing. When the target output path is the network path of the debugging equipment, the log in the embedded equipment is output to the debugging equipment through the network interface. Under the condition, the log can be sent to the remote debugging equipment through the Internet without adding a hardware module locally on the embedded equipment. The method and the device solve the problem that the logs can be forwarded to the remote debugging device only by deploying an additional hardware module when the embedded device is remotely debugged.
In this embodiment, specific processes of the program freezing unit 100, the context saving unit 200, the descriptor closing unit 300, the path redirecting unit 400, the descriptor opening unit 500, and the freeze releasing unit 600 and technical effects thereof may respectively refer to the related descriptions of the embodiments from step S100 to step S600 in the corresponding embodiment of fig. 2, and are not described herein again.
It should be noted that the log output redirection apparatus may be a chip, a component or a module, the log output redirection apparatus 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, the freeze releasing unit 600, and the like are all stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions.
The processor may include a kernel, which calls the corresponding program unit from the memory. The kernel can set one or more, and the log output redirection is carried out by adjusting the kernel parameters.
The memory may include volatile memory in a computer readable medium, Random Access Memory (RAM) and/or nonvolatile memory such as Read Only Memory (ROM) or flash memory (flash RAM), and the memory includes at least one memory chip.
As shown in fig. 5, the debugging apparatus 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. Wherein the processor 701 and the memory 702 are connected to each other via a communication bus 706. A communication interface 703, an input unit 704 and an output unit 705 are also connected to the communication bus 706.
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 the embedded device, and the communication interface 703 is also used to send commands to the embedded device.
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), an off-the-shelf programmable gate array (FPGA) or other programmable logic device.
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, an application program required by at least one function (such as an application program freezing function, an output path redirection function, and the like), and the like; the storage data area may store data created according to the use of the computer, such as a log, identification information of an application program, and the like.
Further, the memory 702 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device or other volatile solid state storage device.
The processor 701 may call a program stored in the memory 702, and in particular, the processor 701 may execute a log output redirection method as shown in any one of the embodiments of fig. 1 to 2.
The memory 702 is used for storing one or more programs, the program may include program codes, the program codes include computer operation instructions, and in this embodiment, the memory 702 stores at least the programs for implementing the following functions:
freezing a target application program running on the embedded equipment;
saving a context of the target application;
closing a file descriptor associated with the target application;
redirecting a file path corresponding to the file descriptor to a target log output path;
opening a file descriptor;
and restoring the saved context on the embedded equipment and releasing the freezing of the target application program.
The present application may further include an input unit 704, and the input unit 704 may include at least one of a touch sensing unit sensing a touch event on the touch display panel, a keyboard, a mouse, a camera, a microphone, and the like.
The output unit 705 may include: at least one of a display, a speaker, a vibration mechanism, a light, and the like. The display may comprise a display panel, such as a touch display panel or the like. 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), or the like. The vibration mechanism can enable the debugging equipment 001 to generate displacement when in work, and in one possible implementation mode, the vibration mechanism comprises a motor and an eccentric vibrator, and the motor drives the eccentric vibrator to rotate so as to generate vibration. The brightness and/or color of the lamp can be adjusted, in a possible implementation manner, different information can be embodied through at least one of the on-off, brightness and color of the lamp, for example, the alarm information can be embodied through red light emitted by the lamp.
Of course, the structure of the debugging device 001 shown in fig. 5 does not constitute a limitation to the debugging device in the embodiment of the present application, and in practical applications, the debugging device may include more or less components than those shown in fig. 5, or some components in combination.
The present application provides a computer readable medium, on which a computer program is stored, where the program, when executed by a processor, implements the log output redirection method described in the above method embodiments.
The embodiment of the present application provides a processor, where the processor is configured to execute a program, where the program executes to implement the log output redirection method described in the foregoing method embodiments.
The present application also provides a computer program product, which when executed on a data processing apparatus, causes the data processing apparatus to implement the log output redirection method described in the above method embodiments.
The debugging device, the processor, the computer readable medium, or the computer program product provided in the above embodiments of the present application may all be configured to execute the corresponding method provided above, and therefore, beneficial effects achieved by the debugging device, the processor, the computer readable medium, or the computer program product may refer to beneficial effects in the corresponding method provided above, and are not described herein again.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include forms of volatile memory in a computer readable medium, Random Access Memory (RAM) and/or non-volatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). The memory is an example of a computer-readable medium.
Computer-readable media, which include both non-transitory and non-transitory, removable and non-removable media, may implement the information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, 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 disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The above description is only for the purpose of illustrating the preferred embodiments of the present application and the technical principles applied, and is not intended to limit the present application. Various modifications and changes may occur to those skilled in the art. The scope of the invention according to the present application is not limited to the specific combinations of the above-described features, and may also cover other embodiments in which the above-described features or their equivalents are arbitrarily combined without departing from the spirit of the invention. For example, the above features may be replaced with (but not limited to) features having similar functions disclosed in the present application.

Claims (10)

1. A log output redirection 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 of remotely controlling the embedded device, and the method comprises the following steps:
freezing a target application program running on the embedded equipment;
saving a context of the target application;
closing a file descriptor associated with the target application;
redirecting the file path corresponding to the file descriptor to a target log output path;
opening the file descriptor;
and restoring the saved context on the embedded equipment, and releasing the freezing of the target application program.
2. The method of claim 1, wherein freezing the target application running on the embedded device comprises:
and intercepting the call of the system to the Sleep function of the target application program by using a system call function Linux ptrace to freeze the target application program.
3. The method of claim 2, wherein intercepting a call by a system call function Linux ptrace to a Sleep function of the target application to freeze the target application comprises:
and calling the Sleep function of the target application program by using a system calling function Linux ptrace monitoring system, and if the system calling function Linux ptrace monitoring system is monitored, intercepting and capturing a calling parameter of the Sleep function transmitted to the target application program by the system to freeze the target application program.
4. The method of any of claims 1-3, wherein prior to the freezing a target application running on the embedded device, the method further comprises:
obtaining identification information of the target application program;
the freezing of the target application program running on the embedded device comprises the following steps: and freezing the target application program running on the embedded equipment according to the identification information.
5. The method according to any one of claims 1 to 3, wherein the debugging device is provided with a client application program for realizing remote control, the embedded device is provided with a server application program corresponding to the client application program, and the client application program is in communication connection with the server application program.
6. The log output redirection device is applied to debugging equipment, the debugging equipment is in communication connection with embedded equipment to be debugged, and the debugging equipment has the authority of remotely controlling the embedded equipment, and the device comprises:
the program freezing unit is used for freezing a target application program running on the embedded equipment;
a context saving unit, configured to save a context of the target application;
a descriptor closing unit for closing a file descriptor related to the target application;
the path redirection unit is used for redirecting the file path corresponding to the file descriptor to a target log output path;
a descriptor opening unit for opening the file descriptor;
and the freeze removing unit is used for recovering the saved context on the embedded equipment and removing the freeze of the target application program.
7. The apparatus according to claim 6, wherein the program freezing unit is specifically configured to:
and intercepting the call of the system to the Sleep function of the target application program by using a system call function Linux ptrace to freeze the target application program.
8. A computer-readable medium, on which a computer program is stored, wherein the program, when executed by a processor, implements the log output redirection method of any of claims 1 to 5.
9. A processor for running a program, wherein the program when running implements the log output redirection method of any of claims 1 to 5.
10. A commissioning device comprising:
one or more processors;
a storage device having one or more programs stored thereon;
the one or more programs, when executed by the one or more processors, cause the one or more processors to implement the log output redirection method of any of claims 1 to 5.
CN201911111998.1A 2019-11-14 2019-11-14 Log output redirection method and device and related equipment Pending CN112799902A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911111998.1A CN112799902A (en) 2019-11-14 2019-11-14 Log output redirection method and device and related equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911111998.1A CN112799902A (en) 2019-11-14 2019-11-14 Log output redirection method and device and related equipment

Publications (1)

Publication Number Publication Date
CN112799902A true CN112799902A (en) 2021-05-14

Family

ID=75803610

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911111998.1A Pending CN112799902A (en) 2019-11-14 2019-11-14 Log output redirection method and device and related equipment

Country Status (1)

Country Link
CN (1) CN112799902A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102473089A (en) * 2009-08-27 2012-05-23 惠普发展公司有限责任合伙企业 File system for dual operating systems
US20130081017A1 (en) * 2011-09-26 2013-03-28 International Business Machines Corporation Dynamically redirecting a file descriptor
CN105573910A (en) * 2015-12-11 2016-05-11 北京元心科技有限公司 Application program debugging method of protected system and intelligent terminal
CN109491759A (en) * 2018-10-26 2019-03-19 深圳康佳电子科技有限公司 Process debugged method, device and computer equipment based on Virtual File System
CN109660399A (en) * 2018-12-24 2019-04-19 苏州思必驰信息科技有限公司 A kind of method and system of remote debugging

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102473089A (en) * 2009-08-27 2012-05-23 惠普发展公司有限责任合伙企业 File system for dual operating systems
US20130081017A1 (en) * 2011-09-26 2013-03-28 International Business Machines Corporation Dynamically redirecting a file descriptor
CN105573910A (en) * 2015-12-11 2016-05-11 北京元心科技有限公司 Application program debugging method of protected system and intelligent terminal
CN109491759A (en) * 2018-10-26 2019-03-19 深圳康佳电子科技有限公司 Process debugged method, device and computer equipment based on Virtual File System
CN109660399A (en) * 2018-12-24 2019-04-19 苏州思必驰信息科技有限公司 A kind of method and system of remote debugging

Similar Documents

Publication Publication Date Title
US10264025B2 (en) Security policy generation for virtualization, bare-metal server, and cloud computing environments
US10776144B2 (en) Address space management with respect to a coherent accelerator processor interface architecture
US20130198840A1 (en) Systems, methods and computer programs providing impact mitigation of cyber-security failures
CN114253793A (en) Dynamic tracking control
US10833955B2 (en) Dynamic delivery of software functions
CN103530167A (en) Virtual machine memory data migration method and relevant device and cluster system
US10972586B2 (en) Reusable message flow between applications of a message broker integrated systems environment
US8793688B1 (en) Systems and methods for double hulled virtualization operations
US10666715B2 (en) Incident management for complex information technology platforms
US8938712B2 (en) Cross-platform virtual machine and method
US10223218B2 (en) Disaster recovery of managed systems
US20180239612A1 (en) Running a kernel-dependent application in a container
US20190286794A1 (en) Using blockchain for flexible application licensing
US10467078B2 (en) Crash dump extraction of guest failure
US9755922B2 (en) Minimized installation of point of presence software agents by use of pre-installed browser
CN108920379A (en) The method and apparatus for capturing lua code exception
US20160050115A1 (en) Networking component management in host computing systems in a virtual computing environment
CN110673898B (en) Equipment management method, first equipment and interaction system
US20140089946A1 (en) Application management of a processor performance monitor
US11656888B2 (en) Performing an application snapshot using process virtual machine resources
US20230021216A1 (en) Systems and methods for deploying secure edge platforms
CN112799902A (en) Log output redirection method and device and related equipment
US9384120B2 (en) Testing of transaction tracking software
US9772877B2 (en) Managing I/O operations in a shared file system
US11487776B2 (en) Managing extract-transform-load operations

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