WO2017050287A1 - 一种调试方法、多核处理器和调试设备 - Google Patents

一种调试方法、多核处理器和调试设备 Download PDF

Info

Publication number
WO2017050287A1
WO2017050287A1 PCT/CN2016/099996 CN2016099996W WO2017050287A1 WO 2017050287 A1 WO2017050287 A1 WO 2017050287A1 CN 2016099996 W CN2016099996 W CN 2016099996W WO 2017050287 A1 WO2017050287 A1 WO 2017050287A1
Authority
WO
WIPO (PCT)
Prior art keywords
core
preset event
function
debugging
stop
Prior art date
Application number
PCT/CN2016/099996
Other languages
English (en)
French (fr)
Inventor
王名发
喻钢
王海川
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Priority to BR112018005588-3A priority Critical patent/BR112018005588B1/pt
Priority to KR1020187010961A priority patent/KR102119585B1/ko
Priority to EP16848168.7A priority patent/EP3352083B1/en
Publication of WO2017050287A1 publication Critical patent/WO2017050287A1/zh
Priority to US15/936,030 priority patent/US10503629B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/22Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing
    • G06F11/2205Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing using arrangements specific to the hardware being tested
    • G06F11/2236Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing using arrangements specific to the hardware being tested to test CPU or processors
    • G06F11/2242Detection or location of defective computer hardware by testing during standby operation or during idle time, e.g. start-up testing using arrangements specific to the hardware being tested to test CPU or processors in multi-processor systems, e.g. one processor becoming the test master
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3648Software debugging using additional hardware
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3648Software debugging using additional hardware
    • G06F11/3656Software debugging using additional hardware using a specific debug interface
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/545Interprogram communication where tasks reside in different layers, e.g. user- and kernel-space
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt

