KR20080044652A - Method for debugging by using stack of cpu - Google Patents

Method for debugging by using stack of cpu Download PDF

Info

Publication number
KR20080044652A
KR20080044652A KR1020060113943A KR20060113943A KR20080044652A KR 20080044652 A KR20080044652 A KR 20080044652A KR 1020060113943 A KR1020060113943 A KR 1020060113943A KR 20060113943 A KR20060113943 A KR 20060113943A KR 20080044652 A KR20080044652 A KR 20080044652A
Authority
KR
South Korea
Prior art keywords
register
memory
entry
value
cpu
Prior art date
Application number
KR1020060113943A
Other languages
Korean (ko)
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 KR1020060113943A priority Critical patent/KR20080044652A/en
Publication of KR20080044652A publication Critical patent/KR20080044652A/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1497Details of time redundant execution on a single processing unit
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software

Abstract

A debugging method using a stack of a CPU is provided to perform a smooth debugging though a user makes a program excluding a dangerous attempt code and then there occurs a problem. A debugging method comprises the following several steps. A CPU having a set amount of stacks in its inner space determines whether an instruction to a memory or to a register is performed(S201). In case of the instruction to the memory, the CPU receives an entry from plural executing codes records via a core and records the entry at the stacks wherein the entry is composed of changed position of a memory, a value before data is changed and a value after data is changed whenever the data at the memory is changed(S203). In case of the instruction to the register, the CPU records an entry at the stacks wherein the entry is composed of an address of the register, a value before data at the register is changed and a value after data at the register is changed(S205). If there occurs an error, the CPU executes a debugging unit(S207,S209). The debugging unit debugs a value of the memory or the register to a state before data at the memory or the register is changed while reading the latest inputted data by using the entry of the changed value of the memory or the register stored at the stacks just before there occurs the error(S211).

Description

CPU에서의 스택을 이용한 디버깅 방법{METHOD FOR DEBUGGING BY USING STACK OF CPU}Debugging method using stack in CPU {METHOD FOR DEBUGGING BY USING STACK OF CPU}

도 1은 본 발명에 따른 CPU에서의 스택을 이용한 디버깅 방법을 수행하기 위한 블록 구성도,1 is a block diagram for performing a debugging method using a stack in a CPU according to the present invention;

도 2는 본 발명의 바람직한 실시예에 따른 CPU에서의 스택을 이용한 디버깅 방법에 대한 상세 흐름도.2 is a detailed flowchart of a debugging method using a stack in a CPU according to a preferred embodiment of the present invention.

<도면의 주요부분에 대한 부호의 설명><Description of the symbols for the main parts of the drawings>

101 : 메모리 1011-0,...,1011-n : INS 0,..., INS n101: Memory 1011-0, ..., 1011-n: INS 0, ..., INS n

1013 : 데이터부 103 : CPU1013: data portion 103: CPU

1031 : 코어 1033 : 레지스터1031: Core 1033: Register

1035 : 스택(Stack) 1037 : 디버깅부1035: stack 1037: debugging unit

본 발명은 중앙 처리 장치(Central Processing Unit, CPU)에서의 스택을 이용한 디버깅 방법에 관한 것으로, 보다 상세하게는 CPU에서 일정량 만큼의 메모리 값 혹은 레지스터 값의 변화를 스택(Stack)에 기록한 다음에, 원하지 않는 돌발 상 황이 발생될 경우 가장 최근에 기록된 값을 역순으로 복원하면서 디버깅할 수 있는 방법에 관한 것이다. The present invention relates to a debugging method using a stack in a central processing unit (CPU), and more particularly, after recording a change in a certain amount of memory value or register value in a CPU, It is about a method that can be debugged by restoring the most recently recorded value in the reverse order in case of an unexpected unexpected situation.

주지된 바와 같이, CPU는 컴퓨터 및 각종 전자제품 등의 시스템 전체를 제어하는 장치로서, 다양한 입력장치로부터 자료를 받아서 처리한 후 그 결과를 출력장치로 보내는 일련의 과정을 제어하고 조정하는 일을 수행한다.As is well known, the CPU is a device that controls the entire system such as a computer and various electronic products, and controls and adjusts a series of processes that receive data from various input devices and process the results, and then send the result to the output device. do.

