CN117290211A - Method and device for detecting system memory of computer, operating system and storage medium - Google Patents

Method and device for detecting system memory of computer, operating system and storage medium Download PDF

Info

Publication number
CN117290211A
CN117290211A CN202311140668.1A CN202311140668A CN117290211A CN 117290211 A CN117290211 A CN 117290211A CN 202311140668 A CN202311140668 A CN 202311140668A CN 117290211 A CN117290211 A CN 117290211A
Authority
CN
China
Prior art keywords
memory
memory access
computer
agent
instruction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311140668.1A
Other languages
Chinese (zh)
Inventor
彭元志
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kedong Guangzhou Software Technology Co Ltd
Original Assignee
Kedong Guangzhou Software Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kedong Guangzhou Software Technology Co Ltd filed Critical Kedong Guangzhou Software Technology Co Ltd
Priority to CN202311140668.1A priority Critical patent/CN117290211A/en
Publication of CN117290211A publication Critical patent/CN117290211A/en
Pending legal-status Critical Current

Links

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

Landscapes

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

Abstract

The embodiment of the invention provides a method, a device, an operating system and a storage medium for detecting the system memory of a computer, wherein the method comprises the following steps: the remote debugger tests the system memory of the computer through the debugging agent of the computer; when the memory access abnormality occurs, the computer enters a memory access abnormality processing function; when judging that the instruction causing the memory access exception is a memory access instruction of the debugging agent, the memory access exception handling function exits from running, and the computer returns to a memory error return instruction of the debugging agent; the memory error return instruction feeds back a memory access error code to the debugging agent; the debug agent stops the test and feeds back the system memory access error code to the remote debugger. According to the technical scheme provided by the embodiment of the invention, the remote debugger cannot be suspended when the memory access of the system of the computer is abnormal, so that the stability and usability of the debugging system are improved, the user experience is improved, and the problem investigation time is shortened.

Description