Definitions

  • the embodiments of the present invention relate to the field of computer technologies, and in particular, to a debugging method, a multi-core processor, and a debugging device.
  • Program debugging is a process of correcting syntax errors and logic errors by testing the completed computer program before it is actually run, using manual or compiled programs. This is an essential step in ensuring the correctness of the computer information system. Therefore, the completed computer program must be sent to the computer for debugging.
  • kernel-mode code code that runs in user space
  • user-mode code code that runs in user space
  • different debugging platforms are required for debugging kernel mode code and user mode code.
  • target machine described below refers to the physical host that is run by the debug code
  • the host machine refers to the physical host that the debugger runs.
  • debugging user-mode code you need to run the debugger on the operating system of the target machine for local debugging.
  • debugging the user-mode code you need to implant the process tracking module in the operating system of the target machine.
  • the embodiment of the invention provides a debugging method, a multi-core processor and a debugging device, which are used for debugging the kernel state code and the user state code on the same debugging platform.
  • an embodiment of the present invention provides a debugging method, which is applied to a target machine in a remote debugging system, where the target device includes a multi-core processor, and the debugging method includes:
  • the core A of the multi-core processor starts to stop running after executing the preset event processing routine, and sends a stop operation signal to other cores during the stop operation, and the stop operation signal is used to indicate the other
  • the core stops running, and the other cores are all cores located in the multi-core processor and belonging to the same logical grouping as the core A, and the preset event is processing of a kernel function code processing function or user mode code. function;
  • the core A After receiving the first release stop instruction and resume running, the core A executes a debug information collection function to collect debug information of the preset event, and stops running after executing the debug information collection function; the first release The stop instruction is sent by the debugging device in the remote debugging system after determining that the core A stops running and causes the core A to stop running for reasons other than the preset event;
  • the core A After receiving the second release stop instruction and resume operation, the core A sends a resume operation instruction to the other core, the resume operation instruction is used to notify the other core to resume operation; and the second release stop instruction is the
  • the debugging device sends the preset suspension breakpoint to the preset event operation object according to the debugging information of the preset event;
  • the core A hits the suspension breakpoint in the process of running the preset event operation object, thereby entering a debugging state.
  • the debug information collection function includes a debug interface function, and a header of the debug interface function is provided with a first debug exception instruction, where the first debug exception instruction is used to indicate that the core A stops running;
  • the core A After the execution of the preset event processing routine, the core A starts to stop running, and sends a stop operation signal to other cores during the process of stopping the operation, including:
  • the core A executes the preset event processing routine
  • the first debug exception instruction located at the debug interface function header is started, and is executed in the process of executing the first debug exception instruction.
  • the other core sends the stop operation signal.
  • the debug information collection function further includes a function function associated with the preset event, and a tail of the debug interface function is further provided with a second debug exception instruction, where the second debug exception instruction is used to indicate the core A stops running;
  • the core A executes the debugging information collection function to collect the debugging information of the preset event, and stops running after the debugging information collecting function is executed, which specifically includes:
  • the core A performs a function function associated with the preset event to collect debug information of the preset event, and then executes the second debug exception instruction located at the end of the debug interface function.
  • the function function associated with the preset event is located in a kernel debug stub, and the kernel debug stub is pre-implanted in the target operating system.
  • the processing function of the kernel mode code is a load function of the kernel module
  • the processing function of the user mode code is a process creation function, a process switching function, a process blocking function, a process wake function, a thread creation function, a thread switching function, a thread blocking function, or a thread wake function.
  • the preset event operation object is a kernel module
  • the preset event operation object is a process
  • the preset event operation object is a thread.
  • the debugging information of the preset event includes an identifier of the preset event operation object
  • the debug information of the preset event further includes a load address of the preset event operation object.
  • the multi-core processor is integrated in System level chip SOC;
  • the core A sends a stop operation signal to the other cores, where the stop operation signal is used to indicate that the other cores stop running, and specifically includes:
  • the core A sends a stop operation signal to the other cores through a hardware cross trigger network of the SOC, where the stop operation signal is used to indicate that the other cores stop running;
  • the core A sends a recovery operation instruction to the other cores, where the recovery operation instruction is used to notify the other cores to resume operation, which specifically includes:
  • the core A sends a recovery operation finger to the other core through a hardware cross trigger network of the SOC
  • the resume operation instruction is used to notify the other cores to resume operation.
  • an embodiment of the present invention provides a debugging method, which is executed by a debugging device deployed in a host, where the host is located in a remote debugging system, and the method includes:
  • the core A belongs to a multi-core processor of the target machine in the remote debugging system
  • the debugging device acquires debugging information of the preset event, and sets a preset suspension breakpoint according to the debugging information of the preset event, in a case that the cause of the stop operation of the core A is a preset event.
  • the preset event is a processing function of a kernel mode code or a processing function of a user state code;
  • the preset event operation object is a kernel state code or a user state code;
  • the debugging device instructs the core A to resume operation, so that the core A hits the suspension breakpoint during the operation of the preset event operation object, thereby causing the core A to enter a debugging state.
  • the method further includes:
  • the debugging device instructs the core A to resume operation to collect the debug information of the preset event.
  • the function of the kernel mode code is a load function of the kernel module
  • the functions of the user mode code are a process creation function, a process switching function, a process blocking function, a process wakeup function, a thread creation function, a thread switching function, a thread blocking function, or a thread wakeup function.
  • the debugging information of the preset event includes a loading address of the preset event operation object
  • the debugging device acquires the debugging information of the preset event, and the setting the preset suspension breakpoint to the preset event operation object according to the debugging information of the preset event, specifically including:
  • the debugging device acquires a loading address of the preset event operation object, and sets a preset suspension breakpoint to a destination address of the preset event operation object according to the loading address of the preset event operation object.
  • the preset event is a process switching function, a process blocking function, a process wake-up function, a line
  • the debugging information of the preset event includes an identifier of the preset event operation object
  • the debugging device acquires the debugging information of the preset event, and the setting the preset suspension breakpoint to the preset event operation object according to the debugging information of the preset event, specifically including:
  • the debugging device acquires an identifier of the preset event operation object, determines a loading address of the preset event operation object according to the identifier of the preset event operation object, and operates a loading address of the object according to the preset event
  • the preset suspension breakpoint is set to the destination address of the preset event operation object.
  • the storage space of the host machine pre-stores the correspondence between the identifier of the preset event operation object and the load address of the preset event operation object;
  • the debugging device includes a debugger And debugging agents
  • the debugging device After the debugging device determines that the core A stops running, determine the cause of the stop of the operation of the core A. In the case that the cause of the stop operation of the core A is a preset event, the debugging device acquires the pre- Setting the debugging information of the event, and setting the preset suspension breakpoint to the preset event operation object according to the debugging information of the preset event, specifically including:
  • the debugging agent polls the core A to stop running, determine the cause of the stop of the operation of the core A. In the case that the cause of the stop operation of the core A is the preset event, the debugging agent Reporting the second message to the debugger, where the second message includes the core A stops running and the identifier of the preset event;
  • the debugger After receiving the second message, the debugger acquires debugging information of the preset event according to the identifier of the preset event, and sets a preset suspension breakpoint to the preset according to the debugging information of the preset event.
  • Predetermined event operation object
  • the debugging device instructs the core A to resume operation, which specifically includes:
  • the debugger instructs the debug agent to send a second release stop command to the core A, the second The release stop command is used to instruct the core A to resume operation.
  • the debugging device Determining, by the debugging device, that the core A stops running, determining a cause that causes the core A to stop running, and in the case that the reason that the core A stops running is a cause other than a preset event, the debugging device Instructing the core A to resume operation to collect debugging information of the preset event, specifically including:
  • the debug agent After the debugging agent polls the core A to stop running, determining the cause of the stop of the operation of the core A, in the case that the cause of the stop operation of the core A is other than the preset event, The debug agent sends a first release stop instruction to the core A, and the first release stop instruction is used to instruct the core A to resume operation to collect debug information of the preset event.
  • the debugging device includes a debugger And debugging agents
  • the debugging device Determining, by the debugging device, that the core A stops running, determining a cause that causes the core A to stop running, and in the case that the reason that the core A stops running is a cause other than a preset event, the debugging device Instructing the core A to resume operation to collect debugging information of the preset event, specifically including:
  • the debugging agent polls the core A to stop running, determining the cause of the stop of the operation of the core A, in the case that the cause of the stop operation of the core A is other than the preset event, Reporting the first message to the debugger, where the first message includes the core A stopping running and a default identifier,
  • the debugger instructs the debugging agent to send a first release stop instruction to the core A, where the first release stop instruction is used to instruct the core A to resume operation to collect the pre- Set the debugging information of the event.
  • the preset event operation object is a kernel module
  • the preset event operation object is a process
  • the preset event operation object is a thread.
  • an embodiment of the present invention provides a multi-core processor, which is applied to a remote debugging system.
  • the multi-core processor includes a core A, other cores, and input ports, and the other cores are all cores located in the multi-core processor and belonging to the same logical group as the core A, wherein:
  • the core A is used to start the stop operation after executing the preset event processing routine, and send a stop operation signal to the other cores during the stop operation, the stop operation signal is used to indicate that the other cores stop running.
  • the preset event is a processing function of a kernel mode code or a processing function of a user mode code;
  • the input port is configured to receive a first release stop command, and forward the first release stop command to the core A, where the first release stop command is determined by the debugging device in the remote debugging system
  • the reason that the core A stops running and causes the core A to stop running is sent after the cause other than the preset event;
  • the core A is further configured to: after receiving the first release stop instruction and resume running, execute a debug information collection function to collect debug information of the preset event, and stop running after executing the debug information collection function. ;
  • the input port is further configured to receive a second release stop instruction, and forward the second release stop instruction to the core A, where the second release stop instruction is a debugging of the debugging device according to the preset event
  • the information is sent after the preset breakpoint is set to the preset event operation object;
  • the core A is further configured to send a resume operation instruction to the other core after receiving the second release stop instruction and resume operation, the resume operation instruction is used to notify the other core to resume operation;
  • the hanging breakpoint is hit during the running of the preset event operating object, thereby entering a debugging state.
  • the debug information collection function includes a debug interface function, and a header of the debug interface function is provided with a first debug exception instruction, where the first debug exception instruction is used to indicate that the core A stops running;
  • the core A is specifically configured to start executing the first debug exception instruction located at the debug interface function header after executing the preset event processing routine, and executing the first debug exception instruction
  • the stop operation signal is sent to the other cores.
  • the debug information collection function further includes a function function associated with the preset event, and a tail of the debug interface function is further provided with a second debug exception instruction, where the second debug exception instruction is used to indicate the core A stops running;
  • the core A is specifically configured to perform a function function associated with the preset event to collect the preset Debug information for the event, and then executing the second debug exception instruction at the end of the debug interface function.
  • the function function associated with the preset event is located in a kernel debug stub, and the kernel debug stub is pre-implanted in the target operating system.
  • the processing function of the kernel mode code is a load function of the kernel module
  • the processing function of the user mode code is a process creation function, a process switching function, a process blocking function, a process wake function, a thread creation function, a thread switching function, a thread blocking function, or a thread wake function.
  • the preset event operation object is a kernel module
  • the preset event operation object is a process
  • the preset event operation object is a thread.
  • the debugging information of the preset event includes an identifier of the preset event operation object
  • the debug information of the preset event further includes a load address of the preset event operation object.
  • the multi-core processor is integrated in System level chip SOC;
  • the core A is specifically configured to send, by using a hardware cross-trigger network of the SOC, a stop operation signal to the other core, where the stop operation signal is used to indicate that the other core stops running;
  • the core A is specifically configured to send a recovery operation instruction to the other core by using a hardware cross trigger network of the SOC, where the recovery operation instruction is used to notify the other core to resume operation.
  • an embodiment of the present invention provides a debugging apparatus, where the debugging apparatus is deployed in a host of a remote debugging system, where the debugging apparatus includes a debugging unit and a receiving unit.
  • the receiving unit is configured to receive a message for instructing the core A to stop running, and forward the message for instructing the core A to stop running to the debugging unit; wherein the target machine located in the remote debugging system Including a multi-core processor, the multi-core processor includes the core A;
  • the debugging unit is configured to determine, after determining that the core A stops running, a cause that causes the core A to stop running;
  • the debugging unit is further configured to acquire debugging information of the preset event, and perform a preset suspension according to the debugging information of the preset event, in a case that the cause of the stop operation of the core A is a preset event.
  • Setting a breakpoint to the preset event operation object; the preset event is a processing function of a kernel mode code or a processing function of a user state code;
  • the preset event operation object is a kernel state code or a user state code;
  • the debugging unit is further configured to instruct the core A to resume operation, so that the core A hits the suspension breakpoint in the process of running the preset event operation object, thereby causing the core A to enter a debugging state. .
  • the debugging unit is further configured to instruct the core A to resume operation to collect debugging information of the preset event.
  • the function of the kernel mode code is a load function of the kernel module
  • the functions of the user mode code are a process creation function, a process switching function, a process blocking function, a process wakeup function, a thread creation function, a thread switching function, a thread blocking function, or a thread wakeup function.
  • the debugging information of the preset event includes a loading address of the preset event operation object
  • the debugging unit is configured to acquire a loading address of the preset event operation object, and set a preset suspension breakpoint to a destination address of the preset event operation object according to the loading address of the preset event operation object.
  • the preset event is a process switching function, a process blocking function, a process wake-up function, a line
  • the debugging information of the preset event includes an identifier of the preset event operation object
  • the debugging unit is configured to acquire an identifier of the preset event operation object, determine a loading address of the preset event operation object according to the identifier of the preset event operation object, and operate the object according to the preset event.
  • the load address sets a preset suspension breakpoint to the destination address of the preset event operation object.
  • the storage space of the host machine pre-stores the correspondence between the identifier of the preset event operation object and the load address of the preset event operation object;
  • the debugging unit is configured to acquire, according to the identifier of the preset event operation object and the corresponding relationship, a loading address of the preset event operation object from a storage space of the host machine.
  • the debugging unit includes a debugger and a debugging agent.
  • the debugging agent is specifically configured to determine, after determining that the core A stops running, a cause that causes the core A to stop running, and in a case that the cause that the core A stops running is the preset event, The second message is reported to the debugger, where the second message includes the core A stops running and the identifier of the preset event;
  • the debugger is configured to: after receiving the second message, acquire debugging information of the preset event according to the identifier of the preset event, and set a preset suspension breakpoint according to the debugging information of the preset event. Set to the preset event operation object;
  • the debugger is specifically configured to instruct the debug agent to send a second release stop instruction to the core A, and the second release stop instruction is used to instruct the core A to resume operation.
  • the debugging agent is specifically configured to determine, after determining that the core A stops running, a cause that causes the core A to stop running, and the reason that causes the core A to stop running is a cause other than the preset event
  • the debugging agent is specifically configured to send a first release stop instruction to the core A, where the first release stop instruction is used to instruct the core A to resume operation to collect debugging information of the preset event.
  • the debugging device also includes a debugger and a debugging agent.
  • the debugging agent is specifically configured to determine, after determining that the core A stops running, a cause that causes the core A to stop running, and the reason that causes the core A to stop running is a cause other than the preset event
  • the first message is reported to the debugger, where the first message includes the core A stops running and a default identifier.
  • the debugger is specifically configured to: after receiving the first message, instruct the debugging agent to send a first release stop instruction to the core A, where the first release stop instruction is used to instruct the core A to resume operation to collect The debugging information of the preset event.
  • an embodiment of the present invention provides a debugging device, including a processor and a memory.
  • the processor is configured to determine, after determining that the core A stops running, a cause that causes the core A to stop running;
  • a target machine located in the remote debugging system includes a multi-core processor, and the multi-core processor includes the core A ;
  • the processor is further configured to acquire debugging information of the preset event, and perform a pre-set suspension according to the debugging information of the preset event, in a case that the cause of the stop operation of the core A is a preset event.
  • Setting a breakpoint to the preset event operation object; the preset event is a processing function of a kernel mode code or a processing function of a user state code, and the preset event operation object is a kernel state code or a user state code;
  • the memory is configured to store debugging information of the preset event.
  • the processor is further configured to instruct the core A to resume operation, so that the core A hits the suspension breakpoint during running the preset event operation object, thereby causing the core A to enter a debugging state. .
  • the processor is further configured to instruct the core A to resume running to collect debugging information of the preset event, in a case that the reason that the core A stops running is a cause other than the preset event.
  • the function of the kernel mode code is a load function of the kernel module
  • the functions of the user mode code are a process creation function, a process switching function, a process blocking function, a process wakeup function, a thread creation function, a thread switching function, a thread blocking function, or a thread wakeup function.
  • the preset event is a kernel module load function, a process creation function, or a thread creation function.
  • the debugging information of the preset event includes a loading address of the preset event operation object;
  • the processor is specifically configured to acquire a loading address of the preset event operation object, and set a preset suspension breakpoint to a destination address of the preset event operation object according to the loading address of the preset event operation object.
  • the debugging information of the preset event includes The identifier of the preset event operation object;
  • the processor is specifically configured to acquire an identifier of the preset event operation object, determine a loading address of the preset event operation object according to the identifier of the preset event operation object, and operate the object according to the preset event.
  • the load address sets a preset suspension breakpoint to the destination address of the preset event operation object.
  • the storage space of the host machine pre-stores the correspondence between the identifier of the preset event operation object and the load address of the preset event operation object;
  • the processor is specifically configured to acquire, according to the identifier of the preset event operation object and the corresponding relationship, a loading address of the preset event operation object from a storage space of the host.
  • the embodiment of the present invention provides a debugging method, by adding a debugging interface function at the end of a preset event running on the core A, the debugging interface function is associated with the type of the preset event by calling the kernel debugging pile.
  • a function function obtaining debugging information of the preset event; the debugger sets a preset suspension breakpoint to a destination address of the preset event operation object according to the debugging information of the preset event, and the core A runs the preset in a subsequent manner During the operation of the event object, the suspension breakpoint will be hit and the debug state will be entered.
  • the preset event is a processing function of the kernel mode code or a processing function of the user mode code
  • the technical solution provided by the embodiment of the present invention can put the kernel state code and the user state code in the same debugging platform. Implement debugging.
  • FIG. 1 is a schematic structural diagram of a remote debugging system according to an embodiment of the present invention.
  • FIG. 2 is a schematic structural diagram of another remote debugging system according to an embodiment of the present invention.
  • FIG. 3 is a schematic flowchart diagram of a debugging method according to an embodiment of the present disclosure
  • FIG. 4 is a schematic flowchart of another debugging method according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of a target device according to an embodiment of the present disclosure.
  • Figure 6.1 is a schematic structural diagram of a data header and a data body according to an embodiment of the present invention.
  • 6.2 is a schematic structural diagram of another data header and a data body according to an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a multi-core processor according to an embodiment of the present disclosure.
  • FIG. 8 is a schematic structural diagram of a debugging apparatus according to an embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of a debugging device according to an embodiment of the present invention.
  • the embodiment of the present invention provides a debugging method, which is applied to the remote debugging system shown in FIG. 1.
  • the remote debugging system includes a target machine and a host machine, and the target machine includes a multi-core processor, and the debugging device is deployed in The host machine; wherein, the target machine and the host machine are different physical hosts, and the communication connection between the target machine and the host machine.
  • the multi-core processor may be a homogeneous multi-core processor or a heterogeneous multi-core processor.
  • the core A may be any one of the multi-core processors of the target machine, and does not specifically refer to which of the multi-core processors of the target machine.
  • the debugging method provided by the embodiment of the present invention is a cross-commissioning method, which is a system-level debugging method. Referring to FIG. 3, the debugging method provided by the embodiment of the present invention includes the following steps:
  • the core A starts to stop running after executing the preset event processing routine, and sends a stop operation signal to the other cores during the stop operation, where the stop operation signal is used to refer to the other core stops.
  • Running the other cores are all cores located in the multi-core processor and belonging to the same logical grouping as the core A, and the preset event is a processing function of a kernel mode code or a processing function of a user state code;
  • a debug interface function is added at the end of the preset event, and the debug interface function is located outside the preset event, and is not part of the preset event.
  • the first debugging exception instruction is set in the header of the debugging interface function, and the core A stops running after executing the first debugging abnormal instruction;
  • the second debugging exception instruction is also set in the tail of the debugging interface function, and the core A is executed.
  • the second debug exception command will also stop running.
  • the core A starts to stop running after executing the preset event processing routine, and sends a stop operation signal to other cores during the process of stopping the operation, including: the core A executes the preset event processing example.
  • the first debug exception instruction located at the debug interface function header is executed after the process, and the stop run signal is sent to the other cores during execution of the first debug exception instruction.
  • the core A executes a first debug exception instruction to go through a period of time, and the core A first starts executing the first debug exception instruction, and then at some time before executing the first debug exception instruction, Sending a stop operation signal to the other cores, and after transmitting the stop operation signal to the other cores, continuing to execute the first debug exception instruction, and after executing the first debug exception command, the core A stops running .
  • the cores included in the same logical grouping are located in the same multi-core processor, and the logical grouping is based on experience, and the debugging personnel divides the multiple cores having the business association relationship into the same logical grouping.
  • Core A, Core B, Core C, and Core D are in the same logical grouping.
  • the core A sends a stop operation signal to other cores, specifically: the core A sends a stop operation signal to the core B, the core C, and the core D.
  • the core A transmits a stop operation signal to other cores,
  • the stop operation signal is used to indicate that the other cores are stopped.
  • the core A sends a stop operation signal to the other cores through the hardware cross trigger network of the SOC, where the stop operation signal is used to indicate that the other cores are stopped. run.
  • the resume operation instruction is sent in the form of a broadcast.
  • kernel-mode code kernel-space code
  • code that runs in user space is called user-mode code.
  • the processing function of the kernel state code is loading of a kernel module
  • the function of the user state code is a process creation function, a process switching function, a process blocking function, a process wakeup function, a thread creation function, a thread switching function, a thread blocking function, or a thread wakeup function.
  • AMP asymmetric multi-processing
  • SMP Symmetric Multi-Processing
  • the multi-process or multi-thread running on the homogeneous multi-core processor can achieve synchronous debugging by using the technical solutions provided by the embodiments of the present invention.
  • the debugging device After the debugging apparatus determines that the core A stops running, determine a cause that causes the core A to stop running. In a case where the cause of stopping the operation of the core A is other than the preset event, The debugging device sends a first release stop instruction to the core A, where the first release stop instruction is used to instruct the core A to resume operation;
  • step S101 the core A starts to stop running after executing the preset event processing routine, and notifies other cores to stop running; in step S102, the debugging device sends a first release stop instruction to the core A.
  • the purpose of the scheme is to achieve synchronous debugging. Referring to Figure 1, core A, core B, core C, and core D are located in the same logical grouping, and code running on at least one of core B, core C, and core D (such as core B) and code running on core A.
  • the design of the scheme also fully considers the time when the stop signal of the nuclear A is transmitted to other cores, and the time when the nuclear A stops running, specifically after the nuclear A stops running. During the period of stopping the operation, the stop operation command is sent to other cores, so that the core A and other cores are stopped synchronously, thereby achieving relatively accurate synchronous debugging.
  • the preset storage space is used to store a data header.
  • the data header includes a first default information and an address of the data body.
  • the first default information may be empty; the data body includes second default information.
  • the second default information can also be empty.
  • the data header includes the first default information and the position of the data body, and the content of the data body is Second default information.
  • the debugging device in S102 determines that the core A stops running, and determines the cause of the stop of the core A.
  • the method includes: after the debugging device polls the core A to stop running, determining, by reading the content of the data header, causing the core A to stop running, since the content of the data header includes the first default information, the debugging device according to the The first default information can determine the cause of the failure of the core A to stop running for reasons other than the preset event.
  • the debugging apparatus includes a debugging agent and a debugger, and the debugging apparatus is applied in the remote debugging system as described in FIG. 2, and the debugging agent and the debugger are required to be explained. It can be located on the same host or on a different host. For example, in Figure 2, the debug agent is located on the first host and the debugger is located on the second host.
  • S102 in FIG. 3 specifically includes:
  • the debugging agent polls that the core A stops running, determine a cause that causes the core A to stop running, and the cause that causes the core A to stop running is a cause other than the preset event.
  • the debug agent reports the first message to the debugger, where the first message includes the core A stopping running and a default identifier;
  • the S202 specifically includes: after the debug agent polls the core A to stop running, it will read through The content of the data header is determined to cause the core A to stop running. Since the content of the data header includes the first default information, the debugging agent can determine, according to the first default information, that the cause of the stop of the core A is a preset event. For reasons other than this, the first message including the core A stop running and the default ID is reported to the debugger.
  • the debugger instructs the debugging agent to send a first release stop instruction to the core A, where the first release stop instruction is used to indicate that the core A resumes operation;
  • the debugging agent sends the first release stop instruction to the core A.
  • S102 in FIG. 3 specifically includes:
  • the debug agent After the debugging agent polls the core A to stop running, determining the cause of the stop of the operation of the core A, in the case that the cause of the stop operation of the core A is other than the preset event, The debug agent sends the first release stop instruction to the core A, and the first release stop instruction is used to instruct the core A to resume operation.
  • the debugging agent no longer reports to the debugger the first message including the stop operation of the core A and the default identifier, but reads the first default information from the data header.
  • the debug agent After determining that the cause of the stop of the core A is a cause other than the preset event, the debug agent sends the first release stop command to the core A.
  • the debug agent sends the first release stop command to the core A because the debug agent determines that the reason for causing the core A to stop running is a cause other than the preset event, instead of receiving the same as in the foregoing embodiment.
  • the first cancel release command is sent to core A by the instruction of the debugger.
  • the debugging agent in this embodiment shares more work of the debugger, and has less functional requirements on the debugger, which is advantageous for streamlining the debugger.
  • the core A executes a debug information collection function to collect debug information of the preset event, and stops running after executing the debug information collection function.
  • the debug information collection function includes a debug interface function added at the end of the preset event and a function function associated with the preset event, and a function function associated with the preset event. Located in the kernel debugging pile, the kernel debugging pile is pre-implanted in the operating system of the target machine.
  • the header of the debug interface function is provided with a first debug exception instruction, and the tail is provided with a second debug exception instruction.
  • the kernel debug pile is called.
  • a function function associated with the preset event is provided.
  • S103 includes: the core A performs a function function associated with the preset event to collect debug information of the preset event, and then executes the second debug exception located at a tail of the debug interface function. instruction. After core A executes the second debug exception command, core A will stop running.
  • the debugging information of the preset event includes an identifier of the preset event, an identifier of the preset event operation object, and a preset function is a loading function of a kernel module, a process for creating a process, or
  • the debugging information of the preset event further includes a loading address of the preset event operation object. It can be seen that the information amount of the debugging information of the preset event is relatively small, and is usually only about 100 lines. Therefore, the technical solution provided by the embodiment of the present invention can reduce the amount of data processed by the target processor, thereby improving debugging. effectiveness.
  • the debugging device After the debugging device determines that the core A stops running, determine a cause that causes the core A to stop running. In a case where the cause of the stop operation of the core A is the preset event, the debugging device is installed. And acquiring the debugging information of the preset event, and setting a preset suspension operation point to the preset event operation object according to the debugging information of the preset event; the preset event operation object is the kernel state code Or the user mode code;
  • the debugging device sends a second release stop command to the core A, and the second release stop command is used to instruct the core A to resume operation;
  • the core A will trigger the trigger in the process of executing the debug information collection function.
  • the identifier of the preset event that the core A executes the debug information collection function writes to the data header to replace the default information; writes the identifier of the preset event operation object to the data body; and, in the preset event, the kernel
  • core A also writes the load address of the preset event action object to the data body. It is worth noting that the loading address of the preset event operation object may be continuous or discontinuous.
  • the debugging information is collected in the case that the preset event is a switching function of a process, a blocking function of a process, a wake-up function of a process, a switching function of a thread, a blocking function of a thread, or a wake-up function of a thread.
  • the function includes an identifier of the preset event and an identifier of the preset event operation object; where the preset event is a load function of a kernel module, a creation function of a process, or a creation function of a thread, the debug information collection function includes a pre- Set the identifier of the event, the identifier of the preset event operation object, and the load address of the preset event operation object.
  • the debugging device determines in S104 that the core A stops running, and determines the cause of the stop of the core A, specifically Including: after the debugging device polls the core A to stop running, determining the cause of the core A to stop running by reading the content of the data header, since the content of the data header includes the identifier of the preset event, the debugging device can The identification of the preset event determines that the cause of the stop of the operation of the core A is a preset event.
  • the debugging device acquires the debugging information of the preset event, and sets the preset suspension operation point to the preset event operation object according to the debugging information of the preset event, which specifically includes:
  • the debugging device determines, according to the identifier of the preset event, that the preset event is a loading function of a kernel module, a creation function of a process, or a creation function of a thread, the debugging device may be based on data located in the data header.
  • the address of the body reading the loading address of the preset event operation object from the data body, and then setting the preset suspension breakpoint to the pre-set according to the loading address of the preset event operation object Setting a destination address of the event operation object; of course, the destination address of the preset event operation object is located in a loading address of the preset event operation object; or
  • the debugging device determines, according to the identifier of the preset event, that the preset event is a switching function of a process, a blocking function of a process, a wake-up function of a process, a creation function of a thread, a switching function of a thread, or a blocking function of a thread.
  • the debugging device reads the identifier of the preset event operation object from the data body according to the address of the data body located in the data header, and determines the preset event operation according to the identifier of the preset event operation object.
  • the debugging device determines, according to the identifier of the preset event operation object, a loading address of the preset event operation object, because the storage space of the second host pre-stores the preset event.
  • the debugging device according to the identifier of the preset event operation object and the corresponding relationship, from the second host The storage space acquires the loading address of the preset event operation object.
  • the preset event is a load function of a kernel module, a process creation function, a process switch function, a process block function, a process wake function
  • a thread creation function if the core A is stopped after executing the debug information collecting function, the contents of the data header and the data body are as Figure 6.2 shows; if core A stops running because of other events, the contents of the data header and data body are as shown in Figure 6.1. Naturally, other events exclude the execution of the debug information collection function.
  • the data header and the data body only include one message, and the debugging device does not need to distinguish which one is the target information when acquiring the information from the data header.
  • the data header and the data body only include one message, the size of the preset storage space located in the memory of the target device is fixed, and the space occupied by the preset storage space is very small, and does not occupy the target machine excessively. Storage resources improve the efficiency of information acquisition.
  • the preset event operation object is a kernel module; and the preset event is a process creation function, a process switching function, and a process.
  • the preset event operation object is a process; in the case where the preset event is a thread creation function, a thread switching function, a thread blocking function, or a thread wake function
  • the preset event operation object is a thread.
  • the kernel module may be a dynamic patch, a hot patch, a dynamic library, or the like.
  • the debugging apparatus includes a debugging agent and a debugger, and the debugging apparatus is applied in the remote debugging system as described in FIG. 2, and the debugging agent and the debugger are required to be explained. It can be located on the same host or on a different host. For example, in Figure 2, the debug agent is located on the first host and the debugger is located on the second host.
  • S104 in FIG. 3 specifically includes:
  • the debugging agent determines that the core A stops running, and determines that the core A stops running. In the case that the core A stops running because the preset event is the preset event, the debugging agent will be The second message is reported to the debugger, where the second message includes the core A stops running and the identifier of the preset event;
  • the S206 specifically includes: after the debugging agent polls the core A to stop running, the content of the data header is read. Determining the cause of the stop of the operation of the core A. Since the content of the data header includes the identifier of the preset event, the debugging agent can determine, according to the identifier of the preset event, that the cause of the stop of the operation of the core A is the preset event. The debug agent reports to the debugger a second message including the identifier of the core A stop running and the preset event.
  • the debugger After receiving the second message, the debugger acquires debugging information of the preset event according to the identifier of the preset event, and sets a preset suspension breakpoint according to the debugging information of the preset event.
  • the preset event operation object
  • the debugger instructs the debug agent to send a second release stop instruction to the core A, and the second release stop instruction is used to instruct the core A to resume operation;
  • the debugger acquires the debugging information of the preset event according to the identifier of the preset event, and specifically includes: the debugger reads the information from the data body according to the identifier of the preset event.
  • the debugger may An address of the data body located in the data header, reading a loading address of the preset event operation object from the data body, and then setting a preset suspension breakpoint to the loading address according to the loading address of the preset event operation object The destination address of the preset event operation object.
  • the destination address of the preset event operation object is located in the loading address of the preset event operation object.
  • the preset event is determined as a switching function of a process, a blocking function of a process, a wake-up function of a process, a creation function of a thread, and a switching function of a thread according to the identifier of the preset event.
  • the debugger reads the identifier of the preset event operation object from the data body according to the address of the data body located in the data header, and operates the identifier of the object according to the preset event. Determining a loading address of the preset event operation object, and setting a preset suspension breakpoint to a destination address of the preset event operation object according to the loading address of the preset event operation object.
  • the debugger determines the loading address of the preset event operation object according to the identifier of the preset event operation object, because the storage space of the second host pre-stores the preset event. Corresponding relationship between the identifier of the operation object and the load address of the preset event operation object, specifically, the debugger, according to the identifier of the preset event operation object and the corresponding relationship, from the second host The storage space acquires the loading address of the preset event operation object.
  • the loading address of the preset event operation object refers to the loading address of the target code of the preset event operation object, and the loading address of the target code of the preset event operation object. Refers to the loading address of the target code of the preset event operation object on the target machine side; the loading address of the source code of the preset event operation object refers to the source code of the preset event operation object in the second sink The load address on the host side.
  • the debugger sets a preset suspension breakpoint to the destination address of the preset event operation object according to the loading address of the preset event operation object, including: the debugger according to the preset Setting a correspondence between a load address of the target code of the event operation object and a load address of the source code of the preset event operation object, and forming a symbol table; then the debugger determines that the preset is located according to the symbol table a target address side of the event operation object and a target address mapped to the hanging breakpoint (or pending breakpoint); and setting the hanging breakpoint to a destination address of the preset event operation object.
  • the hanging breakpoint (or the pending breakpoint) is preset by the debugger on the source side of the preset event operation object.
  • the debugger instructs the debug agent to send the second release stop instruction occurs after “the debugger sets a preset suspension breakpoint to the preset event operation object”.
  • the debugger instructs the debug agent to send a second release stop instruction may also occur after “the debugger acquires debug information of the preset event” and "described The debugger sets a pre-set suspension breakpoint to any time before the preset event action object.
  • the debugging agent sends a second release stop instruction to the core A.
  • the core A After receiving the second release stop command and resume operation, the core A sends a resume operation instruction to the other core, where the resume operation instruction is used to notify the other core to resume operation;
  • the core A hits the suspension breakpoint in the process of running the preset event operation object, thereby entering a debugging state.
  • the core A transmits a resume operation instruction to the other cores
  • the recovery operation instruction is used to notify the other cores to resume operation, specifically: the core A sends a recovery operation instruction to the other cores through a hardware cross-trigger network of the SOC, where the recovery operation instruction is used to notify the other The core resumes operation.
  • the resume operation instruction is sent in the form of a broadcast.
  • the advantage of using the SOC's hardware cross-triggering network for signal transmission is that it can improve the timeliness of recovery of the running instruction transmission.
  • the debugging interface function is related to the type of the preset event by calling the kernel debugging pile.
  • the function function of the joint obtains the debugging information of the preset event; the debugger can set the preset suspension breakpoint to the destination address of the preset event operation object according to the debugging information of the preset event, and the core A is in the subsequent operation.
  • the suspension breakpoint will be hit, and the debug state is entered.
  • the preset event is a processing function of the kernel mode code or a processing function of the user state code
  • the technical solution provided by the embodiment of the present invention implements the same debugging of the kernel state code and the user state code.
  • the platform implements debugging.
  • an embodiment of the present invention includes a multi-core processor, which is applied to the debugging method according to the first embodiment, and the multi-core processor is deployed in a target machine of the remote debugging system as shown in FIG.
  • the multi-core processor includes a core A, an input port, and other cores, and the other cores include a core B, a core C, and a core D, wherein the core B, the core C, and the core D and the core A are both located in the multi-core. Processors, and belong to the same logical grouping.
  • the core A is used to start the stop operation after executing the preset event processing routine, and send a stop operation signal to the other cores during the stop operation, the stop operation signal is used to indicate that the other cores stop running.
  • the preset event is a processing function of a kernel mode code or a processing function of a user mode code;
  • a debug interface function is added at the end of the preset event, and the debug interface function is located outside the preset event, and is not part of the preset event.
  • the header of the debug interface function is provided with a first debug exception instruction, and the core A stops running after executing the first debug exception instruction. Therefore, the core A is specifically configured to start executing the first debug exception instruction located at the debug interface function header after executing the preset event processing routine, and execute the first debug exception instruction.
  • the stop signal is sent to the other cores during the process.
  • the core A is specifically used for hardware passing through the SOC.
  • the cross trigger network sends a stop run signal to the other cores, the stop run signal being used to indicate that the other cores are down.
  • the resume operation instruction is sent in the form of a broadcast.
  • the processing function of the kernel state code is a load function of the kernel module;
  • the processing function of the user state code is a process creation function, a process switching function, a process blocking function, a process wake function, a thread.
  • AMP asymmetric multi-processing
  • SMP Symmetric Multi-Processing
  • core A, core B, core C, and core D are located in the same logical grouping, and code running on at least one of core B, core C, and core D (such as core B) and code running on core A.
  • code running on at least one of core B, core C, and core D such as core B
  • core B code running on core A
  • the code running on the core B may be distorted because the data cannot be correctly interacted with the code running on the core A, so it is provided in the embodiment of the present invention.
  • other cores belonging to the same logical group as the core A stop running to avoid distortion. Further, let Core A stop running synchronously with other cores, and then Core A resumes operation for debugging.
  • the design of the scheme also fully considers the time when the stop signal of the nuclear A is transmitted to other cores, and the time when the nuclear A stops running, specifically after the nuclear A stops running. During the period of stopping the operation, the stop operation command is sent to other cores, so that the core A and other cores are stopped synchronously, thereby achieving relatively accurate synchronous debugging.
  • the input port is configured to receive a first release stop command, and forward the first release stop command to the core A, where the first release stop command is determined by the debugging device in the remote debugging system
  • the reason that the core A stops running and causes the core A to stop running is sent after the cause other than the preset event;
  • the core A is further configured to: after receiving the first release stop instruction and resume running, execute a debug information collection function to collect debug information of the preset event, and stop running after executing the debug information collection function;
  • the debug information collection function includes a debug interface function added at the end of the preset event and a function function associated with the preset event, and a function function associated with the preset event. Located in the kernel debugging pile, the kernel debugging pile is pre-implanted in the operating system of the target machine.
  • the debug interface function is provided with a second debug exception instruction at the end of the debug interface function.
  • the function function associated with the preset event located in the kernel debug stub is called.
  • the core A is specifically configured to execute a function function associated with the preset event to collect debugging information of the preset event, and then execute the second at the tail of the debugging interface function. Debug exception instructions. After core A executes the second debug exception command, core A will stop running.
  • the debugging information of the preset event includes an identifier of the preset event, an identifier of the preset event operation object, and a preset function is a loading function of a kernel module, a process for creating a process, or
  • the debugging information of the preset event further includes a loading address of the preset event operation object. It can be seen that the information amount of the debugging information of the preset event is relatively small, and is usually only about 100 lines. Therefore, the technical solution provided by the embodiment of the present invention can reduce the amount of data processed by the target processor, thereby improving debugging. effectiveness.
  • the input port is further configured to receive a second release stop instruction, and forward the second release stop instruction to the core A, where the second release stop instruction is a debugging of the debugging device according to the preset event
  • the information is sent after the preset breakpoint is set to the preset event operation object;
  • the preset event operation object is a kernel module; and the preset event is a process creation function, a process switching function, and a process.
  • the preset event operation object is a process; the preset event is a thread creation function, a thread switching function, a thread blocking function, or a thread calling
  • the preset event operation object is a thread.
  • the kernel module may be a dynamic patch, a hot patch, a dynamic library, or the like.
  • the core A is further configured to send a resume operation instruction to the other core after receiving the second release stop instruction and resume running, the resume operation instruction is used to notify the other core to resume operation; and is also used to run The preset event hits the suspension breakpoint during the operation of the object, thereby entering a debug state.
  • the core A is specifically used for hardware cross-triggering through the SOC.
  • the network sends a resume run command to the other cores, the resume run command being used to notify the other cores to resume operation.
  • the resume operation instruction is sent in the form of a broadcast.
  • the advantage of using the SOC's hardware cross-triggering network for signal transmission is that it can improve the timeliness of recovery of the running instruction transmission.
  • the debug interface function calls the kernel debug pile and the type of the preset event.
  • the function function is configured to obtain the debugging information of the preset event, so that the debugging device sets the preset suspension breakpoint to the destination address of the preset event operation object according to the debugging information of the preset event; The preset event operation object will hit the suspension breakpoint in the process of entering the debug state.
  • the multi-core processor provided by the embodiment of the present invention can implement the kernel state code and the user state code. Debugging is implemented on the same debugging platform.
  • an embodiment of the present invention includes a debugging apparatus, which is applied to the debugging method according to the first embodiment, and the debugging apparatus is deployed in a host of the remote debugging system as shown in FIG.
  • the debugging device includes a debug unit and a receiving unit.
  • the receiving unit is configured to receive a message for instructing the core A to stop running, and forward the message for instructing the core A to stop running to the debugging device; wherein the target device located in the remote debugging system includes a multi-core a processor, the multi-core processor including the core A;
  • the debugging unit is configured to determine, after determining that the core A stops running, a cause that causes the core A to stop running;
  • the debug unit is also used for Obtaining the debugging information of the preset event, and setting a preset suspension breakpoint to the preset event operation object according to the debugging information of the preset event;
  • the preset event is a processing function of the kernel state code or a processing function of the user mode code;
  • the preset event operation object is the kernel mode code or the user mode code;
  • the processing function of the kernel state code is a load function of the kernel module
  • the processing function of the user state code is a process creation function, a process switching function, a process blocking function, a process wake function, a thread.
  • the preset event is a load function of a kernel module
  • the preset event operation object is a kernel module
  • the preset event is a process creation function, a process switching function, a process blocking function or a process.
  • the preset event operation object is a process; in the case that the preset event is a thread creation function, a thread switching function, a thread blocking function, or a thread wake function, the pre Let the event action object be a thread.
  • the kernel module may be a dynamic patch, a hot patch, a dynamic library, or the like.
  • the preset storage space is used to store a data header.
  • the data header includes a first default information and an address of the data body.
  • the first default information may be empty; the data body includes second default information.
  • the second default information can also be empty.
  • the core A will trigger the core A to execute the debug information collecting function.
  • An identifier of a preset event of the debug information collection function is written in the data header to replace the default information; an identifier of the preset event operation object is written into the data body; and, in the preset event, a load function of the kernel module,
  • core A also writes the load address of the preset event operation object to the data body. It is worth noting that the loading address of the preset event operation object may be continuous or discontinuous.
  • the debugging unit is specifically configured to determine that the core A stops running by reading the content of the data header after determining that the core A stops running.
  • the reason is that, because the content of the data header includes the identifier of the preset event, the debugging unit can determine, according to the identifier of the preset event, that the reason that the core A stops running is a preset event.
  • the debugging unit is specifically configured to determine the preset according to the identifier of the preset event
  • the event is a load function of a kernel module, a create function of a process, or a create function of a thread
  • the load address of the preset event operation object is read from the data body according to the address of the data body located in the data header, and then according to Setting a loading address of the preset event operation object, and setting a preset suspension breakpoint to a destination address of the preset event operation object; or
  • the debugging unit is specifically configured to determine, according to the identifier of the preset event, the preset event as a process switching function, a process blocking function, a process wake-up function, a thread creation function, a thread switching function, or a thread
  • the blocking function the identifier of the preset event operation object is read from the data body according to the address of the data body located in the data header, and the preset event operation object is determined according to the identifier of the preset event operation object. Loading a address, and setting a preset suspension breakpoint to a destination address of the preset event operation object according to the loading address of the preset event operation object.
  • the debugging unit is specifically used. And acquiring, according to the identifier of the preset event operation object and the corresponding relationship, a loading address of the preset event operation object from a storage space of the second host.
  • the debugging unit in the debugging apparatus is further used to indicate the core A recovery. Run to collect debug information for the preset event.
  • the debugging unit is specifically configured to determine, by determining the content of the data header, after determining that the core A stops running.
  • the reason for causing the core A to stop running, because the content of the data header includes the first default information the debugging unit can determine, according to the first default information, that the reason that the core A stops running is a cause other than the preset event. .
  • the debugging unit includes a debugging agent and a debugger.
  • the debugging agent and the debugger in the debugging device shown in FIG. 8 may be located on the same host. It can also be located on different hosts. Referring to the remote debugging system shown in FIG. 2, the debugging agent and the debugger are respectively located on different hosts, wherein the debugging agent is located at the first host and the debugger is located at the second host.
  • the debug unit includes a debug agent and a debugger, and in the case where the cause of the stop of the core A is a preset event:
  • the debugging agent is specifically configured to determine that the core A stops after determining that the core A stops running.
  • the second message is reported to the debugger, and the second message includes the core A stops running and the preset is caused by the reason that the cause of the stop operation of the core A is the preset event.
  • the debugging agent is specifically configured to: after the polling of the core A stops running, determine, by reading an identifier of the preset event in the content of the data header, that the cause that causes the core A to stop running is the preset event, A second message including the identification of the core A stop operation and the preset event is reported to the debugger.
  • the debugger is configured to: after receiving the second message, acquire debugging information of the preset event according to the identifier of the preset event, and set a preset suspension breakpoint according to the debugging information of the preset event. Set the preset event operation object.
  • the debugger is configured to: read, according to the identifier of the preset event in the second message, an identifier of the preset event operation object or a loading of the preset event operation object from a data body address.
  • the debugger in the case that the preset event is determined to be a load function of a kernel module, a creation function of a process, or a creation function of a thread according to the identifier of the preset event, the debugger is specifically used. Reading the loading address of the preset event operation object from the data body according to the address of the data body located in the data header, and then setting the preset suspension breakpoint to the loading address of the preset event operation object to The destination address of the preset event operation object.
  • the preset event is determined as a switching function of a process, a blocking function of a process, a wake-up function of a process, a creation function of a thread, and a switching function of a thread according to the identifier of the preset event.
  • the debugger is configured to read the identifier of the preset event operation object from the data body according to the address of the data body located in the data header, and operate the object according to the preset event.
  • the identifier determines the loading address of the preset event operation object, and sets a preset suspension breakpoint to the destination address of the preset event operation object according to the loading address of the preset event operation object.
  • the debugger determines the loading address of the preset event operation object according to the identifier of the preset event operation object, because the storage space of the second host pre-stores the preset event. Corresponding relationship between the identifier of the operation object and the load address of the preset event operation object, specifically, the debugger, according to the identifier of the preset event operation object and the corresponding relationship, from the second host The storage space acquires the loading address of the preset event operation object.
  • the debug unit includes a debug agent and a debugger, and
  • the reason that the core A stops running is the reason other than the preset event:
  • the debugging agent is specifically configured to determine, after determining that the core A stops running, a cause that causes the core A to stop running, and the reason that causes the core A to stop running is a cause other than the preset event
  • the debugging agent is specifically configured to send a first release stop instruction to the core A, where the first release stop instruction is used to instruct the core A to resume operation to collect debugging information of the preset event.
  • the debugging agent is specifically configured to: after polling the core A to stop running, the content of the read data header includes first default information, and the reason for causing the core A to stop running can be determined according to the first default information. For reasons other than the preset event.
  • the debug unit includes a debug agent and a debugger
  • the debug unit includes a debug agent and a debugger
  • the debugging agent is specifically configured to determine, after polling that the core A stops running, a cause that causes the core A to stop running, and causes the core A to stop running for reasons other than the preset event.
  • the first message is reported to the debugger, where the first message includes the core A stops running and a default identifier;
  • the debugging agent is specifically configured to: after polling the core A to stop running, the content of the read data header includes first default information, and the reason for causing the core A to stop running can be determined according to the first default information. For reasons other than the preset event, the core A is stopped and the default identifier is reported to the debugger.
  • the debugger is specifically configured to: after receiving the first message, instruct the debugging agent to send a first release stop instruction to the core A, where the first release stop instruction is used to indicate that the core A resumes operation;
  • the debugging agent is specifically configured to send the first release stop instruction to the core A.
  • the debugging unit is further configured to instruct the core A to resume operation, so that the core A hits the suspension breakpoint in the process of running the preset event operation object, thereby causing the core A to enter a debugging state. .
  • the debugger is specifically configured to instruct the debugging agent to send a second release stop instruction to the core A, where the second release stop instruction is used to indicate The verification A resumes operation so that the core A hits the suspension breakpoint during the operation of the preset event operation object, thereby causing the core A to enter the debugging state.
  • the debugging device after determining that the core A of the target-side multi-core processor stops running, and determines that the cause of the stop of the core A is a preset event, the debugging device Obtain debugging information of the preset event from the target machine side, and according to the debugging information of the preset event, The suspended breakpoint set first is set to the preset event operation object, thereby implementing debugging of the preset event operation object.
  • the preset event is a processing function of the kernel mode code or a processing function of the user state code
  • the preset event operation object is a kernel state code or a user state code
  • the embodiment of the present invention is provided.
  • the debugging device can not only realize the debugging of the kernel state code, but also realize the debugging of the user state code.
  • FIG. 9 is a structural block diagram of a debugging device 900 according to an embodiment of the present invention.
  • the debugging device 900 is applied in a remote debugging system as shown in FIG. 1 , and the debugging device 900 is remotely debugged as shown in FIG. 1 .
  • the debugging device 900 includes: at least one processor 901, at least one network interface 904 or other user interface 903, a memory 905, and at least one communication bus 902.
  • the communication bus 902 is used to implement connection communication between these components.
  • the debug device 900 optionally includes a user interface 903, including a display (eg, a touch screen, LCD, CTR, Holographic or Projector, etc.), a keyboard or a pointing device (eg, a mouse, trackball) , touch panel or touch screen, etc.).
  • a display eg, a touch screen, LCD, CTR, Holographic or Projector, etc.
  • a keyboard or a pointing device eg, a mouse, trackball
  • touch panel or touch screen etc.
  • Memory 905 can include read only memory and random access memory and provides instructions and data to the processor. A portion of the memory 905 may also include non-volatile random access memory (NVRAM).
  • NVRAM non-volatile random access memory
  • memory 905 stores elements, executable modules or data structures, or a subset thereof, or their extension set:
  • the operating system 9051 includes various system programs, such as a framework layer, a core library layer, a driver layer, and the like, for implementing various basic services and processing hardware-based tasks;
  • the application module 9052 includes various applications, such as a desktop, a media player, a browser, etc., for implementing various application services.
  • the processor 901 is configured to determine, after determining that the core A stops running, a cause that causes the core A to stop running;
  • the target machine located in the remote debugging system includes a multi-core processor, the multi-core The processor includes the core A;
  • the preset storage space is specified by the debugger in advance in the memory of the target machine, and the size and address of the preset storage space are fixed.
  • the preset storage space is used to store a data header.
  • the data header includes a first default information and an address of the data body.
  • the first default information may be empty; the data body includes second default information.
  • the second default information can also be empty.
  • the core A will trigger the core A to execute the debug information collecting function.
  • An identifier of a preset event of the debug information collection function is written in the data header to replace the default information; an identifier of the preset event operation object is written into the data body; and, in the preset event, a load function of the kernel module,
  • core A also writes the load address of the preset event operation object to the data body. It is worth noting that the loading address of the preset event operation object may be continuous or discontinuous. If the core A stops running for other reasons, as shown in Figure 6.1, the data header still includes the address of the first default information and the data body, and the data body still includes the second default information.
  • the processor 901 is specifically configured to determine, by reading the content of the data header, the reason for causing the core A to stop running after determining that the core A stops running. If the data header includes an identifier of the preset event, determining that the core A is caused The reason for stopping the operation is a preset event; if the data header includes the first default information, it is determined that the reason for causing the core A to stop running is a cause other than the preset event.
  • the processor 901 is further configured to acquire debugging information of the preset event, and perform a preset suspension according to the debugging information of the preset event, in a case that the cause of the stop operation of the core A is a preset event.
  • Setting a point to the preset event operation object; the preset event is a processing function of a kernel mode code or a processing function of a user mode code, and the preset event operation object is a kernel state code or a user state code;
  • the debugging information of the preset event may be determined by the identifier of the preset event and the identifier of the preset event operation object, where the preset event is a loading function and a process of the kernel module.
  • the debugging information of the preset event further includes a loading address of the preset event operation object.
  • the processing function of the kernel state code is a load function of the kernel module
  • the processing function of the user state code is a process creation function, a process switching function, a process blocking function, a process wake function, a thread.
  • the preset event is a load function of a kernel module
  • the preset event operation object is a kernel module
  • the preset event is a process creation function, a process switching function, a process blocking function or a process.
  • the preset event operation object is a process; in the case that the preset event is a thread creation function, a thread switching function, a thread blocking function, or a thread wake function, the pre Let the event action object be a thread.
  • the device 901 is specifically configured to determine, according to the identifier of the preset event, that the preset event is a load function of a kernel module, a creation function of a process, or a creation function of a thread, according to an address of a data body located in the data header. Reading the loading address of the preset event operation object from the data body, and then setting a preset suspension breakpoint to the destination address of the preset event operation object according to the loading address of the preset event operation object; or,
  • the processor 901 is configured to determine, according to the identifier of the preset event, that the preset event is a process switching function, a process blocking function, a process wake function, a thread creation function, a thread switching function, or a thread blocking function.
  • the identifier of the preset event operation object is read from the data body according to the address of the data body located in the data header, and the loading of the preset event operation object is determined according to the identifier of the preset event operation object.
  • An address, and setting a preset suspension breakpoint to a destination address of the preset event operation object according to the loading address of the preset event operation object.
  • the processor 901 is specifically configured to use the The identifier of the preset event operation object and the corresponding relationship are obtained, and the loading address of the preset event operation object is obtained from the storage space of the second host.
  • the memory 905 is configured to store debugging information of the preset event
  • the processor 901 is further configured to instruct the core A to resume operation, so that the core A hits the suspension breakpoint during running the preset event operation object, thereby causing the core A to enter debugging. status.
  • the processor 901 is further configured to instruct the core A to resume operation to collect the preset. Debug information for the event.
  • the debugging device after determining that the core A of the target-side multi-core processor stops running, and determines that the cause of the stop operation of the core A is a preset event, the debugging device
  • the debugging information of the preset event is obtained from the target machine side, and the preset suspension breakpoint is set to the preset event operation object according to the debugging information of the preset event, thereby implementing debugging of the preset event operation object.
  • the preset event is a processing function of the kernel mode code or a processing function of the user state code
  • the preset event operation object is a kernel state code or a user state code
  • the embodiment of the present invention is provided.
  • Debugging the device not only enables debugging of kernel-mode code, but also enables debugging of user-mode code.
  • the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium, including The instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to perform all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .

Landscapes

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

Abstract

一种调试方法、多核处理器和调试装置,涉及计算机技术领域。所述方法包括:所述多核处理器的核A执行完预设事件处理例程后开始停止运行,并在停止运行的过程中向其他核发送停止运行信号(S101);所述核A接收第一解除停止指令并恢复运行后,执行调试信息收集函数以收集所述预设事件的调试信息,并在执行完所述调试信息收集函数之后停止运行(S103);所述核A接收第二解除停止指令并恢复运行后,向所述其他核发送恢复运行指令,所述核A在运行所述预设事件操作对象的过程中撞到悬挂断点,从而进入调试状态(S105)。该方法能够将内核态代码和用户态代码在同一个调试平台进行调试。

Description

一种调试方法、多核处理器和调试设备
本申请要求于2015年09月25日提交中国专利局、申请号为201510623830.4、发明名称为“一种调试方法、多核处理器和调试设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明实施例涉及计算机技术领域,尤其涉及一种调试方法、多核处理器和调试设备。
背景技术
程序调试,是将编写完成的计算机程序投入实际运行前,用手工或编译程序等方法进行测试,修正语法错误和逻辑错误的过程。这是保证计算机信息系统正确性必不可少的步骤。所以编写完成的计算机程序,必须送入计算机中进行调试。
业界通常将运行在内核空间代码称为内核态代码,将运行在用户空间的代码称为用户态代码。当前,在对内核态代码和用户态代码进行调试时,需要使用不同的调试平台。需要明确的是,下述的目标机是指被调试代码运行的物理主机,宿主机是指调试器运行的物理主机。比如在对用户态代码进行调试时,需要在目标机的操作系统上运行调试器以进行本地调试;或者,在对用户态代码进行调试时,需要在目标机的操作系统内植入进程跟踪模块(Ptrace),可能还需要在操作系统上运行调试桩,再在宿主机上运行调试器以进行远程调试;而在对内核态代码,比如内核模块,进行调试时,需要在目标机的操作系统内植入内核调试器,然后在宿主机运行调试器进行远程调试。
发明内容
本发明实施例提供一种调试方法、多核处理器和调试设备,用于将内核态代码和用户态代码在同一个调试平台实现调试。
第一方面,本发明实施例提供一种调试方法,应用于远程调试系统中的目标机,所述目标机包括多核处理器,该调试方法包括:
所述多核处理器的核A执行完预设事件处理例程后开始停止运行,并在停止运行的过程中向其他核发送停止运行信号,所述停止运行信号用于指示所述其他 核停止运行,所述其他核是指位于所述多核处理器内、且与所述核A属于同一逻辑分组的所有核,所述预设事件为内核态代码的处理函数或用户态代码的处理函数;
所述核A接收第一解除停止指令并恢复运行后,执行调试信息收集函数以收集所述预设事件的调试信息,并在执行完所述调试信息收集函数之后停止运行;所述第一解除停止指令是所述远程调试系统中的调试装置在确定所述核A停止运行且导致所述核A停止运行的原因为所述预设事件之外的原因后发送的;
所述核A接收第二解除停止指令并恢复运行后,向所述其他核发送恢复运行指令,所述恢复运行指令用于通知所述其他核恢复运行;所述第二解除停止指令是所述调试装置根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象之后发送的;
所述核A在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而进入调试状态。
结合第一方面,在第一方面的第一种实施方式下,
所述调试信息收集函数包括调试接口函数,所述调试接口函数的头部设置有第一调试异常指令,所述第一调试异常指令用于指示所述核A停止运行;
所述核A执行完预设事件处理例程后开始停止运行,并在停止运行的过程中向其他核发送停止运行信号,具体包括:
所述核A执行完所述预设事件处理例程后开始执行位于所述调试接口函数头部的所述第一调试异常指令,并在执行所述第一调试异常指令的过程中向所述其他核发送所述停止运行信号。
结合第一方面的第一种实施方式,在第一方面的第二种实施方式下,
所述调试信息收集函数还包括与所述预设事件相关联的功能函数,且所述调试接口函数的尾部还设置有第二调试异常指令,所述第二调试异常指令用于指示所述核A停止运行;
所述核A执行调试信息收集函数以收集所述预设事件的调试信息,并在执行完所述调试信息收集函数之后停止运行,具体包括:
所述核A执行与所述预设事件相关联的功能函数以收集所述预设事件的调试信息,然后执行位于所述调试接口函数尾部的所述第二调试异常指令。
结合第一方面的第二种实施方式,在第一方面的第三种实施方式下,
所述与所述预设事件相关联的功能函数位于内核调试桩内,所述内核调试桩是预先植入在所述目标机操作系统内的。
结合第一方面或第一方面的第一种实施方式至第一方面的第三种实施方式中任一种实施方式,在第一方面的第四种实施方式下,
所述内核态代码的处理函数为内核模块的加载函数;
所述用户态代码的处理函数为进程的创建函数、进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数。
结合第一方面的第四种实施方式,在第一方面的第五种实施方式下,
在所述预设事件为所述内核模块的加载函数的情况下,所述预设事件操作对象为内核模块;
在所述预设事件为所述进程的创建函数、所述进程的切换函数、所述进程的阻塞函数或所述进程的唤醒函数的情况下,所述预设事件操作对象为进程;
在所述预设事件为所述线程的创建函数、所述线程的切换函数、所述线程的阻塞函数或所述线程的唤醒函数的情况下,所述预设事件操作对象为线程。
结合第一方面的第四种实施方式或第一方面的第五种实施方式,在第一方面的第六种实施方式下,
所述预设事件的调试信息包括所述预设事件操作对象的标识;
在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述预设事件的调试信息还包括所述预设事件操作对象的加载地址。
结合第一方面或第一方面的第一种实施方式至第一方面的第六种实施方式中任一种实施方式,在第一方面的第七种实施方式下,所述多核处理器集成在系统级芯片SOC上;
所述核A向其他核发送停止运行信号,所述停止运行信号用于指示所述其他核停止运行,具体包括:
所述核A通过所述SOC的硬件交叉触发网络向所述其他核发送停止运行信号,所述停止运行信号用于指示所述其他核停止运行;
所述核A向所述其他核发送恢复运行指令,所述恢复运行指令用于通知所述其他核恢复运行,具体包括:
所述核A通过所述SOC的硬件交叉触发网络向所述其他核发送恢复运行指 令,所述恢复运行指令用于通知所述其他核恢复运行。
第二方面,本发明实施例提供一种调试方法,由部署于宿主机内的调试装置执行,所述宿主机位于远程调试系统,所述方法包括:
所述调试装置确定核A停止运行后,确定导致所述核A停止运行的原因,所述核A属于所述远程调试系统中的目标机的多核处理器;
在导致所述核A停止运行的原因为预设事件的情况下,所述调试装置获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象;所述预设事件为内核态代码的处理函数或用户态代码的处理函数;所述预设事件操作对象为内核态代码或用户态代码;
所述调试装置指示所述核A恢复运行,以使所述核A在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而使所述核A进入调试状态。
结合第二方面,在第二方面的第一种实施方式下,所述方法还包括:
在导致所述核A停止运行的原因为预设事件之外的原因的情况下,所述调试装置指示所述核A恢复运行以收集所述预设事件的调试信息。
结合第二方面或第二方面的第一种实施方式,在第二方面的第二种实施方式下,
所述内核态代码的函数为内核模块的加载函数;
所述用户态代码的函数为进程的创建函数、进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数。
结合第二方面的第二种实施方式,在第二方面的第三种实施方式下,
在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述预设事件的调试信息包括所述预设事件操作对象的加载地址;
所述调试装置获取所述预设事件的调试信息,并所述根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象,具体包括:
所述调试装置获取所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
结合第二方面的第二种实施方式,在第二方面的第四种实施方式下,
在所述预设事件为进程的切换函数、进程的阻塞函数、进程的唤醒函数、线 程的切换函数、线程的阻塞函数或线程的唤醒函数的情况下,所述预设事件的调试信息包括所述预设事件操作对象的标识;
所述调试装置获取所述预设事件的调试信息,并所述根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象,具体包括:
所述调试装置获取所述预设事件操作对象的标识,根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
结合第二方面的第四种实施方式,在第二方面的第五种实施方式下,
所述宿主机的存储空间预先存储了所述预设事件操作对象的标识与所述预设事件操作对象的加载地址的对应关系;
所述根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,具体包括:
根据所述预设事件操作对象的标识以及所述对应关系,从所述宿主机的存储空间获取所述预设事件操作对象的加载地址。
结合第二方面或第二方面的第一种实施方式至第二方面的第五种实施方式中任一种实施方式,在第二方面的第六种实施方式下,所述调试装置包括调试器和调试代理,
所述调试装置确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为预设事件的情况下,所述调试装置获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象,具体包括:
所述调试代理轮询到所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件的情况下,所述调试代理将第二消息上报所述调试器,所述第二消息包括所述核A停止运行以及所述预设事件的标识;
所述调试器接收所述第二消息后,根据所述预设事件的标识获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象;
所述调试装置指示所述核A恢复运行,具体包括:
所述调试器指示所述调试代理向所述核A发送第二解除停止指令,所述第二 解除停止指令用于指示所述核A恢复运行。
结合第二方面的第六种实施方式,在第二方面的第七种实施方式下,
所述调试装置确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为预设事件之外的原因的情况下,所述调试装置指示所述核A恢复运行以收集所述预设事件的调试信息,具体包括:
所述调试代理轮询到所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件之外的原因的情况下,所述调试代理向所述核A发送第一解除停止指令,所述第一解除停止指令用于指示所述核A恢复运行以收集所述预设事件的调试信息。
结合第二方面或第二方面的第一种实施方式至第二方面的第六种实施方式中任一种实施方式,在第二方面的第八种实施方式下,所述调试装置包括调试器和调试代理;
所述调试装置确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为预设事件之外的原因的情况下,所述调试装置指示所述核A恢复运行以收集所述预设事件的调试信息,具体包括:
所述调试代理轮询到所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件之外的原因的情况下,将第一消息上报给所述调试器,所述第一消息包括所述核A停止运行以及缺省标识,
所述调试器接收所述第一消息后,指示所述调试代理向所述核A发送第一解除停止指令,所述第一解除停止指令用于指示所述核A恢复运行以收集所述预设事件的调试信息。
结合第二方面或第二方面的第一种实施方式至第二方面的第八种实施方式中任一种实施方式,在第二方面的第九种实施方式下,
在所述预设事件为所述内核模块的加载函数的情况下,所述预设事件操作对象为内核模块;
在所述预设事件为所述进程的创建函数、所述进程的切换函数、所述进程的阻塞函数或所述进程的唤醒函数的情况下,所述预设事件操作对象为进程;
在所述预设事件为所述线程的创建函数、所述线程的切换函数、所述线程的阻塞函数或所述线程的唤醒函数的情况下,所述预设事件操作对象为线程。
第三方面,本发明实施例提供一种多核处理器,应用于远程调试系统中的目 标机,所述多核处理器包括核A、其他核和输入端口,所述其他核是指位于所述多核处理器内、且与所述核A属于同一逻辑分组的所有核,其中:
所述核A用于在执行完预设事件处理例程后开始停止运行,并在停止运行的过程中向其他核发送停止运行信号,所述停止运行信号用于指示所述其他核停止运行,所述预设事件为内核态代码的处理函数或用户态代码的处理函数;
所述输入端口用于接收第一解除停止指令,并将所述第一解除停止指令转送给所述核A,所述第一解除停止指令是所述远程调试系统中的调试装置在确定所述核A停止运行且导致所述核A停止运行的原因为所述预设事件之外的原因后发送的;
所述核A还用于在接收所述第一解除停止指令并恢复运行后,执行调试信息收集函数以收集所述预设事件的调试信息,并在执行完所述调试信息收集函数之后停止运行;
所述输入端口还用于接收第二解除停止指令,并将所述第二解除停止指令转送给所述核A,所述第二解除停止指令是所述调试装置根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象之后发送的;
所述核A还用于在接收所述第二解除停止指令并恢复运行后,向所述其他核发送恢复运行指令,所述恢复运行指令用于通知所述其他核恢复运行;以及还用于在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而进入调试状态。
结合第三方面,在第三方面的第一种实施方式下,
所述调试信息收集函数包括调试接口函数,所述调试接口函数的头部设置有第一调试异常指令,所述第一调试异常指令用于指示所述核A停止运行;
所述核A具体用于在执行完所述预设事件处理例程后开始执行位于所述调试接口函数头部的所述第一调试异常指令,并在执行所述第一调试异常指令的过程中向所述其他核发送所述停止运行信号。
结合第三方面的第一种实施方式,在第三方面的第二种实施方式下,
所述调试信息收集函数还包括与所述预设事件相关联的功能函数,且所述调试接口函数的尾部还设置有第二调试异常指令,所述第二调试异常指令用于指示所述核A停止运行;
所述核A具体用于执行与所述预设事件相关联的功能函数以收集所述预设 事件的调试信息,然后执行位于所述调试接口函数尾部的所述第二调试异常指令。
结合第三方面的第二种实施方式,在第三方面的第三种实施方式下,
所述与所述预设事件相关联的功能函数位于内核调试桩内,所述内核调试桩是预先植入在所述目标机操作系统内的。
结合第三方面或第三方面的第一种实施方式至第三方面的第三种实施方式中任意一种实现方式,在第三方面的第四种实施方式下,
所述内核态代码的处理函数为内核模块的加载函数;
所述用户态代码的处理函数为进程的创建函数、进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数。
结合第三方面的第四种实施方式,在第三方面的第五种实施方式下,
在所述预设事件为所述内核模块的加载函数的情况下,所述预设事件操作对象为内核模块;
在所述预设事件为所述进程的创建函数、所述进程的切换函数、所述进程的阻塞函数或所述进程的唤醒函数的情况下,所述预设事件操作对象为进程;
在所述预设事件为所述线程的创建函数、所述线程的切换函数、所述线程的阻塞函数或所述线程的唤醒函数的情况下,所述预设事件操作对象为线程。
结合第三方面的第四种实施方式或第三方面的第五种实施方式,在第三方面的第六种实施方式下,
所述预设事件的调试信息包括所述预设事件操作对象的标识;
在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述预设事件的调试信息还包括所述预设事件操作对象的加载地址。
结合第三方面或第三方面的第一种实施方式至第三方面的第六种实施方式中任意一种实现方式,在第三方面的第七种实施方式下,所述多核处理器集成在系统级芯片SOC上;
所述核A具体用于通过所述SOC的硬件交叉触发网络向所述其他核发送停止运行信号,所述停止运行信号用于指示所述其他核停止运行;以及,
所述核A具体用于通过所述SOC的硬件交叉触发网络向所述其他核发送恢复运行指令,所述恢复运行指令用于通知所述其他核恢复运行。
第四方面,本发明实施例提供一种调试装置,所述调试设备部署在远程调试系统的宿主机内,所述调试设备包括调试单元和接收单元,
所述接收单元用于接收用于指示核A停止运行的消息,并将所述用于指示所述核A停止运行的消息转送给所述调试单元;其中,位于所述远程调试系统的目标机包括多核处理器,所述多核处理器包括所述核A;
所述调试单元用于在确定所述核A停止运行后,确定导致所述核A停止运行的原因;
在导致所述核A停止运行的原因为预设事件的情况下,所述调试单元还用于获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象;所述预设事件为内核态代码的处理函数或用户态代码的处理函数;所述预设事件操作对象为内核态代码或用户态代码;
所述调试单元还用于指示所述核A恢复运行,以使所述核A在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而使所述核A进入调试状态。
结合第四方面,在第四方面的第一种实施方式下,
在导致所述核A停止运行的原因为预设事件之外的原因的情况下,所述调试单元还用于指示所述核A恢复运行以收集所述预设事件的调试信息。
结合第四方面或第四方面的第一种实施方式,在第四方面的第二种实施方式下,
所述内核态代码的函数为内核模块的加载函数;
所述用户态代码的函数为进程的创建函数、进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数。
结合第四方面的第二种实施方式,在第四方面的第三种实施方式下,
在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述预设事件的调试信息包括所述预设事件操作对象的加载地址;
所述调试单元具体用于获取所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
结合第四方面的第二种实施方式,在第四方面的第四种实施方式下,
在所述预设事件为进程的切换函数、进程的阻塞函数、进程的唤醒函数、线 程的切换函数、线程的阻塞函数或线程的唤醒函数的情况下,所述预设事件的调试信息包括所述预设事件操作对象的标识;
所述调试单元具体用于获取所述预设事件操作对象的标识,根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
结合第四方面的第四种实施方式,在第四方面的第五种实施方式下,
所述宿主机的存储空间预先存储了所述预设事件操作对象的标识与所述预设事件操作对象的加载地址的对应关系;
所述调试单元具体用于根据所述预设事件操作对象的标识以及所述对应关系,从所述宿主机的存储空间获取所述所述预设事件操作对象的加载地址。
结合第四方面或第四方面的第一种实施方式至第四方面的第五种实施方式中任意一种实施方式,在第四方面的第六种实施方式下,
所述调试单元包括调试器和调试代理,
所述调试代理具体用于在确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件的情况下,将第二消息上报所述调试器,所述第二消息包括所述核A停止运行以及所述预设事件的标识;
所述调试器具体用于接收所述第二消息后,根据所述预设事件的标识获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象;
所述调试器具体用于指示所述调试代理向所述核A发送第二解除停止指令,所述第二解除停止指令用于指示所述核A恢复运行。
结合第四方面的第六种实施方式,在第四方面的第七种实施方式下,
所述调试代理具体用于在确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件之外的原因的情况下,所述调试代理具体用于向所述核A发送第一解除停止指令,所述第一解除停止指令用于指示所述核A恢复运行以收集所述预设事件的调试信息。
结合第四方面或第四方面的第一种实施方式至第四方面的第六种实施方式中任意一种实施方式,在第四方面的第八种实施方式下,
所述调试装置还包括调试器和调试代理,
所述调试代理具体用于在确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件之外的原因的情况下,将第一消息上报给所述调试器,所述第一消息包括所述核A停止运行以及缺省标识,
所述调试器具体用于接收所述第一消息后,指示所述调试代理向所述核A发送第一解除停止指令,所述第一解除停止指令用于指示所述核A恢复运行以收集所述预设事件的调试信息。
第五方面,本发明实施例提供一种调试设备,包括处理器和存储器,
所述处理器用于在确定所述核A停止运行后,确定导致所述核A停止运行的原因;位于所述远程调试系统的目标机包括多核处理器,所述多核处理器包括所述核A;
在导致所述核A停止运行的原因为预设事件的情况下,所述处理器还用于获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象;所述预设事件为内核态代码的处理函数或用户态代码的处理函数,所述预设事件操作对象为内核态代码或用户态代码;
所述存储器用于存储所述预设事件的调试信息。
所述处理器还用于指示所述核A恢复运行,以使所述核A在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而使所述核A进入调试状态。
结合第五方面,在第五方面的第一种实施方式下,
在导致所述核A停止运行的原因为预设事件之外的原因的情况下,所述处理器还用于指示所述核A恢复运行以收集所述预设事件的调试信息。
结合第五方面或第五方面的第一种实施方式,在第五方面的第二种实施方式下,
所述内核态代码的函数为内核模块的加载函数;
所述用户态代码的函数为进程的创建函数、进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数。
结合第五方面的第二种实施方式,在第五方面的第三种实施方式下,
在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数 的情况下,所述预设事件的调试信息包括所述预设事件操作对象的加载地址;
所述处理器具体用于获取所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
结合第五方面的第二种实施方式,在第五方面的第四种实施方式下,
在所述预设事件为进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数的情况下,所述预设事件的调试信息包括所述预设事件操作对象的标识;
所述处理器具体用于获取所述预设事件操作对象的标识,根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
结合第五方面的第四种实施方式,在第五方面的第五种实施方式下,
所述宿主机的存储空间预先存储了所述预设事件操作对象的标识与所述预设事件操作对象的加载地址的对应关系;
所述处理器具体用于根据所述预设事件操作对象的标识以及所述对应关系,从所述宿主机的存储空间获取所述所述预设事件操作对象的加载地址。
可知,本发明实施例提供一种调试方法,通过在运行在核A上的预设事件的末尾添加调试接口函数,该调试接口函数通过调用内核调试桩中与该预设事件的类型相关联的功能函数,获取该预设事件的调试信息;调试器根据该预设事件的调试信息将预先设置的悬挂断点设置该预设事件操作对象的目的地址,则核A在后续运行所述预设事件操作对象的过程中将会撞到所述悬挂断点,从而进入调试状态。因为在本发明实施例中,该预设事件为内核态代码的处理函数或用户态代码的处理函数,所以本发明实施例提供的技术方案能够将内核态代码和用户态代码在同一个调试平台实现调试。
附图说明
为了更清楚地说明本发明实施例的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提 下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种远程调试系统的结构示意图;
图2为本发明实施例提供的另一种远程调试系统的结构示意图;
图3为本发明实施例提供的一种调试方法的流程示意图;
图4为本发明实施例提供的另一种调试方法的流程示意图;
图5为本发明实施例提供的一种目标机的结构示意图;
图6.1为本发明实施例提供的一种数据头和数据体的结构示意图;
图6.2为本发明实施例提供的另一种数据头和数据体的结构示意图;
图7为本发明实施例提供的一种多核处理器的结构示意图;
图8为本发明实施例提供的一种调试装置的结构示意图;
图9为本发明实施例提供的一种调试设备的结构示意图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
实施例一
本发明实施例提供一种调试方法,应用于如图1所示的远程调试系统,参见附图1,该远程调试系统包括目标机和宿主机,该目标机包括多核处理器,调试装置部署在所述宿主机内;其中,目标机和宿主机是不同的物理主机,目标机和宿主机之间通信连接。需要说明的是,在本发明实施例提供的技术方案中,所述多核处理器既可以是同构多核处理器,也可以是异构多核处理器。在目标机包括多个多核处理器的情况下,核A可以是该目标机中任一个多核处理器的任一个核,并不特指该目标机中的哪一个多核处理器的哪一个核。
本发明实施例提供的调试方法是一种交叉调试方法,是一种系统级调试方法,参见附图3,本发明实施例提供的调试方法包括下述步骤:
S101、所述核A执行完预设事件处理例程后开始停止运行,并在停止运行的过程中向其他核发送停止运行信号,所述停止运行信号用于是指所述其他核停止 运行,所述其他核是指位于所述多核处理器内、且与所述核A属于同一逻辑分组的所有核,所述预设事件为内核态代码的处理函数或用户态代码的处理函数;
如附图5所示,在本发明实施例中,预设事件的末尾添加了调试接口函数,该调试接口函数是位于预设事件外部的,不是预设事件的一部分。该调试接口函数的头部设置有第一调试异常指令,核A执行完该第一调试异常指令后将会停止运行;该调试接口函数的尾部还设置有第二调试异常指令,核A执行完该第二调试异常指令后也将停止运行。
具体的,所述核A执行完预设事件处理例程后开始停止运行,并在停止运行的过程中向其他核发送停止运行信号,包括:所述核A执行完所述预设事件处理例程后开始执行位于所述调试接口函数头部的所述第一调试异常指令,并在执行第一调试异常指令的过程中向所述其他核发送停止运行信号。需要说明的是,所述核A执行第一调试异常指令要经历一个时间段,所述核A先是开始执行第一调试异常指令,然后在执行完该第一调试异常指令之前的某个时刻,向所述其他核发送停止运行信号,并在向所述其他核发送停止运行信号之后,继续执行该第一调试异常指令,并在执行完该第一调试异常指令后,所述核A停止运行。
需要说明的是,同一逻辑分组包括的所有核均位于同一多核处理器,逻辑分组是调试人员根据经验,将具有业务上关联关系的多个核划分到同一逻辑分组。如附图1所示,核A、核B、核C和核D处于同一逻辑分组。则所述核A向其他核发送停止运行信号,具体是:所述核A向核B、核C和核D发送停止运行信号。
作为本发明的一个实施例,在目标机包括系统级芯片SOC,且该包括所述核A的多核处理器集成在该SOC的情况下,所述核A向其他核发送停止运行信号,所述停止运行信号用于指示所述其他核停止运行,具体为:所述核A通过所述SOC的硬件交叉触发网络向其他核发送停止运行信号,所述停止运行信号用于指示所述其他核停止运行。需要说明的是,所述核A通过所述SOC的硬件交叉触发网络向其他核发送恢复运行指令时是以广播的形式发送该恢复运行指令的。使用系统级芯片SOC的硬件交叉触发网络进行信号传递的优势在于:相对于使用软件进行信号传输来说,使用硬件进行信号传输,能够提高停止运行信号传输的时效性。
值得注意的是,业界通常将运行在内核空间代码称为内核态代码,将运行在用户空间的代码称为用户态代码。所述内核态代码的处理函数为内核模块的加载 函数;所述用户态代码的处理函数为进程的创建函数、进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数。容易得知的是,对于无论是非对称多处理(AMP,asymmetric multi-processing)结构下异构多核处理器上运行的多进程或多线程,还是对称多处理(SMP,Symmetric Multi-Processing)结构下同构多核处理器上运行的多进程或多线程,使用本发明实施例提供的技术方案,均可以实现同步调试。
S102、所述调试装置确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件之外的原因的情况下,所述调试装置向所述核A发送第一解除停止指令,所述第一解除停止指令用于指示所述核A恢复运行;
值得注意的是,步骤S101中,核A执行完预设事件处理例程后开始停止运行,并通知其他核停止运行;步骤S102中,所述调试装置向所述核A发送第一解除停止指令。方案这样设计的目的在于实现同步调试。参见附图1,核A、核B、核C和核D位于同一逻辑分组,核B、核C和核D中的至少一个(比如核B)上运行的代码与核A上运行的代码之间具有数据交互,则在核A调试期间,若核B继续运行,则核B上运行的代码可能因为不能与核A上运行的代码正确进行数据交互从而产生失真,所以在本发明实施例提供的方案中,在核A调试期间,与核A属于同一逻辑分组的其他核停止运行,避免产生失真。进一步的,先让核A与其他核同步停止运行,然后核A再恢复运行以进行调试。且为了实现核A与其他核同步停止运行,方案的设计还充分考虑到了核A发出的停止运行信号传输到其他核的时间,以及核A停止运行的时间,具体是在核A开始停止运行后,在停止运行的期间内向其他核发送停止运行指令,从而实现核A与其他核同步停止运行,进而实现比较精确的同步调试。
需要说明的是,目标机的内存中有预设存储空间,该预设存储空间是调试人员预先在目标机的内存中指定的,该预设存储空间的大小和地址均是固定的。该预设存储空间用于存储数据头,初始时,所述数据头包括第一缺省信息和数据体的地址,当然该第一缺省信息可以为空;该数据体包括第二缺省信息,当然该第二缺省信息也可以为空。
若核A是在执行完所述预设事件操作例程后停止执行的,则如图6.1所示,数据头包括的依然是第一缺省信息和数据体的位置,且数据体的内容为第二缺省 信息。相应的,在核A是在执行完所述预设事件操作例程后停止执行的情况下,S102中所述调试装置确定所述核A停止运行后,确定导致所述核A停止运行的原因,具体包括:调试装置轮询到所述核A停止运行后,通过读取数据头的内容判断导致核A停止运行的原因,由于数据头的内容包括第一缺省信息,所以调试装置根据所述第一缺省信息能够确定导致核A停止运行的原因为预设事件之外的原因。
参见附图4,作为本发明的一个实施例,所述调试装置包括调试代理和调试器,该调试装置应用在如图2所述的远程调试系统内,需要说明的是,调试代理和调试器可以位于相同的宿主机,也可以位于不同的宿主机,比如在附图2中,调试代理位于第一宿主机,调试器位于第二宿主机。在所述调试装置包括调试代理和调试器的情况下,如附图4所示,图3中的S102具体包括:
S202、所述调试代理轮询到所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件之外的原因的情况下,所述调试代理将第一消息上报给所述调试器,所述第一消息包括所述核A停止运行以及缺省标识;
在核A是在执行完所述预设事件操作例程后停止执行的情况下,结合前面详细解释的内容,可知S202具体包括:调试代理轮询到所述核A停止运行后,会通过读取数据头的内容判断导致核A停止运行的原因,由于数据头的内容包括第一缺省信息,所以调试代理根据所述第一缺省信息能够确定导致核A停止运行的原因为预设事件之外的原因,并会向调试器上报包括核A停止运行和缺省标识的第一消息。
S203、所述调试器接收所述第一消息后,指示所述调试代理向所述核A发送第一解除停止指令,所述第一解除停止指令用于指示所述核A恢复运行;
S204、所述调试代理向所述核A发送所述第一解除停止指令。
在所述调试装置包括调试代理和调试器的情况下,作为本发明的一个实施例,图3中的S102具体包括:
所述调试代理轮询到所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件之外的原因的情况下,所述调试代理向所述核A发送所述第一解除停止指令,所述第一解除停止指令用于指示所述核A恢复运行。
具体参见前面对步骤S402的解释,此处不再赘述。需要说明的是,在本发明实施例中,调试代理不再向调试器上报包括核A停止运行以及缺省标识的第一消息,而是在从数据头中读取到第一缺省信息、确定导致核A停止运行的原因为预设事件之外的原因后,调试代理向核A发送所述第一解除停止指令。在本实施例中,调试代理向核A发送第一解除停止指令是由于该调试代理确定导致核A停止运行的原因为预设事件之外的原因,而非像前述实施例那样,因为接收了调试器的指示而向核A发送第一解除停止指令。相对于前述实施例来说,本实施例中调试代理分担了调试器更多的工作,对调试器的功能要求更少,利于精简调试器。
S103、所述核A接收所述第一解除停止指令并恢复运行后,执行调试信息收集函数以收集所述预设事件的调试信息,并在执行完所述调试信息收集函数之后停止运行;
参见附图5,需要说明的是,调试信息收集函数包括位于添加在预设事件末尾的调试接口函数和与所述预设事件相关联的功能函数,与所述预设事件相关联的功能函数位于内核调试桩,该内核调试桩是预先植入在目标机的操作系统内的。
正如前面对S101的细化,该调试接口函数的头部设置有第一调试异常指令,尾部设置有第二调试异常指令,在执行该调试接口函数的过程中,会调用位于内核调试桩的与所述预设事件相关联的功能函数。
具体的,S103包括:所述核A执行与所述预设事件相关联的功能函数以收集所述预设事件的调试信息,然后执行位于所述该调试接口函数尾部的所述第二调试异常指令。在核A执行完所述第二调试异常指令后,所述核A将停止运行。
需要说明的是,所述预设事件的调试信息包括所述预设事件的标识、所述预设事件操作对象的标识;在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述预设事件的调试信息还包括所述预设事件操作对象的加载地址。可知,所述预设事件的调试信息的信息量是比较小的,通常仅有100行左右,所以采用本发明实施例提供的技术方案,可以降低目标机处理器处理的数据量,从而提高调试效率。
S104、所述调试装置确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件的情况下,所述调试装 置获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置所述预设事件操作对象;所述预设事件操作对象为所述内核态代码或所述用户态代码;
所述调试装置向所述核A发送第二解除停止指令,所述第二解除停止指令用于指示所述核A恢复运行;
需要说明的是,若核A是在执行完所述调试信息收集函数后停止运行的,则如图6.2所示,所述核A会在执行所述调试信息收集函数的过程中,将触发所述核A执行该调试信息收集函数的预设事件的标识写入所述数据头以替代缺省信息;将预设事件操作对象的标识写入数据体;以及,在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,核A还会将预设事件操作对象的加载地址写入数据体。值得关注的是,预设事件操作对象的加载地址可以是连续的,也可以是不连续的。容易理解的是,在所述预设事件为进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数的情况下,所述调试信息收集函数包括预设事件的标识和预设事件操作对象的标识;在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述调试信息收集函数包括预设事件的标识、预设事件操作对象的标识以及预设事件操作对象的加载地址。
相应的,在核A是在执行完所述调试信息收集函数后停止执行的情况下,S104中所述调试装置确定所述核A停止运行后,确定导致所述核A停止运行的原因,具体包括:调试装置轮询到所述核A停止运行后,通过读取数据头的内容判断导致核A停止运行的原因,由于数据头的内容包括预设事件的标识,所以调试装置能够根据所述预设事件的标识确定导致核A停止运行的原因为预设事件。
需要说明的是,S104中所述调试装置获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置所述预设事件操作对象,具体包括:
所述调试装置根据所述预设事件的标识确定所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述调试装置会根据位于数据头内的数据体的地址,从数据体读取所述预设事件操作对象的加载地址,然后根据所述预设事件操作对象的加载地址,将预先设置的悬挂断点设置到所述预 设事件操作对象的目的地址;当然,所述预设事件操作对象的目的地址位于所述预设事件操作对象的加载地址中;或者
所述调试装置根据所述预设事件的标识确定所述预设事件为进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数或线程的阻塞函数的情况下,所述调试装置会根据位于数据头内的数据体的地址,从数据体读取所述预设事件操作对象的标识,根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址,将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
值得注意的是,所述调试装置根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,是因为所述第二宿主机的存储空间预先存储了所述预设事件操作对象的标识与所述预设事件操作对象的加载地址的对应关系,则具体的,所述调试装置根据所述预设事件操作对象的标识以及所述对应关系,从所述第二宿主机的存储空间获取所述预设事件操作对象的加载地址。
结合附图6.1和6.2可知,在本发明实施例提供的技术方案中,在预设事件为内核模块的加载函数、进程的创建函数、进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数的情况下,若核A是在执行完所述调试信息收集函数后停止运行的,则数据头和数据体的内容如图6.2所示;若核A是因为其他事件而停止运行的,则数据头和数据体的内容如图6.1所示,自然该其他事件排除了执行完所述调试信息收集函数后的情况。也即数据头和数据体仅包括一条消息,调试装置从数据头中获取信息时,不需要分辨到底哪一条才是目标信息。且由于数据头和数据体仅包括一条消息,则位于目标机内存的所述预设存储空间的大小是固定的,且该预设存储空间占用的空间非常小,不会过多的占用目标机的存储资源,则提高信息获取的效率。
需要明确的是,在所述预设事件为内核模块的加载函数的情况下,所述预设事件操作对象为内核模块;在所述预设事件为进程的创建函数、进程的切换函数、进程的阻塞函数或进程的唤醒函数的情况下,所述预设事件操作对象为进程;在所述预设事件为线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数的情况下,所述预设事件操作对象为线程。其中,所述内核模块可以为动态补丁、热补丁、动态库等。
参阅附图4,作为本发明的一个实施例,所述调试装置包括调试代理和调试器,该调试装置应用在如图2所述的远程调试系统内,需要说明的是,调试代理和调试器可以位于相同的宿主机,也可以位于不同的宿主机,比如在附图2中,调试代理位于第一宿主机,调试器位于第二宿主机。在所述调试装置包括调试代理和调试器的情况下,如图4所示,图3中的S104具体包括:
S206、所述调试代理确定所述核A停止运行后,确定导致所述核A停止运行原因,在导致所述核A停止运行原因为所述预设事件的情况下,所述调试代理将第二消息上报给所述调试器,所述第二消息包括所述核A停止运行以及所述预设事件的标识;
需要说明的是,在核A是在执行完所述调试信息收集函数后停止执行的情况下,S206具体包括:调试代理轮询到所述核A停止运行后,会通过读取数据头的内容判断导致核A停止运行的原因,由于数据头的内容包括预设事件的标识,所以调试代理能够根据所述预设事件的标识确定导致核A停止运行的原因为所述预设事件,则所述调试代理向调试器上报包括核A停止运行和预设事件的标识的第二消息。
S207、所述调试器接收所述第二消息后,根据所述预设事件的标识获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置所述预设事件操作对象;
所述调试器指示所述调试代理向所述核A发送第二解除停止指令,所述第二解除停止指令用于指示所述核A恢复运行;
值得注意的是,所述调试器根据所述预设事件的标识获取所述预设事件的调试信息,具体包括:所述调试器根据所述预设事件的标识,从数据体读取所述预设事件操作对象的标识或所述预设事件操作对象的加载地址。
作为本发明的一种实施方式,在根据所述预设事件的标识确定所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述调试器会根据位于数据头内的数据体的地址,从数据体读取所述预设事件操作对象的加载地址,然后根据所述预设事件操作对象的加载地址,将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。当然,所述预设事件操作对象的目的地址位于所述预设事件操作对象的加载地址中。
作为本发明的另一种实施方式,在根据所述预设事件的标识确定所述预设事件为进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数或线程的阻塞函数的情况下,所述调试器会根据位于数据头内的数据体的地址,从数据体读取所述预设事件操作对象的标识,根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址,将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
值得注意的是,所述调试器根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,是因为所述第二宿主机的存储空间预先存储了所述预设事件操作对象的标识与所述预设事件操作对象的加载地址的对应关系,则具体的,所述调试器根据所述预设事件操作对象的标识以及所述对应关系,从所述第二宿主机的存储空间获取所述预设事件操作对象的加载地址。
需要说明的是,本发明实施例中所述预设事件操作对象的加载地址是指所述预设事件操作对象的目标码的加载地址,而所述预设事件操作对象的目标码的加载地址指的是所述预设事件操作对象的目标码在目标机侧的加载地址;所述预设事件操作对象的源码的加载地址是指所述预设事件操作对象的源码在所述第二宿主机侧的加载地址。则具体的,所述调试器根据所述预设事件操作对象的加载地址,将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址,包括:所述调试器根据所述预设事件操作对象的目标码的加载地址和所述预设事件操作对象的源码的加载地址之间的对应关系,组建符号表;然后所述调试器根据符号表,确定位于所述所述预设事件操作对象的目标码侧、且与所述悬挂断点(或者说pending断点)相映射的目标地址;并将所述悬挂断点设置到所述预设事件操作对象的目的地址。其中,悬挂断点(或者说pending断点)是调试人员预先设置在所述预设事件操作对象的源码侧的。
在本发明实施例中,“所述调试器指示所述调试代理发送第二解除停止指令”发生在“所述调试器将预先设置的悬挂断点设置到所述预设事件操作对象”之后。作为本发明的另一个实施例,“所述调试器指示所述调试代理发送第二解除停止指令”还可以发生在“所述调试器获取所述预设事件的调试信息”之后以及“所述调试器将预先设置的悬挂断点设置到所述预设事件操作对象”之前的任一时刻。
S208、所述调试代理向所述核A发送第二解除停止指令。
S105、所述核A接收所述第二解除停止指令并恢复运行后,向所述其他核发送恢复运行指令,所述恢复运行指令用于通知所述其他核恢复运行;
所述核A在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而进入调试状态。
正如前面对S301的解释,在目标机包括系统级芯片SOC,且该包括所述核A的多核处理器集成在该SOC的情况下,所述核A向其他核发送恢复运行指令,所述恢复运行指令用于通知所述其他核恢复运行,具体为:所述核A通过所述SOC的硬件交叉触发网络向所述其他核发送恢复运行指令,所述恢复运行指令用于通知所述其他核恢复运行。需要说明的是,所述核A通过所述SOC的硬件交叉触发网络向其他核发送恢复运行指令时是以广播的形式发送该恢复运行指令的。类似的,使用SOC的硬件交叉触发网络进行信号传递的优势在于:能够提高恢复运行指令传输的时效性。
由上可知,采用本发明实施例提供的调试方法,通过在运行在核A上的预设事件的末尾添加调试接口函数,该调试接口函数通过调用内核调试桩中与该预设事件的类型相关联的功能函数,获取该预设事件的调试信息;调试器根据该预设事件的调试信息可以将预先设置的悬挂断点设置该预设事件操作对象的目的地址,则核A在后续运行所述预设事件操作对象的过程中将会撞到所述悬挂断点,从而进入调试状态。因为在本发明实施例中,该预设事件为内核态代码的处理函数或用户态代码的处理函数,所以本发明实施例提供的技术方案实现了将内核态代码和用户态代码在同一个调试平台实现调试。
实施例二
参见附图7,本发明实施例包括一种多核处理器,应用于实施例一所述的调试方法中,且该多核处理器部署在如图1所示的远程调试系统的目标机内,如图7所示,该多核处理器包括核A、输入端口以及其他核,该其他核包括核B、核C和核D,其中,核B、核C和核D与核A均位于所述多核处理器、且属于同一逻辑分组。
所述核A用于在执行完预设事件处理例程后开始停止运行,并在停止运行的过程中向其他核发送停止运行信号,所述停止运行信号用于指示所述其他核停止运行,所述预设事件为内核态代码的处理函数或用户态代码的处理函数;
如附图5所示,在本发明实施例中,预设事件的末尾添加了调试接口函数,该调试接口函数是位于预设事件外部的,不是预设事件的一部分。该调试接口函数的头部设置有第一调试异常指令,核A执行完该第一调试异常指令后将会停止运行。所以,所述核A具体用于在执行完所述预设事件处理例程后开始执行位于所述调试接口函数头部的所述第一调试异常指令,并在执行所述第一调试异常指令的过程中向所述其他核发送停止运行信号。
作为本发明的一个实施例,在目标机包括系统级芯片SOC,且该包括所述核A的多核处理器集成在该SOC的情况下,则所述核A具体用于通过所述SOC的硬件交叉触发网络向其他核发送停止运行信号,所述停止运行信号用于指示所述其他核停止运行。需要说明的是,所述核A通过所述SOC的硬件交叉触发网络向其他核发送恢复运行指令时是以广播的形式发送该恢复运行指令的。使用系统级芯片SOC的硬件交叉触发网络进行信号传递的优势在于:提高停止运行信号传输的时效性。
值得注意的是,所述内核态代码的处理函数为内核模块的加载函数;所述用户态代码的处理函数为进程的创建函数、进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数。容易得知的是,对于无论是非对称多处理(AMP,asymmetric multi-processing)结构下异构多核处理器上运行的多进程或多线程,还是对称多处理(SMP,Symmetric Multi-Processing)结构下同构多核处理器上运行的多进程或多线程,使用本发明实施例提供的多核处理器,均可以实现同步调试。
参见附图7,核A、核B、核C和核D位于同一逻辑分组,核B、核C和核D中的至少一个(比如核B)上运行的代码与核A上运行的代码之间具有数据交互,则在核A调试期间,若核B继续运行,则核B上运行的代码可能因为不能与核A上运行的代码正确进行数据交互从而产生失真,所以在本发明实施例提供的方案中,在核A调试期间,与核A属于同一逻辑分组的其他核停止运行,避免产生失真。进一步的,先让核A与其他核同步停止运行,然后核A再恢复运行以进行调试。且为了实现核A与其他核同步停止运行,方案的设计还充分考虑到了核A发出的停止运行信号传输到其他核的时间,以及核A停止运行的时间,具体是在核A开始停止运行后,在停止运行的期间内向其他核发送停止运行指令,从而实现核A与其他核同步停止运行,进而实现比较精确的同步调试。
所述输入端口用于接收第一解除停止指令,并将所述第一解除停止指令转送给所述核A,所述第一解除停止指令是所述远程调试系统中的调试装置在确定所述核A停止运行且导致所述核A停止运行的原因为所述预设事件之外的原因后发送的;
所述核A还用于在接收第一解除停止指令并恢复运行后,执行调试信息收集函数以收集所述预设事件的调试信息,并在执行完所述调试信息收集函数之后停止运行;
参见附图5,需要说明的是,调试信息收集函数包括位于添加在预设事件末尾的调试接口函数和与所述预设事件相关联的功能函数,与所述预设事件相关联的功能函数位于内核调试桩,该内核调试桩是预先植入在目标机的操作系统内的。
该调试接口函数的尾部设置有第二调试异常指令,在执行该调试接口函数的过程中,会调用位于内核调试桩的与所述预设事件相关联的功能函数。
需要说明的是,所述核A具体用于执行与所述预设事件相关联的功能函数以收集所述预设事件的调试信息,然后执行位于所述该调试接口函数尾部的所述第二调试异常指令。在核A执行完所述第二调试异常指令后,所述核A将停止运行。
需要说明的是,所述预设事件的调试信息包括所述预设事件的标识、所述预设事件操作对象的标识;在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述预设事件的调试信息还包括所述预设事件操作对象的加载地址。可知,所述预设事件的调试信息的信息量是比较小的,通常仅有100行左右,所以采用本发明实施例提供的技术方案,可以降低目标机处理器处理的数据量,从而提高调试效率。
所述输入端口还用于接收第二解除停止指令,并将所述第二解除停止指令转送给所述核A,所述第二解除停止指令是所述调试装置根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象之后发送的;
需要明确的是,在所述预设事件为内核模块的加载函数的情况下,所述预设事件操作对象为内核模块;在所述预设事件为进程的创建函数、进程的切换函数、进程的阻塞函数或进程的唤醒函数的情况下,所述预设事件操作对象为进程;在所述预设事件为线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤 醒函数的情况下,所述预设事件操作对象为线程。其中,所述内核模块可以为动态补丁、热补丁、动态库等。
所述核A还用于在接收第二解除停止指令并恢复运行后,向所述其他核发送恢复运行指令,所述恢复运行指令用于通知所述其他核恢复运行;以及还用于在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而进入调试状态。
如前面所述,在所述目标机包括系统级芯片SOC,且该包括所述核A的多核处理器集成在该SOC的情况下,所述核A具体用于通过所述SOC的硬件交叉触发网络向所述其他核发送恢复运行指令,所述恢复运行指令用于通知所述其他核恢复运行。需要说明的是,所述核A通过所述SOC的硬件交叉触发网络向其他核发送恢复运行指令时是以广播的形式发送该恢复运行指令的。类似的,使用SOC的硬件交叉触发网络进行信号传递的优势在于:能够提高恢复运行指令传输的时效性。
由上可知,采用本发明实施例提供的多核处理器,通过在运行在核A上的预设事件的末尾添加调试接口函数,该调试接口函数通过调用内核调试桩中与该预设事件的类型相关联的功能函数,获取该预设事件的调试信息,使得调试装置根据该预设事件的调试信息将预先设置的悬挂断点设置该预设事件操作对象的目的地址;则核A在后续运行所述预设事件操作对象的过程中将会撞到所述悬挂断点,从而进入调试状态。因为在本发明实施例中,该预设事件为内核态代码的处理函数或用户态代码的处理函数,所以采用本发明实施例提供的多核处理器,能够实现了将内核态代码和用户态代码在同一个调试平台实现调试。
实施例三
参见附图8,本发明实施例包括一种调试装置,应用于实施例一所述的调试方法中,且该调试装置部署在如图1所示的远程调试系统的宿主机内,如图8所示,该调试装置包括调试单元和接收单元。
所述接收单元用于接收用于指示核A停止运行的消息,并将所述用于指示核A停止运行的消息转送给所述调试装置;其中,位于所述远程调试系统的目标机包括多核处理器,所述多核处理器包括所述核A;
所述调试单元用于在确定所述核A停止运行后,确定导致所述核A停止运行的原因;
在导致所述核A停止运行的原因为预设事件的情况下,所述调试单元还用于 获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象;所述预设事件为内核态代码的处理函数或用户态代码的处理函数;所述预设事件操作对象为所述内核态代码或所述用户态代码;
需要说明的是,所述内核态代码的处理函数为内核模块的加载函数,所述用户态代码的处理函数为进程的创建函数、进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数。在所述预设事件为内核模块的加载函数的情况下,所述预设事件操作对象为内核模块;在所述预设事件为进程的创建函数、进程的切换函数、进程的阻塞函数或进程的唤醒函数的情况下,所述预设事件操作对象为进程;在所述预设事件为线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数的情况下,所述预设事件操作对象为线程。其中,所述内核模块可以为动态补丁、热补丁、动态库等。
值得注意的是,目标机的内存中有预设存储空间,该预设存储空间是调试人员预先在目标机的内存中指定的,该预设存储空间的大小和地址均是固定的。该预设存储空间用于存储数据头,初始时,所述数据头包括第一缺省信息和数据体的地址,当然该第一缺省信息可以为空;该数据体包括第二缺省信息,当然该第二缺省信息也可以为空。
若核A是在执行完所述调试信息收集函数后停止运行的,则如图6.2所示,所述核A会在执行所述调试信息收集函数的过程中,将触发所述核A执行该调试信息收集函数的预设事件的标识写入所述数据头以替代缺省信息;将预设事件操作对象的标识写入数据体;以及,在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,核A还会将预设事件操作对象的加载地址写入数据体。值得关注的是,预设事件操作对象的加载地址可以是连续的,也可以是不连续的。
则在导致所述核A停止运行的原因为预设事件的情况下,所述调试单元具体用于在确定所述核A停止运行后,通过读取数据头的内容判断导致核A停止运行的原因,由于数据头的内容包括预设事件的标识,所以调试单元能够根据所述预设事件的标识确定导致核A停止运行的原因为预设事件。
进一步的,所述调试单元具体用于在根据所述预设事件的标识确定所述预设 事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,根据位于数据头内的数据体的地址,从数据体读取所述预设事件操作对象的加载地址,然后根据所述预设事件操作对象的加载地址,将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址;或者,
所述调试单元具体用于在根据所述预设事件的标识确定所述预设事件为进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数或线程的阻塞函数的情况下,根据位于数据头内的数据体的地址,从数据体读取所述预设事件操作对象的标识,根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址,将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
值得注意的是,因为所述第二宿主机的存储空间预先存储了所述预设事件操作对象的标识与所述预设事件操作对象的加载地址的对应关系,所以,所述调试单元具体用于根据所述预设事件操作对象的标识以及所述对应关系,从所述第二宿主机的存储空间获取所述预设事件操作对象的加载地址。
需要说明的是,在导致所述核A停止运行的原因为预设事件之外的原因的情况下,本发明实施例提供的调试装置中的所述调试单元还用于指示所述核A恢复运行以收集所述预设事件的调试信息。
具体的,在导致所述核A停止运行的原因为预设事件之外的原因的情况下,所述调试单元具体用于在确定所述核A停止运行后,通过读取数据头的内容判断导致核A停止运行的原因,由于数据头的内容包括所述第一缺省信息,所以调试单元能够根据所述第一缺省信息确定导致核A停止运行的原因为预设事件之外的原因。
作为本发明的一个实施例,如附图8所示,所述调试单元包括调试代理和调试器,需要说明的是,图8所示调试装置中的调试代理和调试器可以位于同一宿主机,也可以位于不同的宿主机,参见附图2所示的远程调试系统,调试代理和调试器分别位于不同的宿主机,其中,调试代理位于第一宿主机,调试器位于第二宿主机。
在所述调试单元包括调试代理和调试器,且在导致所述核A停止运行的原因为预设事件的情况下:
所述调试代理具体用于在确定所述核A停止运行后,确定导致所述核A停止 运行原因,在导致所述核A停止运行原因为所述预设事件的情况下,将第二消息上报给所述调试器,所述第二消息包括所述核A停止运行以及所述预设事件的标识;
进一步的,调试代理具体用于在轮询到所述核A停止运行后,通过读取数据头的内容中包括预设事件的标识,确定导致核A停止运行的原因为所述预设事件,向调试器上报包括核A停止运行和预设事件的标识的第二消息。
所述调试器具体用于接收所述第二消息后,根据所述预设事件的标识获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置所述预设事件操作对象。
进一步的,所述调试器具体用于根据所述第二消息中的所述预设事件的标识,从数据体读取所述预设事件操作对象的标识或所述预设事件操作对象的加载地址。
作为本发明的一种实施方式,在根据所述预设事件的标识确定所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述调试器具体用于根据位于数据头内的数据体的地址,从数据体读取所述预设事件操作对象的加载地址,然后根据所述预设事件操作对象的加载地址,将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
作为本发明的另一种实施方式,在根据所述预设事件的标识确定所述预设事件为进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数或线程的阻塞函数的情况下,所述调试器具体用于根据位于数据头内的数据体的地址,从数据体读取所述预设事件操作对象的标识,根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址,将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
值得注意的是,所述调试器根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,是因为所述第二宿主机的存储空间预先存储了所述预设事件操作对象的标识与所述预设事件操作对象的加载地址的对应关系,则具体的,所述调试器根据所述预设事件操作对象的标识以及所述对应关系,从所述第二宿主机的存储空间获取所述预设事件操作对象的加载地址。
作为本发明的另一个实施例,在所述调试单元包括调试代理和调试器,且在 导致所述核A停止运行的原因为预设事件之外的原因的情况下:
所述调试代理具体用于在确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件之外的原因的情况下,所述调试代理具体用于向所述核A发送第一解除停止指令,所述第一解除停止指令用于指示所述核A恢复运行以收集所述预设事件的调试信息。
进一步的,调试代理具体用于在轮询到所述核A停止运行后,读取数据头的内容包括第一缺省信息,根据所述第一缺省信息能够确定导致核A停止运行的原因为预设事件之外的原因。
作为本发明的再一个实施例,在所述调试单元包括调试代理和调试器,且在导致所述核A停止运行的原因为预设事件之外的原因的情况下:
所述调试代理具体用于在轮询到所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件之外的原因的情况下,将第一消息上报给所述调试器,所述第一消息包括所述核A停止运行以及缺省标识;
进一步的,调试代理具体用于在轮询到所述核A停止运行后,读取数据头的内容包括第一缺省信息,根据所述第一缺省信息能够确定导致核A停止运行的原因为预设事件之外的原因,将包括所述核A停止运行以及缺省标识上报给所述调试器。
所述调试器具体用于在接收所述第一消息后,指示所述调试代理向所述核A发送第一解除停止指令,所述第一解除停止指令用于指示所述核A恢复运行;
所述调试代理具体用于向所述核A发送所述第一解除停止指令。
所述调试单元还用于指示所述核A恢复运行,以使所述核A在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而使所述核A进入调试状态。
在所述调试单元包括调试代理和调试器的情况下,所述调试器具体用于指示所述调试代理向所述核A发送第二解除停止指令,所述第二解除停止指令用于指示所述核A恢复运行,以使所述核A在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而使所述核A进入调试状态。
由上可知,采用本发明实施例提供的调试装置,在确定目标机侧多核处理器的核A停止运行后,且在确定导致核A停止运行的原因为预设事件的情况下,该调试装置从目标机侧获取预设事件的调试信息,并根据预设事件的调试信息将预 先设置的悬挂断点设置到所述预设事件操作对象,从而实现对预设事件操作对象的调试。因为在本发明实施例中,该预设事件为内核态代码的处理函数或用户态代码的处理函数,所以预设事件操作对象为内核态代码或用户态代码,所以采用本发明实施例提供的调试装置,不仅能够实现了对内核态代码的调试,还能够实现对用户态代码的调试。
实施例四
参见附图9,为本发明实施例提供的一种调试设备900的结构框图,该调试设备900应用在如图1所示的远程调试系统中,且调试设备900为图1所示的远程调试系统中宿主机的一种具体实现方式。具体的,如图9所示,所述调试设备900包括:至少一个处理器901,至少一个网络接口904或者其他用户接口903,存储器905,至少一个通信总线902。所述通信总线902用于实现这些组件之间的连接通信。该调试设备900可选的包含用户接口903,包括显示器(例如,触摸屏、LCD、CTR、全息成像(Holographic)或者投影(Projector)等),键盘或者点击设备(例如,鼠标,轨迹球(trackball),触感板或者触摸屏等)。
存储器905可以包括只读存储器和随机存取存储器,并向处理器提供指令和数据。存储器905的一部分还可以包括非易失性随机存取存储器(NVRAM)。
在一些实施例中,存储器905存储了如下的元素,可执行模块或者数据结构,或者他们的子集,或者他们的扩展集:
操作系统9051,包含各种系统程序,例如框架层、核心库层、驱动层等,用于实现各种基础业务以及处理基于硬件的任务;
应用程序模块9052,包含各种应用程序,例如桌面(launcher)、媒体播放器(Media Player)、浏览器(Browser)等,用于实现各种应用业务。
在本发明实施例中,处理器901用于在确定所述核A停止运行后,确定导致所述核A停止运行的原因;位于所述远程调试系统的目标机包括多核处理器,所述多核处理器包括所述核A;
值得注意的是,目标机侧的内存中有预设存储空间,该预设存储空间是调试人员预先在目标机的内存中指定的,该预设存储空间的大小和地址均是固定的。该预设存储空间用于存储数据头,初始时,所述数据头包括第一缺省信息和数据体的地址,当然该第一缺省信息可以为空;该数据体包括第二缺省信息,当然该第二缺省信息也可以为空。
若核A是在执行完所述调试信息收集函数后停止运行的,则如图6.2所示,所述核A会在执行所述调试信息收集函数的过程中,将触发所述核A执行该调试信息收集函数的预设事件的标识写入所述数据头以替代缺省信息;将预设事件操作对象的标识写入数据体;以及,在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,核A还会将预设事件操作对象的加载地址写入数据体。值得关注的是,预设事件操作对象的加载地址可以是连续的,也可以是不连续的。若核A是因为其他原因停止运行的,则如图6.1所示,数据头包括的依然是第一缺省信息和数据体的地址,数据体包括的依然是第二缺省信息。
则处理器901具体用于在确定所述核A停止运行后,通过读取数据头的内容判断导致核A停止运行的原因,若数据头包括预设事件的标识,则确定导致所述核A停止运行的原因为预设事件;若数据头包括第一缺省信息,则确定导致所述核A停止运行的原因为预设事件之外的原因。
在导致所述核A停止运行的原因为预设事件的情况下,处理器901还用于获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象;所述预设事件为内核态代码的处理函数或用户态代码的处理函数,所述预设事件操作对象为内核态代码或用户态代码;
通过本实施例中前面的描述,能够确定所述预设事件的调试信息包括所述预设事件的标识和预设事件操作对象的标识,在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述预设事件的调试信息还包括预设事件操作对象的加载地址。
需要说明的是,所述内核态代码的处理函数为内核模块的加载函数,所述用户态代码的处理函数为进程的创建函数、进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数。在所述预设事件为内核模块的加载函数的情况下,所述预设事件操作对象为内核模块;在所述预设事件为进程的创建函数、进程的切换函数、进程的阻塞函数或进程的唤醒函数的情况下,所述预设事件操作对象为进程;在所述预设事件为线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数的情况下,所述预设事件操作对象为线程。
需要说明的是,在导致所述核A停止运行的原因为预设事件的情况下,处理 器901具体用于在根据所述预设事件的标识确定所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,根据位于数据头内的数据体的地址,从数据体读取所述预设事件操作对象的加载地址,然后根据所述预设事件操作对象的加载地址,将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址;或者,
处理器901用于在根据所述预设事件的标识确定所述预设事件为进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数或线程的阻塞函数的情况下,根据位于数据头内的数据体的地址,从数据体读取所述预设事件操作对象的标识,根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址,将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
值得注意的是,因为所述调试设备的存储空间预先存储了所述预设事件操作对象的标识与所述预设事件操作对象的加载地址的对应关系,所以,处理器901具体用于根据所述预设事件操作对象的标识以及所述对应关系,从所述第二宿主机的存储空间获取所述预设事件操作对象的加载地址。
所述存储器905用于存储所述预设事件的调试信息;
所述处理器901还用于指示所述核A恢复运行,以使所述核A在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而使所述核A进入调试状态。
作为本发明的另一个实施例,在导致所述核A停止运行的原因为预设事件之外的原因的情况下,处理器901还用于指示所述核A恢复运行以收集所述预设事件的调试信息。
由上可知,采用本发明实施例提供的调试设备,在确定目标机侧多核处理器的核A停止运行后,且在确定导致核A停止运行的原因为预设事件的情况下,该调试设备从目标机侧获取预设事件的调试信息,并根据预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象,从而实现对预设事件操作对象的调试。因为在本发明实施例中,该预设事件为内核态代码的处理函数或用户态代码的处理函数,所以预设事件操作对象为内核态代码或用户态代码,所以采用本发明实施例提供的调试设备,不仅能够实现了对内核态代码的调试,还能够实现对用户态代码的调试。
其中上述实施例之间可以相互参见,所属领域的技术人员可以清楚地了解 到,为描述的方便和简洁,上述描述的装置、设备和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的方法、装置和设备,可以通过其它的方式实现。本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本发明的范围。
应当理解的是,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应所述以权利要求的保护范围为准。

Claims (31)

  1. 一种调试方法,其特征在于,应用于远程调试系统中的目标机,所述目标机包括多核处理器,所述方法包括:
    所述多核处理器的核A执行完预设事件处理例程后开始停止运行,并在停止运行的过程中向其他核发送停止运行信号,所述停止运行信号用于指示所述其他核停止运行,所述其他核是指位于所述多核处理器内、且与所述核A属于同一逻辑分组的所有核,所述预设事件为内核态代码的处理函数或用户态代码的处理函数;
    所述核A接收第一解除停止指令并恢复运行后,执行调试信息收集函数以收集所述预设事件的调试信息,并在执行完所述调试信息收集函数之后停止运行;所述第一解除停止指令是所述远程调试系统中的调试装置在确定所述核A停止运行且导致所述核A停止运行的原因为所述预设事件之外的原因后发送的;
    所述核A接收第二解除停止指令并恢复运行后,向所述其他核发送恢复运行指令,所述恢复运行指令用于通知所述其他核恢复运行;所述第二解除停止指令是所述调试装置根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象之后发送的;
    所述核A在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而进入调试状态。
  2. 根据权利要求1所述的方法,其特征在于,
    所述调试信息收集函数包括调试接口函数,所述调试接口函数的头部设置有第一调试异常指令,所述第一调试异常指令用于指示所述核A停止运行;
    所述核A执行完预设事件处理例程后开始停止运行,并在停止运行的过程中向其他核发送停止运行信号,具体包括:
    所述核A执行完所述预设事件处理例程后开始执行位于所述调试接口函数头部的所述第一调试异常指令,并在执行所述第一调试异常指令的过程中向所述其他核发送所述停止运行信号。
  3. 根据权利要求2所述的方法,其特征在于,
    所述调试信息收集函数还包括与所述预设事件相关联的功能函数,且所述调试接口函数的尾部还设置有第二调试异常指令,所述第二调试异常指令用于指示所述核A停止运行;
    所述核A执行调试信息收集函数以收集所述预设事件的调试信息,并在执行完所述调试信息收集函数之后停止运行,具体包括:
    所述核A执行与所述预设事件相关联的功能函数以收集所述预设事件的调试信息,然后执行位于所述调试接口函数尾部的所述第二调试异常指令。
  4. 根据权利要求3所述的方法,其特征在于,
    所述与所述预设事件相关联的功能函数位于内核调试桩内,所述内核调试桩是预先植入在所述目标机操作系统内的。
  5. 根据权利要求1至4任一项所述的方法,其特征在于:
    所述内核态代码的处理函数为内核模块的加载函数;
    所述用户态代码的处理函数为进程的创建函数、进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数。
  6. 根据权利要求5所述的方法,其特征在于,
    在所述预设事件为所述内核模块的加载函数的情况下,所述预设事件操作对象为内核模块;
    在所述预设事件为所述进程的创建函数、所述进程的切换函数、所述进程的阻塞函数或所述进程的唤醒函数的情况下,所述预设事件操作对象为进程;
    在所述预设事件为所述线程的创建函数、所述线程的切换函数、所述线程的阻塞函数或所述线程的唤醒函数的情况下,所述预设事件操作对象为线程。
  7. 根据权利要求5或6所述的方法,其特征在于,所述预设事件的调试信息包括所述预设事件操作对象的标识;
    在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述预设事件的调试信息还包括所述预设事件操作对象的加载地址。
  8. 根据权利要求1至7任一项所述的方法,其特征在于,所述多核处理器集成在系统级芯片SOC上;
    所述核A向其他核发送停止运行信号,所述停止运行信号用于指示所述其他核停止运行,具体包括:
    所述核A通过所述SOC的硬件交叉触发网络向所述其他核发送停止运行信号,所述停止运行信号用于指示所述其他核停止运行;
    所述核A向所述其他核发送恢复运行指令,所述恢复运行指令用于通知所述 其他核恢复运行,具体包括:
    所述核A通过所述SOC的硬件交叉触发网络向所述其他核发送恢复运行指令,所述恢复运行指令用于通知所述其他核恢复运行。
  9. 一种调试方法,其特征在于,由部署于宿主机内的调试装置执行,所述宿主机位于远程调试系统,所述方法包括:
    所述调试装置确定核A停止运行后,确定导致所述核A停止运行的原因,所述核A属于所述远程调试系统中的目标机的多核处理器;
    在导致所述核A停止运行的原因为预设事件的情况下,所述调试装置获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象;所述预设事件为内核态代码的处理函数或用户态代码的处理函数;所述预设事件操作对象为内核态代码或用户态代码;
    所述调试装置指示所述核A恢复运行,以使所述核A在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而使所述核A进入调试状态。
  10. 根据权利要求9所述的方法,其特征在于,
    在导致所述核A停止运行的原因为预设事件之外的原因的情况下,所述调试装置指示所述核A恢复运行以收集所述预设事件的调试信息。
  11. 根据权利要求9或10所述的方法,其特征在于:
    所述内核态代码的函数为内核模块的加载函数;
    所述用户态代码的函数为进程的创建函数、进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数。
  12. 根据权利要求11所述的方法,其特征在于,
    在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述预设事件的调试信息包括所述预设事件操作对象的加载地址;
    所述调试装置获取所述预设事件的调试信息,并所述根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象,具体包括:
    所述调试装置获取所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
  13. 根据权利要求11所述的方法,其特征在于,
    在所述预设事件为进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数的情况下,所述预设事件的调试信息包括所述预设事件操作对象的标识;
    所述调试装置获取所述预设事件的调试信息,并所述根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象,具体包括:
    所述调试装置获取所述预设事件操作对象的标识,根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
  14. 根据权利要求13所述的方法,其特征在于,所述宿主机的存储空间预先存储了所述预设事件操作对象的标识与所述预设事件操作对象的加载地址的对应关系;
    所述根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,具体包括:
    根据所述预设事件操作对象的标识以及所述对应关系,从所述宿主机的存储空间获取所述预设事件操作对象的加载地址。
  15. 根据权利要求9至14任一项所述的方法,其特征在于,所述调试装置包括调试器和调试代理,
    所述调试装置确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为预设事件的情况下,所述调试装置获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象,具体包括:
    所述调试代理轮询到所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件的情况下,所述调试代理将第二消息上报所述调试器,所述第二消息包括所述核A停止运行以及所述预设事件的标识;
    所述调试器接收所述第二消息后,根据所述预设事件的标识获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象;
    所述调试装置指示所述核A恢复运行,具体包括:
    所述调试器指示所述调试代理向所述核A发送第二解除停止指令,所述第二 解除停止指令用于指示所述核A恢复运行。
  16. 根据权利要求15所述的方法,其特征在于,
    所述调试装置确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为预设事件之外的原因的情况下,所述调试装置指示所述核A恢复运行以收集所述预设事件的调试信息,具体包括:
    所述调试代理轮询到所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件之外的原因的情况下,所述调试代理向所述核A发送第一解除停止指令,所述第一解除停止指令用于指示所述核A恢复运行以收集所述预设事件的调试信息。
  17. 根据权利要求9至15任一项所述的方法,其特征在于,所述调试装置包括调试器和调试代理;
    所述调试装置确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为预设事件之外的原因的情况下,所述调试装置指示所述核A恢复运行以收集所述预设事件的调试信息,具体包括:
    所述调试代理轮询到所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件之外的原因的情况下,将第一消息上报给所述调试器,所述第一消息包括所述核A停止运行以及缺省标识,
    所述调试器接收所述第一消息后,指示所述调试代理向所述核A发送第一解除停止指令,所述第一解除停止指令用于指示所述核A恢复运行以收集所述预设事件的调试信息。
  18. 一种多核处理器,应用于远程调试系统中的目标机,其特征在于,所述多核处理器包括核A、其他核和输入端口,所述其他核是指位于所述多核处理器内、且与所述核A属于同一逻辑分组的所有核,其中:
    所述核A用于在执行完预设事件处理例程后开始停止运行,并在停止运行的过程中向其他核发送停止运行信号,所述停止运行信号用于指示所述其他核停止运行,所述预设事件为内核态代码的处理函数或用户态代码的处理函数;
    所述输入端口用于接收第一解除停止指令,并将所述第一解除停止指令转送给所述核A,所述第一解除停止指令是所述远程调试系统中的调试装置在确定所述核A停止运行且导致所述核A停止运行的原因为所述预设事件之外的原因后发送的;
    所述核A还用于在接收所述第一解除停止指令并恢复运行后,执行调试信息收集函数以收集所述预设事件的调试信息,并在执行完所述调试信息收集函数之后停止运行;
    所述输入端口还用于接收第二解除停止指令,并将所述第二解除停止指令转送给所述核A,所述第二解除停止指令是所述调试装置根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象之后发送的;
    所述核A还用于在接收所述第二解除停止指令并恢复运行后,向所述其他核发送恢复运行指令,所述恢复运行指令用于通知所述其他核恢复运行;以及还用于在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而进入调试状态。
  19. 根据权利要求18所述的多核处理器,其特征在于,
    所述调试信息收集函数包括调试接口函数,所述调试接口函数的头部设置有第一调试异常指令,所述第一调试异常指令用于指示所述核A停止运行;
    所述核A具体用于在执行完所述预设事件处理例程后开始执行位于所述调试接口函数头部的所述第一调试异常指令,并在执行所述第一调试异常指令的过程中向所述其他核发送所述停止运行信号。
  20. 根据权利要求19所述的多核处理器,其特征在于,
    所述调试信息收集函数还包括与所述预设事件相关联的功能函数,且所述调试接口函数的尾部还设置有第二调试异常指令,所述第二调试异常指令用于指示所述核A停止运行;
    所述核A具体用于执行与所述预设事件相关联的功能函数以收集所述预设事件的调试信息,然后执行位于所述调试接口函数尾部的所述第二调试异常指令。
  21. 根据权利要求20所述的多核处理器,其特征在于,
    所述与所述预设事件相关联的功能函数位于内核调试桩内,所述内核调试桩是预先植入在所述目标机操作系统内的。
  22. 根据权利要求18至21任一项所述的多核处理器,其特征在于,所述多核处理器集成在系统级芯片SOC上;
    所述核A具体用于通过所述SOC的硬件交叉触发网络向所述其他核发送停止运行信号,所述停止运行信号用于指示所述其他核停止运行;以及,
    所述核A具体用于通过所述SOC的硬件交叉触发网络向所述其他核发送恢复运行指令,所述恢复运行指令用于通知所述其他核恢复运行。
  23. 一种调试装置,其特征在于,所述调试设备部署在远程调试系统的宿主机内,所述调试设备包括调试单元和接收单元,
    所述接收单元用于接收用于指示核A停止运行的消息,并将所述用于指示所述核A停止运行的消息转送给所述调试单元;其中,位于所述远程调试系统的目标机包括多核处理器,所述多核处理器包括所述核A;
    所述调试单元用于在确定所述核A停止运行后,确定导致所述核A停止运行的原因;
    在导致所述核A停止运行的原因为预设事件的情况下,所述调试单元还用于获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象;所述预设事件为内核态代码的处理函数或用户态代码的处理函数;所述预设事件操作对象为内核态代码或用户态代码;
    所述调试单元还用于指示所述核A恢复运行,以使所述核A在运行所述预设事件操作对象的过程中撞到所述悬挂断点,从而使所述核A进入调试状态。
  24. 根据权利要求23所述的装置,其特征在于,
    在导致所述核A停止运行的原因为预设事件之外的原因的情况下,所述调试单元还用于指示所述核A恢复运行以收集所述预设事件的调试信息。
  25. 根据权利要求23或24所述的装置,其特征在于:
    所述内核态代码的函数为内核模块的加载函数;
    所述用户态代码的函数为进程的创建函数、进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的创建函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数。
  26. 根据权利要求25所述的装置,其特征在于,
    在所述预设事件为内核模块的加载函数、进程的创建函数或线程的创建函数的情况下,所述预设事件的调试信息包括所述预设事件操作对象的加载地址;
    所述调试单元具体用于获取所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
  27. 根据权利要求25所述的装置,其特征在于,
    在所述预设事件为进程的切换函数、进程的阻塞函数、进程的唤醒函数、线程的切换函数、线程的阻塞函数或线程的唤醒函数的情况下,所述预设事件的调试信息包括所述预设事件操作对象的标识;
    所述调试单元具体用于获取所述预设事件操作对象的标识,根据所述预设事件操作对象的标识确定所述预设事件操作对象的加载地址,并根据所述预设事件操作对象的加载地址将预先设置的悬挂断点设置到所述预设事件操作对象的目的地址。
  28. 根据权利要求27所述的装置,其特征在于,所述宿主机的存储空间预先存储了所述预设事件操作对象的标识与所述预设事件操作对象的加载地址的对应关系;
    所述调试单元具体用于根据所述预设事件操作对象的标识以及所述对应关系,从所述宿主机的存储空间获取所述所述预设事件操作对象的加载地址。
  29. 根据权利要求23至28任一项所述的装置,其特征在于,所述调试单元包括调试器和调试代理,
    所述调试代理具体用于在确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件的情况下,将第二消息上报所述调试器,所述第二消息包括所述核A停止运行以及所述预设事件的标识;
    所述调试器具体用于接收所述第二消息后,根据所述预设事件的标识获取所述预设事件的调试信息,并根据所述预设事件的调试信息将预先设置的悬挂断点设置到所述预设事件操作对象;
    所述调试器具体用于指示所述调试代理向所述核A发送第二解除停止指令,所述第二解除停止指令用于指示所述核A恢复运行。
  30. 根据权利要求29所述的装置,其特征在于,
    所述调试代理具体用于在确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件之外的原因的情况下,所述调试代理具体用于向所述核A发送第一解除停止指令,所述第一解除停止指令用于指示所述核A恢复运行以收集所述预设事件的调试信息。
  31. 根据权利要求23至29任一项所述的装置,其特征在于,所述调试装置还包括调试器和调试代理,
    所述调试代理具体用于在确定所述核A停止运行后,确定导致所述核A停止运行的原因,在导致所述核A停止运行的原因为所述预设事件之外的原因的情况下,将第一消息上报给所述调试器,所述第一消息包括所述核A停止运行以及缺省标识,
    所述调试器具体用于接收所述第一消息后,指示所述调试代理向所述核A发送第一解除停止指令,所述第一解除停止指令用于指示所述核A恢复运行以收集所述预设事件的调试信息。
PCT/CN2016/099996 2015-09-25 2016-09-24 一种调试方法、多核处理器和调试设备 WO2017050287A1 (zh)

Priority Applications (4)

Application Number Priority Date Filing Date Title
BR112018005588-3A BR112018005588B1 (pt) 2015-09-25 2016-09-24 Método de depuração, processador de múltiplos núcleos e dispositivo de depuração
KR1020187010961A KR102119585B1 (ko) 2015-09-25 2016-09-24 디버깅 방법, 멀티 코어 프로세서, 및 디버깅 장치
EP16848168.7A EP3352083B1 (en) 2015-09-25 2016-09-24 Debugging method, multi-core processor, and debugging equipment
US15/936,030 US10503629B2 (en) 2015-09-25 2018-03-26 Debugging method, multi-core processor, and debugging device

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510623830.4 2015-09-25
CN201510623830.4A CN105224454B (zh) 2015-09-25 2015-09-25 一种调试方法、多核处理器和调试设备

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US15/936,030 Continuation US10503629B2 (en) 2015-09-25 2018-03-26 Debugging method, multi-core processor, and debugging device

Publications (1)

Publication Number Publication Date
WO2017050287A1 true WO2017050287A1 (zh) 2017-03-30

Family

ID=54993439

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/099996 WO2017050287A1 (zh) 2015-09-25 2016-09-24 一种调试方法、多核处理器和调试设备

Country Status (6)

Country Link
US (1) US10503629B2 (zh)
EP (1) EP3352083B1 (zh)
KR (1) KR102119585B1 (zh)
CN (1) CN105224454B (zh)
BR (1) BR112018005588B1 (zh)
WO (1) WO2017050287A1 (zh)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10409709B2 (en) 2015-09-25 2019-09-10 Huawei Technologies Co., Ltd. Debugging method, multi-core processor and debugging device
CN110532164A (zh) * 2018-05-25 2019-12-03 瑞萨电子株式会社 半导体设备和调试方法
WO2020186518A1 (en) * 2019-03-21 2020-09-24 Hangzhou Fabu Technology Co. Ltd Method and apparatus for debugging, and system on chip
CN111708662A (zh) * 2020-05-26 2020-09-25 新华三技术有限公司 调试方法及装置
CN117785591A (zh) * 2024-02-27 2024-03-29 北京壁仞科技开发有限公司 用于计算设备的计算内核的调试方法、计算设备、计算机可读存储介质和计算机程序产品

Families Citing this family (18)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105224454B (zh) * 2015-09-25 2018-06-05 华为技术有限公司 一种调试方法、多核处理器和调试设备
US10025741B2 (en) * 2016-01-13 2018-07-17 Samsung Electronics Co., Ltd. System-on-chip, mobile terminal, and method for operating the system-on-chip
CN107015847A (zh) * 2016-01-28 2017-08-04 扬智科技股份有限公司 电子装置及其工作模式切换方法
CN105740119A (zh) * 2016-01-29 2016-07-06 华为技术有限公司 一种芯片及芯片内多核的调试方法
US10169133B2 (en) * 2016-04-26 2019-01-01 Juniper Networks, Inc. Method, system, and apparatus for debugging networking malfunctions within network nodes
CN106201896A (zh) * 2016-07-26 2016-12-07 华中科技大学 一种嵌入式环境下基于检查点的调试方法、系统及装置
CN106775732B (zh) * 2016-12-23 2019-02-12 优刻得科技股份有限公司 一种热补丁加载方法以及装置
US10579499B2 (en) 2017-04-04 2020-03-03 International Business Machines Corporation Task latency debugging in symmetric multiprocessing computer systems
US10606679B2 (en) * 2017-12-04 2020-03-31 Arm Limited Debug apparatus and method
KR102518370B1 (ko) * 2018-01-19 2023-04-05 삼성전자주식회사 저장 장치 및 이의 디버깅 시스템
CN109726135B (zh) * 2019-01-25 2022-06-14 嘉楠明芯(北京)科技有限公司 一种多核调试方法、装置及计算机可读存储介质
CN110300037A (zh) * 2019-08-06 2019-10-01 郭金海 一种网络设备调试台及调试系统
CN111639312B (zh) * 2020-06-02 2023-04-14 腾讯科技(成都)有限公司 反调试方法、装置、存储介质及电子装置
CN113051088B (zh) * 2021-03-31 2022-03-08 广州锦行网络科技有限公司 程序加载方法、装置、设备及计算机可读介质
CN113342554B (zh) * 2021-08-02 2022-01-04 阿里云计算有限公司 Io多路复用方法、介质、设备和操作系统
CN114035855B (zh) * 2021-09-30 2023-10-27 鸣芯信息科技(上海)有限公司 固件的调试方法、装置、终端及存储介质
KR20230059128A (ko) 2021-10-25 2023-05-03 한국전자통신연구원 코드 실행에 기반한 매니코어 병렬 프로세서의 프로그램 디버깅 방법 및 이를 위한 장치
CN114355802A (zh) * 2021-12-15 2022-04-15 中国航空工业集团公司成都飞机设计研究所 一种多核并起的处理器同步调试方法

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1779652A (zh) * 2004-11-24 2006-05-31 中兴通讯股份有限公司 一种调试操作系统内核态程序的方法及装置
CN102346708A (zh) * 2010-08-03 2012-02-08 中兴通讯股份有限公司 一种调试器及其调试方法
CN103729288A (zh) * 2013-11-01 2014-04-16 华中科技大学 一种嵌入式多核环境下应用程序的调试方法
WO2014166526A1 (de) * 2013-04-09 2014-10-16 Siemens Aktiengesellschaft Mehrkern-prozessorsystem mit fehleranalysefunktion
CN105224454A (zh) * 2015-09-25 2016-01-06 华为技术有限公司 一种调试方法、多核处理器和调试设备

Family Cites Families (32)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6886110B2 (en) 2000-11-21 2005-04-26 Wind River Systems, Inc. Multiple device scan chain emulation/debugging
US20040098639A1 (en) 2002-11-14 2004-05-20 Liu Bao Gang Debugging kernel-loadable modules and suspending and replacing functions in non-microkernel operating systems
US20050216895A1 (en) * 2004-03-23 2005-09-29 Tran Hieu T Method and apparatus for remote debugging of kernel and application software
CN1282085C (zh) 2004-04-09 2006-10-25 中兴通讯股份有限公司 一种嵌入式系统多任务并发调试的方法
US7941585B2 (en) * 2004-09-10 2011-05-10 Cavium Networks, Inc. Local scratchpad and data caching system
US7581087B2 (en) * 2006-01-17 2009-08-25 Qualcomm Incorporated Method and apparatus for debugging a multicore system
KR20070109432A (ko) * 2006-05-11 2007-11-15 삼성전자주식회사 커널 인지 디버깅 장치 및 방법
US7755154B2 (en) * 2006-08-01 2010-07-13 Dongbu Hitek Co., Ltd. Image sensor
US20100174892A1 (en) 2006-08-21 2010-07-08 Nxp, B.V. Multiprocessor system and method for synchronizing a debugging process of a multiprocessor system
EP2058725A3 (en) * 2007-06-11 2015-07-22 Mediatek Inc. Method of and apparatus for reducing power consumption within an integrated circuit
JP2008310727A (ja) * 2007-06-18 2008-12-25 Toshiba Corp シミュレーション装置及びシミュレーション方法
CN101398780B (zh) 2007-09-27 2011-08-24 国际商业机器公司 可基于进程定制调试器的即时调试的方法和系统
CN101685420B (zh) 2008-09-24 2013-06-12 中兴通讯股份有限公司 多线程调试方法和装置
CN101504626B (zh) 2009-03-06 2012-06-06 中兴通讯股份有限公司 一种调试控制实现方法及系统
CN101515251A (zh) 2009-03-31 2009-08-26 华为技术有限公司 板级平台调试方法、装置和系统
CN101540706B (zh) 2009-04-23 2011-12-28 中兴通讯股份有限公司 一种实现远程调试的方法及系统
US8832666B2 (en) * 2009-12-21 2014-09-09 International Business Machines Corporation Dynamic instrumentation
US8495344B2 (en) * 2010-01-22 2013-07-23 Via Technologies, Inc. Simultaneous execution resumption of multiple processor cores after core state information dump to facilitate debugging via multi-core processor simulator using the state information
US8533418B2 (en) 2010-06-30 2013-09-10 International Business Machines Corporation Memory allocation with identification of requesting loadable kernel module
US8635476B2 (en) * 2010-12-22 2014-01-21 Via Technologies, Inc. Decentralized power management distributed among multiple processor cores
CN102073565B (zh) 2010-12-31 2014-02-19 华为技术有限公司 触发操作方法、多核分组调试方法、装置及系统
US20130031419A1 (en) * 2011-07-28 2013-01-31 International Business Machines Corporation Collecting Debug Data in a Secure Chip Implementation
CN102521087B (zh) 2011-11-02 2014-11-19 烽火通信科技股份有限公司 一种远程获取内核模块实时分级调试信息的方法
CN104335220B (zh) 2012-03-30 2018-04-20 爱迪德技术有限公司 用于防止和检测安全威胁的方法和系统
US9304880B2 (en) 2013-03-15 2016-04-05 Freescale Semiconductor, Inc. System and method for multicore processing
WO2014158151A1 (en) 2013-03-27 2014-10-02 Intel Corporation Method and system for detecting concurrency programming errors in kernel modules and device drivers
CN103226504B (zh) 2013-04-19 2016-05-11 中国科学院自动化研究所 一种分布式片上调试系统
US9600397B2 (en) 2013-08-29 2017-03-21 Stmicroelectronics (Grenoble 2) Sas Dynamic debugging method of a software module and corresponding device
CN104750603B (zh) 2013-12-30 2018-12-11 辰芯科技有限公司 一种多核dsp软件仿真器及其物理层软件测试方法
US10102050B2 (en) * 2015-02-05 2018-10-16 Microchip Technology Incorporated System and method for generating cross-core breakpoints in a multi-core microcontroller
US9626265B2 (en) * 2015-06-29 2017-04-18 International Business Machines Corporation Efficiency of cycle-reproducible debug processes in a multi-core environment
US20170062075A1 (en) * 2015-08-31 2017-03-02 Sandisk Technologies Inc. Apparatus including core and clock gating circuit and method of operating same

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1779652A (zh) * 2004-11-24 2006-05-31 中兴通讯股份有限公司 一种调试操作系统内核态程序的方法及装置
CN102346708A (zh) * 2010-08-03 2012-02-08 中兴通讯股份有限公司 一种调试器及其调试方法
WO2014166526A1 (de) * 2013-04-09 2014-10-16 Siemens Aktiengesellschaft Mehrkern-prozessorsystem mit fehleranalysefunktion
CN103729288A (zh) * 2013-11-01 2014-04-16 华中科技大学 一种嵌入式多核环境下应用程序的调试方法
CN105224454A (zh) * 2015-09-25 2016-01-06 华为技术有限公司 一种调试方法、多核处理器和调试设备

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10409709B2 (en) 2015-09-25 2019-09-10 Huawei Technologies Co., Ltd. Debugging method, multi-core processor and debugging device
CN110532164A (zh) * 2018-05-25 2019-12-03 瑞萨电子株式会社 半导体设备和调试方法
CN110532164B (zh) * 2018-05-25 2024-01-09 瑞萨电子株式会社 半导体设备和调试方法
WO2020186518A1 (en) * 2019-03-21 2020-09-24 Hangzhou Fabu Technology Co. Ltd Method and apparatus for debugging, and system on chip
US11403206B2 (en) 2019-03-21 2022-08-02 Hangzhou Fabu Technology Co., Ltd. Method and apparatus for debugging, and system on chip
CN111708662A (zh) * 2020-05-26 2020-09-25 新华三技术有限公司 调试方法及装置
CN111708662B (zh) * 2020-05-26 2023-09-29 新华三技术有限公司 调试方法及装置
CN117785591A (zh) * 2024-02-27 2024-03-29 北京壁仞科技开发有限公司 用于计算设备的计算内核的调试方法、计算设备、计算机可读存储介质和计算机程序产品
CN117785591B (zh) * 2024-02-27 2024-04-26 北京壁仞科技开发有限公司 用于计算设备的计算内核的调试方法、计算设备、计算机可读存储介质和计算机程序产品

Also Published As

Publication number Publication date
EP3352083A1 (en) 2018-07-25
KR102119585B1 (ko) 2020-06-05
EP3352083A4 (en) 2018-09-05
KR20180054773A (ko) 2018-05-24
US20180217915A1 (en) 2018-08-02
EP3352083B1 (en) 2019-11-06
CN105224454A (zh) 2016-01-06
BR112018005588B1 (pt) 2023-12-26
US10503629B2 (en) 2019-12-10
BR112018005588A2 (zh) 2018-10-09
CN105224454B (zh) 2018-06-05

Similar Documents

Publication Publication Date Title
WO2017050287A1 (zh) 一种调试方法、多核处理器和调试设备
WO2017050286A1 (zh) 一种调试方法、多核处理器和调试设备
US9329958B2 (en) Efficient incremental checkpointing of virtual devices
US7971104B2 (en) Apparatus and methods for stabilization of processors, operating systems and other hardware and/or software configurations
US11307965B2 (en) Managing and maintaining multiple debug contexts in a debug execution mode for real-time processors
US20220197780A1 (en) Managing and maintaining multiple debug contexts in a debug execution mode for real-time processors
US20150161008A1 (en) Virtual machine crash management
US7353498B2 (en) Multi-process debugger
US20210334125A1 (en) Method and Apparatus for Resuming Running of Application, and Computer
US10795785B2 (en) Failover method, apparatus and system
WO2024012003A1 (zh) 数据处理方法、装置、设备、存储介质和程序产品
US11409636B2 (en) Processor including debug unit and debug system
CN113821257B (zh) 处理器内核调用栈信息查询方法及装置
US20120079338A1 (en) Memory system capable of increasing data transfer efficiency
US11216356B2 (en) Managing and maintaining multiple debug contexts in a debug execution mode for real-time processors
US9910760B2 (en) Method and apparatus for interception of synchronization objects in graphics application programming interfaces for frame debugging
US10229033B2 (en) System, method and apparatus for debugging of reactive applications
US20120311133A1 (en) Facilitating processing in a communications environment using stop signaling
CN104657229A (zh) 基于高可用性硬件检查点的多核处理器卷回恢复系统及其卷回恢复方法
CN106598755B (zh) 一种处理器及dcc通信系统
KR101649607B1 (ko) 가상화 운영체제 모니터링 방법, 이를 수행하는 가상화 운영체제 모니터링 장치 및 이를 저장하는 기록매체
KR20150117104A (ko) 호스트 기기 및 그것의 응용 프로그램 개발 방법

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16848168

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

REG Reference to national code

Ref country code: BR

Ref legal event code: B01A

Ref document number: 112018005588

Country of ref document: BR

ENP Entry into the national phase

Ref document number: 20187010961

Country of ref document: KR

Kind code of ref document: A

WWE Wipo information: entry into national phase

Ref document number: 2016848168

Country of ref document: EP

ENP Entry into the national phase

Ref document number: 112018005588

Country of ref document: BR

Kind code of ref document: A2

Effective date: 20180321