이러한 CPU는 비교, 판단, 연산을 담당하는 논리연산장치(arithmetic logic unit)와 명령어의 해석과 실행을 담당하는 제어장치(control unit)로 구성된다. 논리연산장치(ALU)는 각종 덧셈을 수행하고 결과를 수행하는 가산기(adder)와 산술과 논리연산의 결과를 일시적으로 기억하는 레지스터인 누산기(accumulater), 중앙처리장치에 있는 일종의 임시 기억장치인 레지스터(register) 등으로 구성되어 있다.The CPU is composed of an arithmetic logic unit that is responsible for comparison, determination, and operation, and a control unit that is responsible for interpreting and executing instructions. An ALU is an adder that performs various additions and results, an accumulator which is a register that temporarily stores the result of arithmetic and logic operations, and a register that is a kind of temporary storage device in a central processing unit. (register) or the like.

더불어, 제어장치는 프로그램의 수행 순서를 제어하는 프로그램 계수기(program counter), 현재 수행중인 명령어의 내용을 임시 기억하는 명령 레지스터(instruction register), 명령 레지스터에 수록된 명령을 해독하여 수행될 장치에 제어신호를 보내는 명령해독기(instruction decoder)로 이루어져 있다. 즉, CPU는 외부 메모리(예컨대, RAM, ROM,.. 등)에 연결되어 메모리내 데이터부에 저장된 각종 데이터의 코드를 읽어와서 기계어 명령(Instruction)을 실행하는 것이다. In addition, the control device includes a program counter for controlling the execution order of the program, an instruction register for temporarily storing the contents of the currently executing instruction, and a control signal to a device to be executed by decoding the instruction contained in the instruction register. It consists of an instruction decoder that sends. In other words, the CPU is connected to an external memory (for example, RAM, ROM, ...) to read the code of various data stored in the data portion in the memory to execute a machine language instruction (Instruction).

그러나, 상술한 바와 같이 구성된 CPU가 메모리에 저장된 데이터의 코드를 읽어와서 기계어 명령을 실행하는 중에 원하지 않는 상황, 즉 에러가 발생될 경우 해당 작업의 실행이 갑자기 중지됨에 따라 CPU의 상태를 재부팅하여 처음부터 다시 진행해야 하므로, 에러가 발생되기 바로 이전 메모리 값 및 레지스터 값의 변화를 기억하고 있지 못하여 결국 비정상적으로 디버깅을 수행할 수 밖에 없는 문제점을 갖는다. However, when the CPU configured as described above reads the code of data stored in the memory and executes a machine command, an unwanted situation, that is, an error occurs, suddenly stops the execution of the task and reboots the CPU state for the first time. Since it is necessary to proceed from the beginning, it does not remember the change of the memory value and the register value just before the error occurs, and thus has the problem that the debugging is abnormally performed.

이에, 본 발명은 상기와 같은 문제점을 해결하기 위해 안출한 것으로, 그 목적은 CPU에서 일정량 만큼의 메모리 값 혹은 레지스터 값의 변화를 스택(Stack)에 기록한 다음에, 원하지 않는 돌발 상황이 발생될 경우 가장 최근에 기록된 값을 역순으로 복원하면서 디버깅할 수 있는 CPU에서의 스택을 이용한 디버깅 방법을 제공함에 있다. Accordingly, the present invention has been made to solve the above problems, the object of which is to write a change of a certain amount of memory value or register value on the stack in the CPU, when an unexpected accident occurs It provides a debugging method using the stack on the CPU that can be debugged while restoring the most recently recorded value in reverse order.

상술한 목적을 달성하기 위한 본 발명에서 CPU에서의 스택을 이용한 디버깅 방법은 메모리로의 명령 수행인 경우, 메모리에 저장된 데이터의 변화가 있을 때마다 변화된 메모리 엔트리를 다수의 실행 코드를 통해 제공받아 스택에 기록하는 과정과, 레지스터로의 명령 수행인 경우, 레지스터의 변화가 있을때마다 변화된 레지스터 엔트리를 스택에 기록하는 과정과, CPU에서 에러가 발생될 경우, 스택에 저장된 에러가 발생되기 바로 이전 엔트리를 이용하여 가장 최근에 들어온 것부터 읽어나가면서 메모리 혹은 레지스터의 값을 변화되기 이전으로 디버깅하는 과정을 포함하는 것을 특징으로 한다. In the present invention to achieve the above object, a debugging method using a stack in a CPU is provided when the instruction is stored in a memory and receives a changed memory entry through a plurality of execution codes whenever there is a change in data stored in the memory. In the case of writing to the register, executing the instruction to the register, writing the changed register entry to the stack whenever there is a change in the register, and if an error occurs in the CPU, the entry immediately before the error stored in the stack occurs. It includes the process of debugging the memory or register value before changing it by reading from the most recent one.

이하, 본 발명의 실시 예는 다수개가 존재할 수 있으며, 이하에서 첨부한 도면을 참조하여 바람직한 실시 예에 대하여 상세히 설명하기로 한다. 이 기술 분야의 숙련자라면 이 실시 예를 통해 본 발명의 목적, 특징 및 이점들을 잘 이해하게 될 것이다. Hereinafter, a plurality of embodiments of the present invention may exist, and a preferred embodiment will be described in detail with reference to the accompanying drawings. Those skilled in the art will appreciate the objects, features and advantages of the present invention through this embodiment.

도 1은 본 발명에 따른 CPU에서의 스택을 이용한 디버깅 방법을 위한 개략적인 블록 구성도로서, 다수의 실행 코드인 INS 0,..., INS n(1011-0,...,1011-n) 및 각종 데이터를 저장하고 있는 데이터부(1013)를 갖는 메모리(101)와, 메모리(101)와 스택(1035)간에 위치하여 메모리(101) 변화 값의 엔트리를 스택(1035)에 기록하도록 제공하는 코어(1031)와, 산술과 논리연산의 결과를 일시적으로 기억하고 있다가 레지스터(1033) 변화 값의 엔트리를 스택(1035)에 제공하는 레지스터(1033)와, 코어(1035)를 통해 제공되는 메모리(101) 변화 값의 엔트리 혹은 레지스터(1033) 변화 값의 엔트리를 기록하고 있다가 공간이 꽉 차게되면 가장 오래 전에 기록된 엔트리를 지워 새로운 엔트리가 기록될 공간을 확보하는 스택(1035)과, 원하지 않는 상황 즉 에러가 발생될 경우, 에러가 발생되기 바로 이전 메모리(101) 변화 값의 엔트리 혹은 레지스터(1033) 변화 값의 엔트리를 이용하여 가장 최근에 들어온 것부터 읽어나가면서 메모리(101) 혹은 레지스터(1033)의 값을 변화되기 이전으로 디버깅을 수행하는 디버깅부(1037)를 갖는 CPU(103)를 포함한다.1 is a schematic block diagram for a debugging method using a stack in a CPU according to the present invention, a plurality of executable code INS 0, ..., INS n (1011-0, ..., 1011-n Memory 101 having a data portion 1013 storing various data, and located between the memory 101 and the stack 1035 so as to record an entry of the memory 101 change value in the stack 1035. A register 1033 which temporarily stores the result of arithmetic and logical operations, and provides an entry of the register 1033 change value to the stack 1035, and is provided through the core 1035. A stack 1035 which records the entry of the change value of the memory 101 or the entry of the change value of the register 1033, and when the space becomes full, the oldest recorded entry is erased to secure a space for writing a new entry; If an undesired situation occurs, such as an error, A debugging unit that performs debugging before changing the value of the memory 101 or the register 1033 by reading from the most recent entry using the entry of the change value of the previous memory 101 or the entry of the change value of the register 1033. And a CPU 103 having 1037.

다음에, 상술한 바와 같은 구성을 갖는 본 실시 예의 CPU에서의 스택을 이용한 디버깅 과정에 대하여 설명한다. Next, the debugging process using the stack in the CPU of the present embodiment having the above-described configuration will be described.

도 2는 본 발명의 바람직한 실시 예에 따라 CPU에서의 스택을 이용한 디버깅 과정을 순차적으로 도시한 흐름도이다. 2 is a flowchart sequentially illustrating a debugging process using a stack in a CPU according to a preferred embodiment of the present invention.

먼저, CPU(103)는 내부에 일정량의 스택(1035)을 갖고 있으며, 메모리(101)로의 명령 수행인지 아니면 레지스터(1033)로의 명령 수행인지를 판단한다(S201).First, the CPU 103 has a certain amount of stack 1035 therein, and determines whether the instruction is executed to the memory 101 or the register 1033 (S201).

상기 판단(S201)결과, 메모리(101)로의 명령 수행인 경우, 메모리(101)내 데이터부(1013)에 저장된 데이터의 변화가 있을 때마다 변화된 기억장소 위치와 변화전의 값과 변화후의 값인 세가지 값으로 이루어진 엔트리(예컨대, 도 1의 스택내에 저장된 MEM 00xx, 35, 27)를 다수의 실행 코드인 INS 0,..., INS n(1011-0,...,1011-n)로부터 코어(1031)를 통해 제공받아 스택(1035)에 기록한다(S203).As a result of the determination (S201), in the case of performing a command to the memory 101, whenever there is a change in the data stored in the data unit 1013 in the memory 101, three values of the changed storage location, the value before the change and the value after the change are shown. (E.g., MEM 00xx, 35, 27 stored in the stack of FIG. 1) from the plurality of executable codes INS 0, ..., INS n (1011-0, ..., 1011-n) to the core ( 1031 is received through the stack 1035 and recorded (S203).

상기 판단(S201)결과, 레지스터(1011)로의 명령 수행인 경우, 레지스터(101)의 주소와 변화전의 값과 변화후의 값인 세가지 값으로 이루어진 엔트리(예컨대, 도 1의 스택내에 저장된 REG 0x, 2A, 9B)를 스택(1035)에 기록한다(S205). As a result of the determination (S201), when the instruction is executed to the register 1011, an entry consisting of three values, that is, the address of the register 101, the value before the change and the value after the change (for example, REG 0x, 2A, stored in the stack of FIG. 9B) is recorded in the stack 1035 (S205).

한편, CPU(103)는 원하지 않는 상황 즉 에러가 발생될 경우(S207), 디버깅부(1037)를 실행시킨다(S209).On the other hand, the CPU 103 causes the debugging unit 1037 to execute when an undesired situation, that is, an error occurs (S207).

그러면, 디버깅부(1037)는 스택(1035)에 저장된 에러가 발생되기 바로 이전 메모리(101) 변화 값의 엔트리 혹은 레지스터(1033) 변화 값의 엔트리를 이용하여 가장 최근에 들어온 것부터 읽어나가면서 메모리(101) 혹은 레지스터(1033)의 값을 변화되기 이전으로 디버깅을 수행한다(S211). Then, the debugging unit 1037 reads the memory 101 using the entry of the change value of the memory 101 or the entry of the change value of the register 1033 immediately before the error stored in the stack 1035 occurs, and the memory 101 is read. Or before the value of the register 1033 is changed (S211).

따라서, 본 발명은 CPU에서 일정량 만큼의 메모리 값 혹은 레지스터 값의 변화를 스택(Stack)에 기록한 다음에, 원하지 않는 돌발 상황이 발생될 경우 가장 최근에 기록된 값을 역순으로 복원하면서 디버깅함으로써, 프로그래밍할 때에 위험한 시도를 하는 코드를 작성했다가 문제가 발생하더라도 원활하게 디버깅을 수행할 수 있다. Therefore, the present invention writes a certain amount of memory value or register value change on the stack in the CPU, and then debugs while restoring the most recently recorded value in the reverse order in case an unwanted accident occurs. You can write code that makes dangerous attempts when you are doing it, and you can debug smoothly if problems occur.

상기에서 설명한 바와 같이, 본 발명은 CPU에서 일정량 만큼의 메모리 값 혹은 레지스터 값의 변화를 스택(Stack)에 기록한 다음에, 원하지 않는 돌발 상황이 발생될 경우 가장 최근에 기록된 값을 역순으로 복원하면서 디버깅함으로써, 프로그래밍할 때에 위험한 시도를 하는 코드를 작성했다가 문제가 발생하더라도 원활하게 디버깅을 수행할 수 있는 효과가 있다.As described above, the present invention records a certain amount of memory value or register value change on the stack in the CPU, and then restores the most recently recorded value in the reverse order in the event of an unexpected accident. By debugging, you can write code that makes dangerous attempts when programming, and you can debug smoothly even if problems occur.

Claims (3)

메모리와 레지스터 각각으로 명령을 수행하는 CPU에서의 스택을 이용한 디버깅 방법으로서, A debugging method using a stack on a CPU that executes instructions in each of memory and registers. (a) 상기 메모리로의 명령 수행인 경우, 상기 메모리에 저장된 데이터의 변화가 있을 때마다 변화된 메모리 엔트리를 다수의 실행 코드를 통해 제공받아 상기 스택에 기록하는 과정과, (a) in the case of executing a command to the memory, receiving a changed memory entry through a plurality of execution codes and writing them to the stack whenever there is a change in data stored in the memory; (b) 상기 레지스터로의 명령 수행인 경우, 상기 레지스터의 변화가 있을때마다 변화된 레지스터 엔트리를 상기 스택에 기록하는 과정과, (b) writing a changed register entry on the stack each time there is a change of the register in the case of executing an instruction to the register; (c) 상기 CPU에서 에러가 발생될 경우, 상기 스택에 저장된 에러가 발생되기 바로 이전 엔트리를 이용하여 가장 최근에 들어온 것부터 읽어나가면서 상기 메모리 혹은 레지스터의 값을 변화되기 이전으로 디버깅하는 과정(c) when an error occurs in the CPU, debugging the value of the memory or register before changing by reading from the most recent entry using the entry immediately before the error stored in the stack occurs. 을 포함하는 CPU에서의 스택을 이용한 디버깅 방법.Debugging method using a stack on the CPU containing a. 제 1 항에 있어서,The method of claim 1, 상기 (a) 과정의 메모리 엔트리는, 상기 메모리 기억장소 위치와 변화전의 값과 변화후의 값으로 이루어진 것을 특징으로 하는 CPU에서의 스택을 이용한 디버깅 방법.And a memory entry of the step (a) comprises the memory storage location, a value before change and a value after change. 제 1 항에 있어서,The method of claim 1, 상기 (b) 과정의 레지스터 엔트리는, 상기 레지스터 기억장소 위치와 변화전의 값과 변화후의 값으로 이루어진 것을 특징으로 하는 CPU에서의 스택을 이용한 디버깅 방법.And the register entry of step (b) comprises the register storage location, a value before change and a value after change.
KR1020060113943A 2006-11-17 2006-11-17 Method for debugging by using stack of cpu KR20080044652A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020060113943A KR20080044652A (en) 2006-11-17 2006-11-17 Method for debugging by using stack of cpu

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020060113943A KR20080044652A (en) 2006-11-17 2006-11-17 Method for debugging by using stack of cpu

Publications (1)

Publication Number Publication Date
KR20080044652A true KR20080044652A (en) 2008-05-21

Family

ID=39662470

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020060113943A KR20080044652A (en) 2006-11-17 2006-11-17 Method for debugging by using stack of cpu

Country Status (1)

Country Link
KR (1) KR20080044652A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106293999A (en) * 2015-06-25 2017-01-04 深圳市中兴微电子技术有限公司 A kind of micro engine processes implementation method and the device of message intermediate data snapshot functions
CN113377593A (en) * 2021-06-29 2021-09-10 厦门紫光展锐科技有限公司 CPU failure position positioning analysis method and related product

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106293999A (en) * 2015-06-25 2017-01-04 深圳市中兴微电子技术有限公司 A kind of micro engine processes implementation method and the device of message intermediate data snapshot functions
CN106293999B (en) * 2015-06-25 2019-04-30 深圳市中兴微电子技术有限公司 A kind of implementation method and device of micro engine processing message intermediate data snapshot functions
US11010277B2 (en) 2015-06-25 2021-05-18 Sanechips Technology Co., Ltd. Method and device for realizing snapshot function of micro-engine processing packet intermediate data
CN113377593A (en) * 2021-06-29 2021-09-10 厦门紫光展锐科技有限公司 CPU failure position positioning analysis method and related product

Similar Documents

Publication Publication Date Title
JP4703718B2 (en) Selective subroutine return structure
KR101782313B1 (en) Apparatus and method for handling exception events
JP5611756B2 (en) Program flow control
JPH07248897A (en) Method and device for recovery from exception in computer system
JP2008009721A (en) Evaluation system and evaluation method thereof
US6925522B2 (en) Device and method capable of changing codes of micro-controller
US20050060690A1 (en) Microprocessor system with software emulation processed by auxiliary hardware
CN111625328A (en) Interrupt device, system and method suitable for RISC-V architecture
KR20080044652A (en) Method for debugging by using stack of cpu
US8484446B2 (en) Microprocessor saving data stored in register and register saving method
US7353343B2 (en) Memory management system for preventing program execution when CPU fetches execution code from unoccupied region of memory
JP2009230479A (en) Microprocessor
JP2001306334A (en) Emulation device
KR100525537B1 (en) Applied Program Bungle Detection Apparatus and Method by Interrupt
JP2731047B2 (en) Program operand check method
JP2562838B2 (en) Processor and store buffer control method
JPH1011315A (en) In-circuit emulator device and in-circuit emulation method
WO2024029174A1 (en) Processor for controlling pipeline processing based on jump instruction, and program storage medium
JPH0535499A (en) Data processing device and method
KR960029969A (en) A data processor having a pipeline processing function
JPH0484224A (en) Stack area protection circuit
CN117724938A (en) Memory control method
CN114064478A (en) Method and device for generating verification case
JPH1055289A (en) Debugging information generating circuit and information processor using the same
JPH04367902A (en) Programmable controller

Legal Events

Date Code Title Description
WITN Withdrawal due to no request for examination