Method and device for detecting system memory of computer, operating system and storage medium
Technical Field
The present invention relates to the field of operating systems, and in particular, to a method and apparatus for detecting a system memory of a computer, an operating system, and a storage medium.
Background
Software debuggers help many embedded computer programmers find errors in embedded target computer programs.
The embedded debugger provides a cross debugging environment for a developer of the equipment software, and compared with local debugging, the remote cross debugging requires a GdbServer program, the GdbServer program and a target program are operated in a computer, and the GDB debugger and the GdbServer communicate through a network or a serial port and are debugged based on an RSP (reactive-load protocol) debugging protocol. Embedded software debuggers can be used to determine the cause of the problem, however conventional embedded software debuggers have capability limitations and often can only debug one type of embedded computer program, such as a user process, or a task in an embedded system. The operating system itself, and the service programs, interrupt handlers, etc. of the system, these programs also have debug requirements (operating system developers). However, these programs often cannot be debugged by software debugging tools provided to the user, but only by hardware emulators. The hardware simulator has the problems of high price, inconvenient connection and the like, and is not suitable for common users. Therefore, a system level debugging function needs to be provided, a host side debugger needs to read a large amount of memory during the debugging, the computer side debugger needs to ensure that no abnormality occurs during the reading and writing of the memory, otherwise, the computer side debugging cannot work normally, the debugging is interrupted, and the debugging use is unstable. The debugger can rely on the relevant mechanism provided by the operating system, such as an interface provided by the MMU to detect whether the memory is mapped and whether the memory has read permission, but when the operating system is debugged, the operating system does not initialize the MMU yet, and the functions cannot be used, so that an effective method needs to be provided for detecting whether the memory is readable and writable, if the memory cannot be read and written, an error code needs to be returned, and the debugger is not abnormal.
Disclosure of Invention
In view of this, the embodiments of the present invention provide a method, an apparatus, an operating system and a storage medium for detecting a system memory of a computer, where the method includes: the remote debugger tests the system memory of the computer through the debugging agent of the computer; when the memory access abnormality occurs, the computer enters a memory access abnormality processing function; when judging that the instruction causing the access exception is a memory access instruction of the debug agent, the memory access exception handling function exits from running, and the computer returns to a memory error return instruction of the debug agent; the memory error return instruction feeds back a memory access error code to the debugging agent; and stopping the test by the debugging agent according to the memory access error code, and feeding back the system memory access error code to the remote debugger. According to the technical scheme provided by the embodiment of the invention, the remote debugger cannot be suspended when the memory access of the system of the computer is abnormal, so that the stability and usability of the debugging system are improved, the user experience is improved, and the problem investigation time is shortened.
In a first aspect, an embodiment of the present invention provides a method for detecting a system memory of a computer, including: the remote debugger tests the system memory of the computer through the debugging agent of the computer; when the memory access abnormality occurs, the computer enters a memory access abnormality processing function; when judging that the instruction causing the memory access exception is a memory access instruction of the debugging agent, the memory access exception processing function exits from running, and the computer returns to a memory error return instruction of the debugging agent; the memory error return instruction feeds back a memory access error code to the debugging agent; and stopping the test by the debugging according to the memory access error code proxy, and feeding back a system memory access error code to a remote debugger.
By the method, when the memory access abnormality occurs, the computer enters a memory access abnormality processing function, and when the instruction causing the access abnormality is judged to be the memory access instruction of the debugging agent, the memory error return instruction of the debugging agent is returned, the remote debugger cannot be suspended when the memory access abnormality occurs in the system of the computer, so that the stability and the usability of the debugging system are improved, the user experience is improved, and the problem investigation time is shortened.
In a possible implementation manner of the first aspect, the memory access instruction includes an instruction for reading or writing the system memory of any address with any access width, where the access width is an integer multiple of bytes, and the instruction is obtained according to an operating system of the computer.
By the method, the system memory of each address is read or written in various access widths through the memory access instruction, so that the system memory of the target computer is comprehensively tested.
In one possible implementation manner of the first aspect, determining whether the instruction that causes the memory access exception is a memory access instruction of the debug agent specifically includes: and the memory access exception handling function judges whether the PC value of the context of the debugging agent is the PC value of any memory access instruction of the debugging agent.
By judging whether the PC value of the context of the debug agent is the PC value of any memory access instruction when the memory access abnormality occurs, the method judges whether the memory accessed when the memory access abnormality occurs or not.
In one possible implementation manner of the first aspect, the memory access exception handling function exits from running, and the memory error return instruction for returning the computer to the debug agent specifically includes: the memory access exception handling function modifies the PC value of the context of the debug agent to the PC value of the memory error return instruction, and then the memory access exception handling function exits operation; the computer returns an instruction to the PC value of the context of the debug agent.
When the PC value of the context of the debugging agent is the PC value of the current memory access instruction when the memory access abnormality occurs, the computer is returned to the memory error return instruction of the debugging agent by modifying the PC value of the context of the debugging agent so as to feed back the error code of the memory access abnormality.
In a possible implementation manner of the first aspect, the method further includes: the debug agent registers the memory access exception handling function.
By the method, the registered memory access exception handling function is operated when the memory access exception occurs, so that the remote debugger is prevented from being hung up.
In one possible implementation manner of the first aspect, the remote debugger tests the system memory of the computer through a debug agent of the computer, specifically including: the remote debugger calls the memory test interface through the debugging agent of the computer to test the system memory of the computer; the memory error return instruction is positioned in the memory test interface; the memory error return instruction feeds back a memory access error code to the debug agent, and specifically includes: and the memory error return instruction feeds back the memory access error code to the memory test interface, and the memory test interface feeds back the memory access error code to the debugging agent.
The debugging agent also provides a plurality of functions such as register test, breakpoint test and memory test, and the memory test interface provided by the debugging agent is used for testing the system memory and feeding back the memory access error code when the memory access abnormality occurs, so that the memory test and other remote tests of the target computer are completed by one debugging agent.
In a possible implementation manner of the first aspect, when the memory access exception occurs, the computer enters a memory access exception handling function, including specifically; when the memory access exception occurs, the computer enters an exception handling function corresponding to the memory access exception, and the exception handling function calls the memory access exception handling function.
By the method, the memory access exception handling function is called through the exception handling function corresponding to the memory access exception, an exception vector table of a computer is not required to be modified, and the memory access exception handling function is updated without affecting the exception handling function corresponding to the memory access exception.
In a second aspect, an embodiment of the present invention provides a system memory detection device of a computer, including: the remote memory detection module is used for testing the system memory of the computer through the debugging agent of the computer by the remote debugger; the access exception response module is used for enabling the computer to enter a memory access exception processing function when the memory access exception occurs; the access exception handling module is used for stopping the operation of the memory access exception handling function when judging that the instruction causing the memory access exception is the memory access instruction of the debugging agent, and returning the computer to the memory error return instruction of the debugging agent; the error local feedback module is used for feeding back a memory access error code to the debugging agent by the memory error return instruction; and the error remote feedback module is used for stopping the test according to the memory access error code by the debugging agent and feeding back the system memory access error code to the remote debugger.
By the method, when the memory access abnormality occurs, the computer enters a memory access abnormality processing function, and when the instruction causing the access abnormality is judged to be the memory access instruction of the debugging agent, the memory error return instruction of the debugging agent is returned, the remote debugger cannot be suspended when the memory access abnormality occurs in the system of the computer, so that the stability and the usability of the debugging system are improved, the user experience is improved, and the problem investigation time is shortened.
In one possible implementation manner of the second aspect, the memory access instruction includes an instruction for reading or writing the system memory of any address with any access width, where the access width is an integer multiple of bytes, and the instruction is obtained according to an operating system of the computer.
By the method, the system memory of each address is read or written in various access widths through the memory access instruction, so that the system memory of the target computer is comprehensively tested.
In one possible implementation manner of the second aspect, when determining whether the instruction that causes the memory access exception is a memory access instruction of the debug agent, the access exception handling module is specifically configured to determine, by using the memory access exception handling function, whether a PC value of a context of the debug agent is a PC value of any memory access instruction of the debug agent.
By judging whether the PC value of the context of the debug agent is the PC value of any memory access instruction when the memory access abnormality occurs, the method judges whether the memory accessed when the memory access abnormality occurs or not.
In one possible implementation manner of the second aspect, the access exception handling module is specifically configured to, when stopping the memory access exception handling function from exiting from running and returning the computer to the memory error return instruction of the debug agent: the memory access exception handling function modifies the PC value of the context of the debug agent to the PC value of the memory error return instruction, and then the memory access exception handling function exits operation; the computer returns an instruction to the PC value of the context of the debug agent.
When the PC value of the context of the debugging agent is the PC value of the current memory access instruction when the memory access abnormality occurs, the computer is returned to the memory error return instruction of the debugging agent by modifying the PC value of the context of the debugging agent so as to feed back the error code of the memory access abnormality.
In a possible implementation manner of the second aspect, the method further includes: and the exception handling registration module is used for registering the memory access exception handling function by the debugging agent.
By the method, the registered memory access exception handling function is operated when the memory access exception occurs, so that the remote debugger is prevented from being hung up.
In one possible implementation manner of the second aspect, the remote memory detection module is specifically configured to invoke, by the remote debugger, the memory test interface to test the system memory of the computer through the debug agent of the computer; the memory error return instruction is positioned in the memory test interface; the error local feedback module is specifically configured to: and the memory error return instruction feeds back the memory access error code to the memory test interface, and the memory test interface feeds back the memory access error code to the debugging agent.
The debugging agent also provides a plurality of functions such as register test, breakpoint test and memory test, and the memory test interface provided by the debugging agent is used for testing the system memory and feeding back the memory access error code when the memory access abnormality occurs, so that the memory test and other remote tests of the target computer are completed by one debugging agent.
In one possible implementation manner of the second aspect, the access exception response module is specifically configured to, when the memory access exception occurs, enter an exception handling function corresponding to the memory access exception, where the exception handling function calls the memory access exception handling function.
By the method, the memory access exception handling function is called through the exception handling function corresponding to the memory access exception, an exception vector table of a computer is not required to be modified, and the memory access exception handling function is updated without affecting the exception handling function corresponding to the memory access exception.
In a third aspect, an embodiment of the present invention provides an operating system, where a program is included that when executed by a computer is configured to perform a method according to any one of the embodiments of the first aspect.
In a fourth aspect, embodiments of the present invention provide a computing device comprising: a bus; a communication interface connected to the bus; at least one processor coupled to the bus; and at least one memory coupled to the bus and storing program instructions that, when executed by the at least one processor, cause the at least one processor to perform any of the embodiments of the first aspect of the invention.
In a fifth aspect, embodiments of the present invention provide a computer readable storage medium having stored thereon program instructions which when executed by a computer cause the computer to perform any of the embodiments of the first aspect of the present invention.
Drawings
FIG. 1A is a flowchart of a system memory detection method of a computer according to an embodiment of the present invention;
FIG. 1B is a vector table of the exception management of a processor according to a first embodiment of a system memory detection method of a computer according to the present invention;
FIG. 2A is a flowchart illustrating a system memory detection method according to a second embodiment of the present invention;
FIG. 2B is a pseudo code diagram of a read memory probe interface of a second embodiment of a system memory probe method of a computer according to the present invention;
FIG. 3 is a schematic diagram of a system memory detection device of a computer according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a second embodiment of a system memory detection device of a computer according to the present invention;
FIG. 5 is a schematic diagram of a computing device embodiment of the present invention.
Detailed Description
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is to be understood that "some embodiments" can be the same subset or different subsets of all possible embodiments and can be combined with one another without conflict.
In the following description, references to the terms "first/second/third, etc." or module a, module B, module C, etc. are used merely to distinguish between similar objects or between different embodiments, and do not represent a particular ordering of the objects, it being understood that particular orders or precedence may be interchanged as permitted so that embodiments of the invention described herein can be implemented in an order other than that illustrated or described herein.
In the following description, reference numerals indicating steps such as S110, S120, … …, etc. do not necessarily indicate that the steps are performed in this order, and the order of the steps may be interchanged or performed simultaneously as allowed.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to be limiting of the invention.
The embodiment of the invention provides a method, a device, an operating system and a storage medium for detecting the system memory of a computer, wherein the method comprises the following steps: the remote debugger tests the system memory of the computer through the debugging agent of the computer; when the memory access abnormality occurs, the computer enters a memory access abnormality processing function; when judging that the instruction causing the access exception is a memory access instruction of the debug agent, the memory access exception handling function exits from running, and the computer returns to a memory error return instruction of the debug agent; the memory error return instruction feeds back a memory access error code to the debugging agent; and stopping the test by the debugging agent according to the memory access error code, and feeding back the system memory access error code to the remote debugger. According to the technical scheme provided by the embodiment of the invention, the remote debugger cannot be suspended when the memory access of the system of the computer is abnormal, so that the stability and usability of the debugging system are improved, the user experience is improved, and the problem investigation time is shortened.
Embodiments of the present invention are described below with reference to the accompanying drawings.
First, a scene corresponding to the present invention is described. The embodiments of the present invention are used for detecting the system memory of the target computer at the host end, where the system memory is the core memory of the operating system on the target computer, and the host end may be a remote computer or a management computer with the target computer, and a remote debugger is installed on the host end for detecting the system memory of the target computer.
In an industrial control scenario, the target computer is an embedded working computer on site, the system memory of the target computer is the kernel memory of an industrial control operating system, and the host computer is an industrial control management computer.
Method embodiments of the present invention are described below in conjunction with fig. 1A-2B.
In a first embodiment of a system memory detection method of a computer, a remote debugger tests a system memory of a target computer through a debug agent of the target computer; when the memory access abnormality occurs, the target computer enters a memory access abnormality processing function; when judging that the instruction causing the access exception is a memory access instruction of the debug agent, the memory access exception handling function exits from running, and the target computer returns to a memory error return instruction of the debug agent; the memory error return instruction feeds back a memory access error code to the debugging agent; and stopping the test by the debugging agent according to the memory access error code, and feeding back the system memory access error code to the remote debugger.
Fig. 1A shows a flow of a system memory detection method embodiment of a computer, including steps S110 to S150.
S110: the remote debugger tests the system memory of the target computer through the debug agent of the target computer.
The system memory is a core memory of the target computer operating system, and can be a memory managed by a microkernel or a memory managed by a virtual machine operating system kernel.
The debugging agent runs on the target computer, and the IDE or GDB debugger at the host end can be connected with the debugging agent through a serial port or a network to communicate with the debugging agent. The debug agent itself provides the functions of setting breakpoints, deleting breakpoints, reading memory, writing memory, reading registers, writing registers, etc.
In some embodiments, the debug agent includes instructions to access the system memory of the target computer at any address in any access pattern with any access width, the access width being an integer multiple of bytes, including at least one of: single byte, double byte, 4 byte, and 8 byte to match the requirements of the operating system of the computer, access mode accesses include write mode and read mode.
In other embodiments, the remote debugger invokes the memory test interface through the debug agent of the target computer to test the system memory of the target computer. The memory test interface includes instructions for reading or writing the system memory of the target computer at any address with any access width, where the access width is an integer multiple of bytes, and at least includes one of the following: single byte, double byte, 4 byte, and 8 byte to match the operating system requirements of the computer.
In other embodiments, the memory test interface includes a read memory probe interface and a write memory probe interface. The read memory probe interface includes instructions to access the system memory at any address in a read mode with any of the access widths, and the write memory probe interface includes instructions to access the system memory at any address in a write mode with any of the access widths
S120: when the target computer has memory access abnormality, the target computer enters a memory access abnormality processing function.
Each processor provides exception management capability, supports an exception vector table, and when an exception occurs, the processor jumps to the fixed address corresponding to the exception to execute the exception handler. This fixed address is called an exception vector. Typically processors support undefined instruction, soft interrupt, memory access exception, interrupt, etc. exception types.
FIG. 1B illustrates a vector table of exception management for a processor, where memory management fault addresses are memory access exception vectors.
When the memory access abnormality occurs, the target computer enters an abnormality processing function corresponding to the memory access abnormality, and when the abnormality processing function is entered, the context of the debugging agent when the memory access abnormality occurs is saved.
In some embodiments, the address of the access exception corresponding exception handling function is also fixed by the operating system, and the target computer enters the exception handling function, which invokes the memory access exception handling function. The debug agent registers the memory access exception handling function so that it can be invoked by the exception handling function corresponding to the memory access exception.
In other embodiments, the contents of the exception handling function corresponding to the memory access exception are rewritten to the memory access exception handling function.
S130: when the instruction causing the memory access exception is judged to be the memory access instruction of the debugging agent, the memory access exception handling function exits the operation, and the target computer returns to the memory error return instruction of the debugging agent.
When the instruction causing the memory access exception is a memory access instruction of the debug agent, the address corresponding to the address currently tested by the memory access instruction of the debug agent in the system memory of the target computer can be considered as inaccessible.
In some embodiments, when the exception handling function of the system memory invokes the memory access exception handling function, determining whether the instruction causing the memory access exception is a memory access instruction of the debug agent specifically includes: the memory access exception handling function determines whether the saved PC value of the context of the debug agent is the PC value of any memory access instruction of the debug agent. Illustratively, when the read access is currently executed, judging whether the PC value of the context of the saved debug agent is the PC value of the read instruction with any access width in the memory access instructions of the debug agent; when the write access is currently executed, whether the PC value of the context of the saved debug agent is the PC value of the write instruction with any access width in the memory access instructions of the debug agent is judged.
In some embodiments, when the remote debugger invokes the memory test interface through the debug agent of the target computer to test the system memory of the target computer, a memory error return instruction is located in the memory test interface.
In some embodiments, before the memory access exception handling function exits from operation, the PC value of the context of the debug agent is modified to the PC value of the memory error return instruction, after which the memory access exception handling function exits from operation, the target computer returns to the instruction pointed to by the PC value of the context of the debug agent, i.e. returns to the memory error return instruction, so that the debug agent obtains the code of the system memory access error through the memory error return instruction.
In other embodiments, before the memory access exception handling function exits run, code is saved in the shared variable that modifies the system memory access error, the PC value of the context of the debug agent is the PC value of the read shared variable instruction, after which the memory access exception handling function exits run, the instruction pointed to by the PC value of the context of the target computer returned to the debug agent is returned to the read shared variable instruction, causing the debug agent to obtain the code of the system memory access error.
In some embodiments, when the instruction that causes the memory access exception is not a memory access instruction of the debug agent, the memory access exception handling function exits operation, and the target computer returns to the debug memory test interface, so that the memory test interface obtains a memory access normal return code.
From the above, in step S120, when the target computer has a memory access exception, the target computer enters a memory access exception handling function; in step S130, when it is determined that the instruction causing the memory access exception is a memory access instruction of the debug agent, the memory access exception handling function exits from operation, and the target computer returns to a memory error return instruction of the debug agent. This is another probing method of the system, not at the task level of the remote debugger or debug agent.
S140: the memory error return instruction feeds back a memory access error code to the debug agent.
In some embodiments, when the memory error return instruction is located in a memory test interface provided by the debug agent, the memory error return instruction feeds back a memory access error code to the memory test interface, which feeds back the memory access error code to the debug agent.
In some embodiments, the memory test interface stops the system memory test if it receives the memory access error code; and if the memory test interface receives the memory access normal return code, continuing the memory test.
S150: and stopping testing by the debugging agent according to the memory access error code, and feeding back the system memory access error code to the remote debugger.
When the remote debugger obtains the system memory access error code, the remote debugger is not suspended, and other programs perform corresponding analysis and obstacle avoidance work when obtaining the system memory access error code.
In some embodiments, when the debug agent tests the system memory of the target computer by invoking the memory test interface, the memory test interface receives the memory access error code, stops running, and feeds back the system memory access error code to the remote debugger.
In some embodiments, the system memory access error code is generated according to the memory access error code, the access pattern, and/or the access address and/or the access width, so that the remote debugger obtains more detailed information.
In summary, an embodiment of a method for detecting a system memory of a computer can detect whether a memory is accessible or not by using a memory detection technique of system level debug, and return a corresponding error code, so that a debugger cannot generate read-write memory exception, and the debugger is suspended and cannot be used. The stability and usability of the debugging system can be effectively improved through the memory detection technology, the user experience is improved, and the problem investigation time is shortened.
The second embodiment of the system memory detection method of the computer is a detailed implementation manner of the first embodiment of the system memory detection method of the computer, and has all the advantages of the first embodiment of the system memory detection method of the computer.
Fig. 2A shows a flow of a second embodiment of a system memory detection method of a computer, including steps S210 to S273.
S210: the debug agent registers the memory access exception handling function memProbeTrapHandle.
The debug agent is on the target computer, and the memory access exception handling function memProbeTrapHandle is a hook function for detecting memory access exceptions on the target computer, and is called by an exception handling function corresponding to the memory access exception when the memory access of the target computer is abnormal.
S220: the remote debugger tests the system memory through a memory test interface memTest provided by the debug agent.
The memory test interface memTest includes a read memory probe interface memProbeRead of a read mode and a memProbeRead of a write mode for reading and writing memory objects.
Fig. 2B illustrates a pseudo code of a read memory probe interface memProbeRead, comprising:
a byte access instruction memProbeByteRead, which is used for detecting the system memory of any address by taking the access width as a byte;
A word access instruction memProbeWordRead, which is used for detecting the system memory of any address by taking the access width as a word;
a 4-byte access instruction memProbeLongRead, configured to probe a system memory with an access width of 4 bytes for any address;
an 8-byte access instruction memProbelongLongRead; a system memory for probing any address with an access width of 8 bytes;
a memory error return instruction memProbeErrorrtn, configured to return a memory access error code;
and the memory normal return instruction memProbeOKRTn is used for returning a memory access normal return code.
The memory test interface memTest further includes a write memory probe interface memProbeWrite, which includes similar instructions as described above.
S223: the memory test interface memTest tests the system memory by the set address, access width and access mode.
For example, in this step, memTest calls the read memory probe interface memProbeRead, and uses memprobebytereread to perform read memory test on the system memory with set address in byte width.
S230: when the debug agent generates system memory access exception, the target computer enters an exception handling function corresponding to the exception, the context of the debug agent is saved, and the target computer enters a memory access exception handling function memProbeTrapHan.
The address of the abnormal processing function corresponding to the system memory access exception is set by the operating system, and the address of the memory access abnormal processing function memProbeTrapHand is registered to the abnormal processing function corresponding to the system memory access exception and is called by the abnormal processing function.
The branch of the memTest system memory with abnormal result enters the step, and the branch of the memTest system memory with normal result enters the step S273.
S240: memProbeTrapHandle determines whether the PC value in the context of the debug agent saved at the point of exception points to the corresponding instruction in the memTest test system memory.
If yes, step S250 is executed, otherwise step S253 is executed.
For example, in step S220, the memTest calls the read memory probe interface memProbeRead to test the byte read of the system memory with memprobebytereread, and this step determines whether the PC value in the context of the saved debug agent points to memprobebytereread.
S250: the PC value in the context of the saved debug agent, i.e. the return address, is set to memprobeerrrtn, returning it to memprobeerrrtn operation.
The memProbeErrorrtn is used for feeding back a memory access error code RET_FAIL to the memTest.
S260: the target computer returns to memProbeErrorrtn running, the memProbeErrorrtn feeds back the memory access error code to memTest, and returns to memTest running.
S270: the memTest feeds back a system memory access error code to the remote debugger and exits the operation.
After the system test is stopped in the step, the remote debugger is not suspended, and the access error code of the system memory is obtained, so that other modules can analyze and remove the obstacle.
In some embodiments, a system memory access error code is generated based on the memory access error code, the access pattern, the access width, and the access address to include more information.
S253: the PC value, i.e., the return address, in the saved context is set to memProbeOKRtn, returning it to memProbeOKRtn operation.
Wherein, memProbeOKRTn feeds back the normal return code of memory access to memTest, and the occurrence of system access abnormality is caused by other reasons and is not inaccessible to the system memory.
S263: the target computer returns to memProbeOKRTn operation, the memProbeOKRTn feeds back the memory access normal return code to memTest, and returns to memTest operation.
S273: the memTest sets the next test address in the system memory for testing, and returns to step S223.
Wherein, memTest tests all system memories in address cycle mode.
Embodiments of a system memory detection device for a computer according to the present invention are described below with reference to fig. 3 and 4.
A system memory detection device embodiment of a computer the method for performing a system memory detection method embodiment one of a computer has all the advantages of a system memory detection method embodiment one of a computer.
Fig. 3 shows a structure of a first embodiment of a system memory detection device of a computer, including: a remote memory detection module 310, an access exception response module 320, an access exception handling module 330, an error local feedback module 340, and an error remote feedback module 350.
The remote memory detection module 310 is used for a remote debugger to test the system memory of the target computer through a debug agent of the target computer. The working principle and advantages of the method refer to step S110 of the first embodiment of a system memory detection method of a computer.
The access exception response module 320 is configured to enter the memory access exception handling function when the target computer has a memory access exception. The working principle and advantages of the method refer to step S120 of the first embodiment of the system memory detection method of a computer.
The access exception handling module 330 is configured to, when it is determined that the instruction that causes the memory access exception is a memory access instruction of the debug agent, exit the operation of the memory access exception handling function, and return the target computer to a memory error return instruction of the debug agent. The working principle and advantages of the method refer to step S130 of the first embodiment of a system memory detection method of a computer.
The error local feedback module 340 is configured to feedback a memory access error code to the debug agent by using a memory error return instruction. The working principle and advantages of the method refer to step S140 of the first embodiment of the system memory detection method of the computer.
The error remote feedback module 350 is configured to stop the test by the debug agent according to the memory access error code, and feed back the system memory access error code to the remote debugger. The working principle and advantages of the method refer to step S150 of the first embodiment of the system memory detection method of a computer.
The second embodiment of the system memory detection device for a computer is used for executing the second embodiment of the system memory detection method for a computer, and has all the advantages of the second embodiment of the system memory detection method for a computer.
Fig. 4 shows a structure of a first embodiment of a system memory detection device of a computer, including: an exception handling registration module 410, a remote memory probe module 420, a system memory test module 423, an access exception response module 430, an access exception handling module 440, an error local feedback module 460, an error remote feedback module 470, a normal local feedback module 463, an address cycle setting module 473.
The exception handling registration module 410 is used to debug the proxy registration memory access exception handling function memProbeTrapHan. The working principle and advantages of the method refer to step S210 of the second embodiment of the system memory detection method of the computer.
The remote memory probe module 420 tests the system memory by a remote debugger through a memory test interface memTest provided by the debug agent. The working principle and advantages of the method refer to step S220 of the second embodiment of the system memory detection method of the computer.
The system memory test module 423 is configured to test the system memory by using the memory test interface memTest with a set address, an access width, and an access manner. The working principle and advantages of the method refer to step S223 of the second embodiment of the system memory detection method of a computer.
The access exception response module 430 is configured to, when the debug agent generates a system memory access exception, enable the target computer to enter an exception handling function corresponding to the exception, save the context of the debug agent, and enter a memory access exception handling function memProbeTrapHan. The working principle and advantages of the method refer to step S230 of the second embodiment of the system memory detection method of the computer.
The memory exception handling module 440 is configured to determine whether the PC value in the context of the debug agent stored at the time of the exception point points to a corresponding instruction of the memTest system memory. The working principle and advantages of the method refer to step S240 of the second embodiment of the system memory detection method of the computer.
The memory exception handling module 440 is further configured to set the PC value, i.e., the return address, in the context of the saved debug agent to memprobeErrorrtn, and return it to memProbeErrorrtn operation. The working principle and advantages of the method refer to step S250 of the second embodiment of the system memory detection method of the computer.
The error local feedback module 460 is used for returning the target computer to memProbeErrorrtn operation, and the memProbeErrorrtn feeds back the memory access error code to memTest, and returns to memTest operation. The working principle and advantages of the method refer to step S260 of the second embodiment of the system memory detection method of the computer.
The error remote feedback module 470 is configured to feed back the error code to the debug agent, and the debug agent feeds back the system memory access error code to the remote debugger, and exits from operation. The working principle and advantages of the method refer to step S270 of the second embodiment of the system memory detection method of the computer.
The memory exception handling module 440 is further configured to set the PC value, i.e., the return address, in the saved context to memProbeOKRtn, and return it to the memProbeOKRtn operation. The working principle and advantages of the method refer to step S253 of the second embodiment of the system memory detection method of the computer.
The normal local feedback module 463 is used for the target computer to return to memProbeOKRTn operation, and the memProbeOKRTn feeds back the memory access normal return code to memTest and returns to memTest operation. The working principle and advantages of the method refer to step S263 of the second embodiment of the system memory detection method of the computer.
The address cycle setting module 473 is configured to set the next test address in the system memory for testing. The working principle and advantages of the method refer to step S273 of the second embodiment of the system memory detection method of the computer.
The embodiment of the invention also provides a method for executing the system memory detection method embodiment of a computer or the system memory detection method embodiment of a computer when the program included in the operating system is executed by the computer.
An embodiment of the present invention further provides a computing device, which is described in detail in fig. 5 below.
The computing device 500 includes a processor 510, a memory 520, a communication interface 530, and a bus 540.
It should be appreciated that the communication interface 530 in the computing device 500 shown in this figure may be used to communicate with other devices.
Wherein the processor 510 may be coupled to a memory 520. The memory 520 may be used to store the program codes and data. Accordingly, the memory 520 may be a storage unit internal to the processor 510, an external storage unit independent of the processor 510, or a component including a storage unit internal to the processor 510 and an external storage unit independent of the processor 510.
Optionally, computing device 500 may also include a bus 540. The memory 520 and the communication interface 530 may be connected to the processor 510 via a bus 540. Bus 540 may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (EFStended Industry Standard Architecture, EISA) bus, among others. The bus 540 may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, only one line is shown in the figure, but not only one bus or one type of bus.
It should be appreciated that in embodiments of the present invention, the processor 510 may employ a central processing unit (central processing unit, CPU). The processor may also be other general purpose processors, digital signal processors (digital signal processor, DSP), application specific integrated circuits (application specific integrated circuit, ASIC), off-the-shelf programmable gate arrays (field programmable gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. Or the processor 510 may employ one or more integrated circuits for executing associated programs to carry out the techniques provided by embodiments of the present invention.
The memory 520 may include read only memory and random access memory, and provides instructions and data to the processor 510. A portion of the processor 510 may also include non-volatile random access memory. For example, processor 510 may also store information of the device type.
When the computing device 500 is running, the processor 510 executes computer-executable instructions in the memory 520 to perform the operational steps of the various method embodiments.
It should be understood that the computing device 500 according to the embodiments of the present invention may correspond to a respective subject performing the methods according to the embodiments of the present invention, and that the above and other operations and/or functions of the respective modules in the computing device 500 are respectively for implementing the respective flows of the methods according to the embodiments of the present method, and are not repeated herein for brevity.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, and are not repeated herein.
In the several embodiments provided by the present invention, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the method embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the decoding method according to the embodiments of the present invention. The storage medium includes various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk.
The embodiments of the present invention also provide a computer-readable storage medium having stored thereon a computer program for performing the operational steps of the method embodiments when executed by a processor.
The computer storage media of embodiments of the invention may take the form of any combination of one or more computer-readable media. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
Note that the above is only a preferred embodiment of the present invention and the technical principle applied. It will be understood by those skilled in the art that the present invention is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the invention. Therefore, while the invention has been described in connection with the above embodiments, the invention is not limited to the above embodiments, but may include many other equivalent embodiments without departing from the spirit of the invention, which fall within the scope of the invention.

Claims (10)

1. A method for detecting system memory of a computer, comprising:
the remote debugger tests the system memory of the computer through the debugging agent of the computer;
when the memory access abnormality occurs, the computer enters a memory access abnormality processing function;
when judging that the instruction causing the memory access exception is a memory access instruction of the debugging agent, the memory access exception processing function exits from running, and the computer returns to a memory error return instruction of the debugging agent;
the memory error return instruction feeds back a memory access error code to the debugging agent;
and stopping the test by the debugging agent according to the memory access error code, and feeding back the system memory access error code to the remote debugger.
2. The method of claim 1, wherein the memory access instructions comprise instructions to read or write the system memory at any address with any access width, the access width being an integer multiple of bytes, obtained from an operating system of the computer.
3. The method according to claim 1, wherein determining whether the instruction causing the memory access exception is a memory access instruction of the debug agent, specifically comprises:
And the memory access exception handling function judges whether the PC value of the context of the debugging agent is the PC value of any memory access instruction of the debugging agent.
4. The method according to claim 1, wherein the memory access exception handling function exits the operation, and the computer returns a memory error return instruction to the debug agent, comprising:
the memory access exception handling function modifies the PC value of the context of the debug agent to the PC value of the memory error return instruction, and then the memory access exception handling function exits operation;
the computer returns an instruction to the PC value of the context of the debug agent.
5. The method of claim 1, wherein the remote debugger tests the system memory of the computer through a debug agent of the computer, comprising: the remote debugger calls the memory test interface through the debugging agent of the computer to test the system memory of the computer;
the memory error return instruction is positioned in the memory test interface;
the memory error return instruction feeds back a memory access error code to the debug agent, and specifically includes: and the memory error return instruction feeds back the memory access error code to the memory test interface, and the memory test interface feeds back the memory access error code to the debugging agent.
6. The method as recited in claim 1, further comprising: the debug agent registers the memory access exception handling function.
7. The method according to claim 1, wherein when the memory access exception occurs, the computer enters a memory access exception handling function, comprising in particular;
when the memory access exception occurs, the computer enters an exception handling function corresponding to the memory access exception, and the exception handling function calls the memory access exception handling function.
8. A system memory probe device for a computer, comprising:
the remote memory detection module is used for testing the system memory of the computer by the remote debugger through the debugging agent of the computer;
the access exception response module is used for enabling the computer to enter a memory access exception processing function when the memory access exception occurs;
the access exception handling module is used for stopping the operation of the memory access exception handling function when judging that the instruction causing the memory access exception is the memory access instruction of the debugging agent, and returning the computer to the memory error return instruction of the debugging agent;
the error local feedback module is used for feeding back a memory access error code to the debugging agent by the memory error return instruction;
And the error remote feedback module is used for stopping the test according to the memory access error code by the debugging agent and feeding back the system memory access error code to the remote debugger.
9. An operating system comprising a program for performing the method of any of claims 1 to 7 when the program is executed by a computer.
10. A computer-readable storage medium, characterized in that a computer program is stored thereon, which program, when being executed by a computer, is adapted to carry out the method of any of claims 1 to 7.
CN202311140668.1A 2023-09-05 2023-09-05 Method and device for detecting system memory of computer, operating system and storage medium Pending CN117290211A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311140668.1A CN117290211A (en) 2023-09-05 2023-09-05 Method and device for detecting system memory of computer, operating system and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311140668.1A CN117290211A (en) 2023-09-05 2023-09-05 Method and device for detecting system memory of computer, operating system and storage medium

Publications (1)

Publication Number Publication Date
CN117290211A true CN117290211A (en) 2023-12-26

Family

ID=89243516

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311140668.1A Pending CN117290211A (en) 2023-09-05 2023-09-05 Method and device for detecting system memory of computer, operating system and storage medium

Country Status (1)

Country Link
CN (1) CN117290211A (en)

Similar Documents

Publication Publication Date Title
US6634020B1 (en) Uninitialized memory watch
US4910663A (en) System for measuring program execution by replacing an executable instruction with interrupt causing instruction
US7552425B2 (en) Implementing enhanced compiled breakpoint analysis
US20080244536A1 (en) Evaluating static analysis results using code instrumentation
US8769504B2 (en) Method and apparatus for dynamically instrumenting a program
KR101019209B1 (en) Device of automatically extracting Interface of Embedded Software and Method thereof
US7237149B2 (en) Method and apparatus for qualifying debug operation using source information
US7783865B2 (en) Conditional data watchpoint management
US20070168979A1 (en) Transparent debugging of programs in dynamic translation systems
US10599558B1 (en) System and method for identifying inputs to trigger software bugs
US7584383B2 (en) Method and system for kernel-level diagnostics using a hardware watchpoint facility
US20080270842A1 (en) Computer operating system handling of severe hardware errors
US20060277371A1 (en) System and method to instrument references to shared memory
US8117499B2 (en) Generation of a stimuli based on a test template
US20160299859A1 (en) Apparatus and method for external access to core resources of a processor, semiconductor systems development tool comprising the apparatus, and computer program product and non-transitory computer-readable storage medium associated with the method
US9639451B2 (en) Debugger system, method and computer program product for utilizing hardware breakpoints for debugging instructions
US20080010536A1 (en) Breakpoints with Separate Conditions
US20240289257A1 (en) Method for testing a computer program
US8230413B2 (en) Detecting incorrect versions of files
US7526756B2 (en) Address watch breakpoints with basing pointers
US9009671B2 (en) Crash notification between debuggers
US9069900B2 (en) Method for determining whether a machine code instruction of a machine code program is executed in the machine code program
CN111367742A (en) Method, device, terminal and computer readable storage medium for debugging MVP processor
US7100027B1 (en) System and method for reproducing system executions using a replay handler
CN117290211A (en) Method and device for detecting system memory of computer, operating system and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination