KR102300712B1 - Diagnosing method for cause of stack fault and apparatus thereof - Google Patents

Diagnosing method for cause of stack fault and apparatus thereof Download PDF

Info

Publication number
KR102300712B1
KR102300712B1 KR1020190151477A KR20190151477A KR102300712B1 KR 102300712 B1 KR102300712 B1 KR 102300712B1 KR 1020190151477 A KR1020190151477 A KR 1020190151477A KR 20190151477 A KR20190151477 A KR 20190151477A KR 102300712 B1 KR102300712 B1 KR 102300712B1
Authority
KR
South Korea
Prior art keywords
stack
fault
context
processing unit
central processing
Prior art date
Application number
KR1020190151477A
Other languages
Korean (ko)
Other versions
KR20210063519A (en
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 KR1020190151477A priority Critical patent/KR102300712B1/en
Publication of KR20210063519A publication Critical patent/KR20210063519A/en
Application granted granted Critical
Publication of KR102300712B1 publication Critical patent/KR102300712B1/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
    • G06F11/3636Software debugging by tracing the execution of the program
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/34Recording or statistical evaluation of computer activity, e.g. of down time, of input/output operation ; Recording or statistical evaluation of user activity, e.g. usability assessment
    • G06F11/3466Performance evaluation by tracing or monitoring
    • G06F11/3471Address tracing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3604Software analysis for verifying properties of programs
    • G06F11/3612Software analysis for verifying properties of programs by runtime analysis
    • 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/30Arrangements for executing machine instructions, e.g. instruction decode
    • G06F9/30098Register arrangements
    • G06F9/3012Organisation of register space, e.g. banked or distributed register file
    • G06F9/30134Register stacks; shift registers

Landscapes

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

Abstract

본 발명은 중앙처리장치와 스택 메모리를 포함하는 컴퓨팅 시스템에서 스택 결함 원인을 진단하는 방법에 있어서, 어플리케이션 소프트웨어의 실행에 따라 컨텍스트의 입력과 탈출이 반복되는 과정에서, 상기 중앙처리장치가 스택 결함 발생을 감지하는 단계; 상기 스택 결함이 발생할 경우, 상기 중앙처리장치가 스택 히스토리를 반환하는 단계; 및 상기 스택 히스토리가 반환되면, 상기 중앙처리장치가 상기 스택 히스토리에 기초하여 스택 결함을 발생시키는 컨텍스트를 파악하는 단계;를 포함한다.The present invention relates to a method for diagnosing a cause of a stack fault in a computing system including a central processing unit and a stack memory, wherein the central processing unit generates a stack fault in the process of repeatedly entering and exiting a context according to the execution of application software. detecting; returning, by the central processing unit, a stack history when the stack fault occurs; and when the stack history is returned, determining, by the central processing unit, a context in which a stack fault occurs based on the stack history.

Description

스택 결함 원인을 진단하는 방법 및 장치{DIAGNOSING METHOD FOR CAUSE OF STACK FAULT AND APPARATUS THEREOF}Method and apparatus for diagnosing the cause of a stack fault

본 발명은 스택 결함 원인을 진단하는 방법 및 장치에 관한 것으로, 보다 상세하게는 임의의 어플리케이션 소프트웨어 실행 시 스택 결함이 발생하기 전 원인을 파악하여 해당 어플리케이션 소프트웨어의 스택 영역을 최적화시킬 수 있도록 하는, 스택 결함 원인을 진단하는 방법 및 장치에 관한 것이다.The present invention relates to a method and apparatus for diagnosing a cause of a stack defect, and more particularly, to a stack capable of optimizing a stack area of a corresponding application software by identifying a cause before a stack defect occurs when executing any application software. It relates to a method and apparatus for diagnosing the cause of a fault.

일반적으로 스택 구성 중앙처리장치를 구비한 시스템에서 수행되는 오퍼레이터 시스템(OS) 상에서 수행되는 모든 어플리케이션 소프트웨어는 중앙처리장치 내부적으로 스택 방식으로 수행된다. 설정된 오퍼레이터 시스템 상에서 어플리케이션 소프트웨어는 기능별 또는 작업 단위로 태스크 또는 프로세스라는 이름으로 독자적인 동작을 수행하며, 각각의 태스크나 프로세스들은 오퍼레이터 시스템(OS)에서 설정된 우선순위를 모두 가지고 있다.In general, all application software executed on an operator system (OS) executed in a system having a stack configuration central processing unit is executed in a stack manner inside the central processing unit. On the set operator system, the application software performs an independent operation in the name of a task or process by function or work unit, and each task or process has all the priorities set in the operator system (OS).

상기 오퍼레이터 시스템은 이러한 어플리케이션 소프트웨어의 우선순위에 따라서 스케줄링을 수행하여 중앙처리장치의 제어권을 해당 프로그램들에게 넘겨 해당 기능을 수행하게 한다. The operator system performs scheduling according to the priority of the application software to transfer the control right of the central processing unit to the corresponding programs to perform the corresponding function.

이때 임의의 어플리케이션 소프트웨어와 오퍼레이터 시스템의 요구 또는 소프트웨어적인 오류 발생 시 디버깅을 위해 해당 태스크나 프로세서들의 스택 추적을 수행하게 된다. At this time, the stack trace of the corresponding task or processors is performed for debugging when any application software and operator system request or software error occurs.

이러한 경우 종래의 기술은 단순히 현재의 스택 포인터(Stack pointer)에서 마지막 스택 포인터까지 추적을 수행하게 된다. 그런데 이때 연결 목록으로 연결되어 지는 스택이 어떠한 이유에 의해서 깨어질 경우 더 이상의 스택 추적을 진행하지 않거나, 진행한다고 하여도 유효하지 않는 값으로 스택 추적을 진행하게 되어 유효한 정보를 얻을 수 없다.In this case, the conventional technique simply performs tracking from the current stack pointer to the last stack pointer. However, if the stack connected to the linked list is broken for some reason, the stack trace is not performed any more, or even if it does, the stack trace is performed with an invalid value, and valid information cannot be obtained.

즉, 소프트웨어는 컨텍스트 스위칭(Context Switching)(즉, 현재 진행하고 있는 Task(또는 Process, Thread)의 상태를 저장하고 다음 진행할 Task의 상태 값을 읽어 적용하는 과정) 시 소프트웨어 내부 상태를 스택(Stack) 영역에 저장하고 리턴(Return)시 이를 반환한다. 이때 오퍼레이터 시스템(OS)은 스택 영역이 부족하거나 침범될 경우 스택에 저장된 소프트웨어 내부 상태를 정상적으로 복구해 줄 수 없기 때문에 더 이상 정상적인 서비스가 불가능하다고 판단하여 에러를 발생시키고 소프트웨어를 종료한다. In other words, the software stacks the internal state of the software during context switching (that is, the process of saving the state of the currently in progress task (or process, thread) and reading and applying the state value of the next task). It is stored in the area and returned when returning. At this time, when the stack area is insufficient or violated, the operator system (OS) determines that the normal service is no longer possible because it cannot restore the internal state of the software stored in the stack normally, so it generates an error and terminates the software.

이와 같이 스택 결함(Stack Fault)이 발생했는지는 스택 탑(Stack Top)의 패턴이 깨졌는지(즉, 스택 탑이 사용되었는지)를 보고 판단한다.As such, whether a stack fault has occurred is determined by looking at whether the pattern of the stack top is broken (that is, whether the stack top is used).

그런데 스택 탑(Stack Top)이 사용되었을 경우 스택 결함(Stack Fault)을 발생시키기 때문에 실제 스택 결함 발생 시점에 어플리케이션 소프트웨어의 어떤 함수가 스택을 얼마만큼 써서 스택 결함(Stack Fault)이 발생하게 되었는지 알 수 없는 문제점이 있다. However, since a stack fault occurs when the stack top is used, it is impossible to know which function of the application software uses the stack and how much the stack fault occurred at the time of the actual stack fault. There is no problem.

왜냐하면 스택 결함 발생 시점에 수행중인 함수가 항상 스택 결함 발생의 원인이 되는 것은 아니기 때문이다.This is because the function being executed at the time of the stack fault does not always cause the stack fault.

이에 따라 상기 스택 결함 발생 전에 수행된 많은 함수들 중에 스택 결함을 유발시킨 함수를 특정하기가 어렵고, 해당 스택 결함 에러 발생 시 복구 불가능한 에러(Error)이기 때문에 디버깅이 불가능한 문제점이 있다. 따라서 임의의 어플리케이션 소프트웨어 실행 시 스택 결함이 발생하기 전에(또는 스택 결함의 발생을 방지한 상태에서) 그 스택 결함이 발생할 수 있는 상태가 되었을 때 이 상태가 되는 원인을 파악할 수 있도록 하여, 해당 어플리케이션 소프트웨어의 스택 영역을 최적화시킬 수 있도록 하는 기술이 필요한 상황이다. Accordingly, it is difficult to specify the function that caused the stack defect among many functions performed before the occurrence of the stack defect, and when the corresponding stack defect error occurs, it is an unrecoverable error, so debugging is impossible. Therefore, when the stack fault occurs before the stack fault occurs (or in the state in which the stack fault is prevented) when any application software is executed, the cause of this status can be identified when the stack fault occurs, so that the corresponding application software There is a need for a technology that can optimize the stack area of .

본 발명의 배경기술은 대한민국 등록특허 10-0866218호(2008.10.24. 등록, 안정된 스택 추적 방법)에 개시되어 있다. The background technology of the present invention is disclosed in Korean Patent Registration No. 10-0866218 (registration on October 24, 2008, stable stack tracking method).

본 발명의 일 측면에 따르면, 본 발명은 상기와 같은 문제점을 해결하기 위해 창작된 것으로서, 임의의 어플리케이션 소프트웨어 실행 시 스택 결함이 발생하기 전 원인을 파악하여 해당 어플리케이션 소프트웨어의 스택 영역을 최적화시킬 수 있도록 하는, 스택 결함 원인을 진단하는 방법 및 장치를 제공하는 데 그 목적이 있다. According to one aspect of the present invention, the present invention was created to solve the above problems, and it is possible to optimize the stack area of the corresponding application software by identifying the cause before a stack defect occurs when any application software is executed. It is an object of the present invention to provide a method and apparatus for diagnosing a cause of a stack fault.

본 발명의 일 측면에 따른 스택 결함 원인을 진단하는 방법은, 중앙처리장치와 스택 메모리를 포함하는 컴퓨팅 시스템에서 스택 결함 원인을 진단하는 방법에 있어서, 어플리케이션 소프트웨어의 실행에 따라 컨텍스트의 입력과 탈출이 반복되는 과정에서, 상기 중앙처리장치가 스택 결함 발생을 감지하는 단계; 상기 스택 결함이 발생할 경우, 상기 중앙처리장치가 스택 히스토리를 반환하는 단계; 및 상기 스택 히스토리가 반환되면, 상기 중앙처리장치가 상기 스택 히스토리에 기초하여 스택 결함을 발생시키는 컨텍스트를 파악하는 단계;를 포함하는 것을 특징으로 한다.A method for diagnosing a cause of a stack fault according to an aspect of the present invention is a method for diagnosing a cause of a stack fault in a computing system including a central processing unit and a stack memory, wherein input and exit of a context are performed according to execution of application software. In the repeated process, the central processing unit detecting the occurrence of a stack defect; returning, by the central processing unit, a stack history when the stack fault occurs; and when the stack history is returned, determining, by the central processing unit, a context in which a stack fault occurs based on the stack history.

본 발명에 있어서, 상기 스택 히스토리는, 컨텍스트와 스택 포인터 값을 포함하는 것을 특징으로 한다.In the present invention, the stack history includes a context and a stack pointer value.

본 발명에 있어서, 상기 스택 결함 발생을 감지하는 단계 이전에, 상기 스택 결함 발생 시 컴퓨팅 시스템이 다운되거나 리셋되는 것을 방지하기 위하여, 상기 중앙처리장치가, 스택 사용량이 최초 설정된 스택 영역 사이즈에 대하여 미리 지정된 마진 값에 도달하는지 체크하는 단계; 및 상기 스택 사용량이 최초 설정된 스택 영역 사이즈에 대하여 미리 지정된 마진 값에 도달할 경우에 임시 스택 영역을 동적으로 추가 할당하는 단계;를 더 포함하는 것을 특징으로 한다.In the present invention, prior to the step of detecting the occurrence of the stack fault, in order to prevent the computing system from being down or reset when the stack fault occurs, the central processing unit performs the stack usage in advance with respect to the initially set stack area size. checking whether a specified margin value is reached; and dynamically additionally allocating a temporary stack area when the stack usage reaches a predetermined margin value with respect to an initially set stack area size.

본 발명에 있어서, 상기 스택 결함 발생을 감지하는 단계 이전에, 상기 스택 결함 발생 시 컴퓨팅 시스템이 다운되거나 리셋되는 것을 방지하기 위하여, 상기 중앙처리장치가, 컨텍스트 스위칭 시 이벤트가 발생할 때마다 사용했던 최대 스택 사용량을 기록하고, 최초 설정된 스택 영역에서 현재 남은 스택 영역의 사이즈를 산출하는 단계; 및 상기 중앙처리장치가, 현재 남은 스택 영역의 사이즈와 해당 컨텍스트가 사용한 스택의 최대 사용량을 비교하여, 상기 최대 사용량에 지정된 마진 값을 합산한 스택 용량이 현재 남은 스택 영역의 사이즈보다 큰 경우, 추가적인 동적 스택 영역의 할당이 필요한 것으로 판단하여 임시 스택 영역을 동적으로 추가 할당하는 단계;를 더 포함하는 것을 특징으로 한다.In the present invention, before the step of detecting the occurrence of the stack fault, in order to prevent the computing system from being down or reset when the stack fault occurs, the maximum value used by the central processing unit whenever an event occurs during context switching recording a stack usage and calculating a size of a stack area currently remaining in an initially set stack area; and the central processing unit compares the size of the currently remaining stack area with the maximum usage of the stack used by the context, and when the stack capacity obtained by adding the margin value specified to the maximum usage is greater than the size of the currently remaining stack area, additional and dynamically additionally allocating a temporary stack area by determining that allocation of the dynamic stack area is necessary.

본 발명에 있어서, 상기 스택 결함 발생을 감지하는 단계에서, 상기 중앙처리장치는, 최초 설정된 스택 영역에서 이미 사용된 스택 영역과 상기 동적으로 추가 할당된 임시 스택 영역에서 추가로 사용된 스택 영역의 총 합이 상기 최초 설정된 스택 영역의 사이즈를 초과한 경우, 스택 결함이 발생된 것으로 감지하는 것을 특징으로 한다.In the present invention, in the step of detecting the occurrence of the stack defect, the central processing unit includes a total of a stack area already used in the initially set stack area and a stack area additionally used in the dynamically additionally allocated temporary stack area. When the sum exceeds the size of the initially set stack area, it is characterized in that it is detected that a stack defect has occurred.

본 발명에 있어서, 상기 스택 히스토리에 기초하여 스택 결함을 발생시키는 컨텍스트를 파악하는 단계에서, 상기 중앙처리장치는, 컨텍스트가 입력될 때 저장한 스택 포인터와 상기 컨텍스트가 종료되어 복귀할 때 반환하는 스택 포인터가 다른 경우에 스택 결함을 발생시키는 컨텍스트로 파악하는 것을 특징으로 한다.In the present invention, in the step of recognizing a context that generates a stack fault based on the stack history, the central processing unit includes a stack pointer stored when a context is input and a stack returned when the context is terminated and returned. It is characterized by identifying a context that causes a stack fault when the pointer is different.

본 발명에 있어서, 상기 스택 결함을 발생시키는 컨텍스트를 파악하는 단계 이후, 상기 중앙처리장치가, 상기 스택 결함을 발생시키는 컨텍스트를 사용자 인터페이스를 통해 표시하는 단계;를 더 포함하는 것을 특징으로 한다.In the present invention, after the step of recognizing the context in which the stack fault occurs, the step of displaying, by the central processing unit, the context in which the stack fault occurs through a user interface; is characterized in that it further comprises.

본 발명에 있어서, 상기 스택 결함을 발생시키는 컨텍스트를 사용자 인터페이스를 통해 표시하는 단계 이후, 상기 중앙처리장치가 사용자 인터페이스를 통해 사용자에게 어플리케이션 소프트웨어의 계속 진행 여부를 체크하는 단계; 및 사용자가 계속 진행 선택 시, 상기 중앙처리장치가 어플리케이션 소프트웨어를 계속 실행시켜 스택 결함을 발생시키는 다른 컨텍스트를 계속해서 파악하는 단계;를 더 포함하는 것을 특징으로 한다.In the present invention, after the step of displaying the context in which the stack fault occurs through the user interface, the central processing unit checks whether the application software continues to the user through the user interface; and when the user selects to continue, the central processing unit continues to execute the application software to continuously identify another context that causes a stack fault.

본 발명의 다른 측면에 따른 스택 결함 원인을 진단하는 장치는, 컴퓨팅 시스템의 스택 메모리; 및 상기 컴퓨팅 시스템에서 어플리케이션 소프트웨어의 실행에 따라 컨텍스트의 입력과 탈출이 반복되는 과정에서 스택 결함 발생을 감지하는 중앙처리장치;를 포함하고, 상기 스택 결함이 발생할 경우, 상기 중앙처리장치가 스택 히스토리를 반환하고, 상기 반환된 스택 히스토리를 분석하여 스택 결함을 발생시키는 컨텍스트를 파악하는 것을 특징으로 한다.An apparatus for diagnosing a cause of a stack fault according to another aspect of the present invention includes: a stack memory of a computing system; and a central processing unit that detects the occurrence of a stack fault in a process in which input and exit of a context are repeated according to the execution of application software in the computing system. It is characterized in that the context in which the stack fault occurs is identified by analyzing the returned stack history.

본 발명에 있어서, 상기 스택 히스토리는, 컨텍스트와 스택 포인터 값을 포함하는 것을 특징으로 한다.In the present invention, the stack history includes a context and a stack pointer value.

본 발명에 있어서, 상기 중앙처리장치는, 상기 스택 결함 발생 시 컴퓨팅 시스템이 다운되거나 리셋되는 것을 방지하기 위하여, 스택 결함 발생을 감지하는 단계 이전에, 스택 사용량이 최초 설정된 스택 영역 사이즈에 대하여 미리 지정된 마진 값에 도달하는지 체크하고, 상기 스택 사용량이 최초 설정된 스택 영역 사이즈에 대하여 미리 지정된 마진 값에 도달할 경우에 임시 스택 영역을 동적으로 추가 할당하는 것을 더 포함하는 것을 특징으로 한다.In the present invention, the central processing unit, in order to prevent the computing system from being down or reset when the stack fault occurs, before the step of detecting the occurrence of the stack fault, the stack usage is preset for the initially set stack area size. Checking whether a margin value is reached, and dynamically allocating a temporary stack area additionally when the stack usage reaches a predetermined margin value with respect to an initially set stack area size.

본 발명에 있어서, 상기 중앙처리장치는, 상기 스택 결함 발생 시 컴퓨팅 시스템이 다운되거나 리셋되는 것을 방지하기 위하여, 스택 결함 발생을 감지하는 단계 이전에, 컨텍스트 스위칭 시 이벤트가 발생할 때마다 사용했던 최대 스택 사용량을 기록하고, 최초 설정된 스택 영역에서 현재 남은 스택 영역의 사이즈를 산출하고, 현재 남은 스택 영역의 사이즈와 해당 컨텍스트가 사용한 스택의 최대 사용량을 비교하여, 상기 최대 사용량에 지정된 마진 값을 합산한 스택 용량이 현재 남은 스택 영역의 사이즈보다 큰 경우, 임시 스택 영역을 동적으로 추가 할당하는 것을 특징으로 한다.In the present invention, the central processing unit, in order to prevent the computing system from being down or reset when the stack fault occurs, before detecting the occurrence of the stack fault, the maximum stack used whenever an event occurs during context switching. A stack obtained by recording the amount of usage, calculating the size of the currently remaining stack area from the initially set stack area, comparing the size of the currently remaining stack area with the maximum usage of the stack used by the context, and summing the margin value specified for the maximum usage When the capacity is larger than the size of the currently remaining stack area, it is characterized in that the temporary stack area is dynamically additionally allocated.

본 발명에 있어서, 상기 중앙처리장치는, 최초 설정된 스택 영역에서 이미 사용된 스택 영역과 상기 동적으로 추가 할당된 임시 스택 영역에서 추가로 사용된 스택 영역의 총 합이 상기 최초 설정된 스택 영역의 사이즈를 초과한 경우, 스택 결함이 발생된 것으로 감지하는 것을 특징으로 한다.In the present invention, the central processing unit determines the size of the initially set stack area by the sum of the stack area already used in the initially set stack area and the stack area additionally used in the dynamically additionally allocated temporary stack area. When it is exceeded, it is characterized in that it is detected that a stack fault has occurred.

본 발명에 있어서, 상기 중앙처리장치는, 컨텍스트가 입력될 때 저장한 스택 포인터와 상기 컨텍스트가 종료되어 복귀할 때 반환하는 스택 포인터가 다른 경우에 스택 결함을 발생시키는 컨텍스트로 파악하는 것을 특징으로 한다.In the present invention, the central processing unit is characterized in that, when the stack pointer stored when a context is input and the stack pointer returned when the context is terminated and returned are different, it is characterized as a context generating a stack fault. .

본 발명에 있어서, 상기 중앙처리장치는, 상기 스택 결함을 발생시키는 컨텍스트를 파악하면, 상기 스택 결함을 발생시키는 컨텍스트를 사용자 인터페이스를 통해 표시하는 것을 특징으로 한다.In the present invention, the central processing unit is characterized in that, upon recognizing the context for generating the stack defect, the context for generating the stack defect is displayed through a user interface.

본 발명에 있어서, 상기 중앙처리장치는, 상기 스택 결함을 발생시키는 컨텍스트를 사용자 인터페이스를 통해 표시한 이후, 상기 사용자 인터페이스를 통해 사용자에게 어플리케이션 소프트웨어의 계속 진행 여부를 체크하고, 사용자가 계속 진행 선택 시, 어플리케이션 소프트웨어를 계속 실행시켜 스택 결함을 발생시키는 다른 컨텍스트를 계속해서 파악하는 것을 특징으로 한다.In the present invention, the central processing unit, after displaying the context for generating the stack fault through the user interface, checks whether the application software continues to the user through the user interface, and when the user selects to continue , characterized in that the application software continues to run to continuously identify other contexts that cause the stack fault.

본 발명의 일 측면에 따르면, 본 발명은 임의의 어플리케이션 소프트웨어 실행 시 스택 결함이 발생하기 전 원인을 파악하여 해당 어플리케이션 소프트웨어의 스택 영역을 최적화시킬 수 있도록 한다. 또한 임의의 어플리케이션 소프트웨어 실행 시 스택 결함의 발생을 방지한 상태에서 그 스택 결함이 발생할 수 있는 상태가 되었을 때 이 상태가 되는 원인을 파악할 수 있도록 하여, 해당 어플리케이션 소프트웨어의 스택 영역을 최적화시킬 수 있도록 한다.According to one aspect of the present invention, the stack area of the corresponding application software can be optimized by identifying a cause before a stack defect occurs when any application software is executed. In addition, it is possible to optimize the stack area of the application software by preventing the occurrence of a stack defect when executing arbitrary application software and identifying the cause of this state when the stack defect is in a state where it can occur. .

도 1은 본 발명의 일 실시예에 따른 중앙처리장치와 메모리부를 포함하는 컴퓨팅 시스템의 개략적인 구성을 보인 예시도.
도 3은 상기 도 2에 있어서, 태스크(task)의 수행에 따라 스택 포인터를 저장하고 반환하는 과정에서 스택 결함이 발생하는 상황을 예시적으로 설명하기 위하여 보인 예시도.
도 3은 상기 도 2에 있어서, 태스크(task)의 수행에 따라 스택 포인터를 저장하고 반환하는 과정에서 스택 결함이 발생하는 상황을 예시적으로 설명하기 위하여 보인 예시도.
도 4는 상기 도 2에 있어서, 스택에 미리 기록된 히스토리를 바탕으로 스택 결함 원인을 파악하는 과정을 설명하기 위한 흐름도.
도 5는 상기 도 4에 있어서, 최초 설정된 스택 영역 사이즈에 대한 마진 값 이상의 스택이 사용될 경우 임시 스택 영역을 추가로 할당하여 스택 결함 원인을 파악하는 방법을 설명하기 위한 흐름도.
도 6은 상기 도 4에 있어서, 최대 스택 사용량과 최초 설정된 스택 영역에서 현재 남은 스택 영역을 비교하여 스택 영역의 부족이 예상될 경우 임시 스택 영역을 추가로 할당하여 스택 결함 원인을 파악하는 다른 방법을 설명하기 위한 예시도.
1 is an exemplary diagram illustrating a schematic configuration of a computing system including a central processing unit and a memory unit according to an embodiment of the present invention;
FIG. 3 is an exemplary view illustrating a situation in which a stack fault occurs in the process of storing and returning a stack pointer according to the execution of a task in FIG. 2;
FIG. 3 is an exemplary view illustrating a situation in which a stack fault occurs in the process of storing and returning a stack pointer according to the execution of a task in FIG. 2;
4 is a flowchart for explaining a process of identifying a cause of a stack defect based on a history previously recorded in the stack in FIG. 2 ;
FIG. 5 is a flowchart for explaining a method of identifying a cause of a stack defect by additionally allocating a temporary stack area when a stack greater than or equal to a margin value for an initially set stack area size is used in FIG. 4 ;
6 is another method of determining the cause of a stack defect by additionally allocating a temporary stack area when a shortage of the stack area is expected by comparing the maximum stack usage with the stack area currently remaining in the initially set stack area in FIG. An example diagram to explain.

이하, 첨부된 도면을 참조하여 본 발명에 따른 스택 결함 원인을 진단하는 방법 및 장치의 일 실시예를 설명한다. Hereinafter, an embodiment of a method and apparatus for diagnosing a cause of a stack defect according to the present invention will be described with reference to the accompanying drawings.

이 과정에서 도면에 도시된 선들의 두께나 구성요소의 크기 등은 설명의 명료성과 편의상 과장되게 도시되어 있을 수 있다. 또한, 후술되는 용어들은 본 발명에서의 기능을 고려하여 정의된 용어들로서 이는 사용자, 운용자의 의도 또는 관례에 따라 달라질 수 있다. 그러므로 이러한 용어들에 대한 정의는 본 명세서 전반에 걸친 내용을 토대로 내려져야 할 것이다.In this process, the thickness of the lines or the size of the components shown in the drawings may be exaggerated for clarity and convenience of explanation. In addition, the terms to be described later are terms defined in consideration of functions in the present invention, which may vary according to the intention or custom of the user or operator. Therefore, definitions of these terms should be made based on the content throughout this specification.

도 1은 본 발명의 일 실시예에 따른 중앙처리장치와 메모리부를 포함하는 컴퓨팅 시스템의 개략적인 구성을 보인 예시도이다.1 is an exemplary diagram illustrating a schematic configuration of a computing system including a central processing unit and a memory unit according to an embodiment of the present invention.

도 1에 도시된 바와 같이, 중앙처리장치(100)(예 : CPU)는 스택 구성으로 이루어지며, 임의의 태스크, 프로세스, 및 응용프로그램(또는 어플리케이션 소프트웨어)의 수행에 따라 상기 컴퓨팅 시스템의 동작을 제어한다. As shown in FIG. 1 , the central processing unit 100 (eg, CPU) has a stack configuration and controls the operation of the computing system according to the execution of arbitrary tasks, processes, and applications (or application software). Control.

상기 메모리부(200)는 스택부(201)(또는 스택메모리)를 포함하여 구성된다. The memory unit 200 includes a stack unit 201 (or stack memory).

상기 메모리부(200)는 상기 시스템 동작에 필요한 프로그램 데이터와 본 발명에 따른 스택 결함 원인을 진단하는 방법에 따른 프로그램 데이터를 저장한다.The memory unit 200 stores program data necessary for the system operation and program data according to a method for diagnosing a cause of a stack defect according to the present invention.

상기와 같이 스택 구성의 중앙처리장치(100)는 모든 명령 수행을 스택 방식으로 처리한다. As described above, the central processing unit 100 of the stack configuration processes all command execution in a stack manner.

상기 중앙처리장치(100)에 의해 실행되는 오퍼레이터 시스템은, 실행 시 각 어플리케이션 소프트웨어들이 정상적으로 수행될 수 있도록 스택부(201)의 스택 영역을 할당하며, 각 어플리케이션들은 할당된 스택 영역을 이용하여 주어진 동작을 수행한다. The operator system executed by the central processing unit 100 allocates a stack area of the stack unit 201 so that each application software can be normally performed during execution, and each application performs a given operation using the allocated stack area. carry out

이러한 어플리케이션 실행 시 스택 결함(또는 스택 오류, 스택 오버플로우 오류)이 발생하기 전, 또는 임의의 어플리케이션 소프트웨어 실행 시 스택 결함의 발생을 방지한 상태에서 그 스택 결함이 발생할 수 있는 상태가 되었을 경우, 이 상태(즉, 스택 결함이 발생할 수 있는 상태)가 되는 것을 감지하여 그 원인(즉, 스택 결함이 발생하는 원인)을 진단하거나 파악할 수 있도록 한다. When a stack fault (or stack error, stack overflow error) occurs when executing such an application, or when the stack fault is prevented from occurring when any application software is executed, when the stack fault occurs By detecting a state (that is, a state in which a stack defect may occur), the cause (i.e., the cause of the occurrence of a stack defect) can be diagnosed or identified.

즉, 상기 중앙처리장치(100)는 본 발명의 일 실시예에 따라 도 2 내지 도 5에 도시된 바와 같은 방법으로 스택 결함이 발생하는 원인을 진단할 수 있도록 한다.That is, according to an embodiment of the present invention, the central processing unit 100 can diagnose the cause of the stack defect by the method shown in FIGS. 2 to 5 .

도 2는 본 발명의 일 실시예에 따라 어플리케이션들이 스택에 히스토리를 기록하는 과정을 설명하기 위한 흐름도이고, 도 3은 상기 도 2에 있어서, 태스크(task)의 수행에 따라 스택 포인터를 저장하고 반환하는 과정에서 스택 결함이 발생하는 상황을 예시적으로 설명하기 위하여 보인 예시도이다. FIG. 2 is a flowchart illustrating a process in which applications write a history to a stack according to an embodiment of the present invention, and FIG. 3 is a stack pointer stored and returned according to the execution of a task in FIG. 2 . It is an exemplary diagram to exemplarily explain a situation in which a stack defect occurs in the process of

도 2에 도시된 바와 같이, 중앙처리장치(100)는 어플리케이션 소프트웨어를 수행하는 과정에서 컨텍스트 스위칭(Context Switching)시 저장(Save)과 복원(Restore)을 수행함에 따라, 스택에 태스크 아이디(TaskID)(또는 컨텍스트)와 스택 포인터(Stack Pointer)를 기록한다.As shown in FIG. 2 , the central processing unit 100 performs Save and Restore during context switching in the process of executing application software, so that the stack has a task ID (TaskID). (or context) and the stack pointer.

즉, 도 2를 참조하면, 제1 컨텍스트가 입력(Enter)될 경우(S101) 이에 대한 이벤트(Event 1)를 스택 히스토리로서 기록한다(S102). That is, referring to FIG. 2 , when a first context is input (Enter) (S101), an event (Event 1) is recorded as a stack history (S102).

그리고 상기 제1 컨텍스트에 포함된 프로그램 함수(즉, 코드(code))를 수행한다(S103). 이때 상기 코드 수행 중 제2 컨텍스트가 입력(Enter)될 경우(S201), 이에 대한 이벤트(Event 2)를 스택 히스토리로서 기록한다(S202). Then, the program function (ie, code) included in the first context is executed ( S103 ). At this time, when the second context is input (Enter) while executing the code (S201), an event (Event 2) for this is recorded as a stack history (S202).

그리고 상기 제2 컨텍스트에 포함된 프로그램 함수(즉, 코드(code))를 수행하며(S203), 상기 프로그램 함수(즉, 코드(code))의 수행이 완료되면 이에 대한 이벤트(Event 3)를 스택 히스토리로서 기록한 다음(S204), 상기 제2 컨텍스트의 수행(S203)이 완료됨에 따라 상기 제2 컨텍스트를 탈출(Exit)하여(S205), 이전의 프로그램 함수(즉, 코드(code))에 복귀한다.Then, the program function (ie, code) included in the second context is executed (S203), and when the execution of the program function (ie, code) is completed, an event (Event 3) for this is stacked After recording as a history (S204), as the execution of the second context (S203) is completed, the second context is exited (S205), and the previous program function (ie, code) is returned. .

다음 상기 제1 컨텍스트의 수행(S103)이 완료됨에 따라, 이에 대한 이벤트(Event 4)를 스택 히스토리로서 기록하고(S104) 상기 제1 컨텍스트를 탈출(Exit)한다(S105).Next, as the execution of the first context (S103) is completed, an event (Event 4) is recorded as a stack history (S104) and the first context is exited (S105).

참고로 상기 제2 컨텍스트가 입력될 경우(S201) 우선순위가 선점되는 과정에서 스택 포인터를 저장하고, 상기 제2 컨텍스트의 처리가 완료되어 상기 제1 컨텍스트로 우선순위가 복귀될 때(S205) 스택 포인터를 복원한다.For reference, when the second context is input (S201), the stack pointer is stored in the process of preempting the priority, and when the processing of the second context is completed and the priority is returned to the first context (S205), the stack restore a pointer

한편 도 3을 참조하면, 첫 번째 태스크(Task 1)가 입력될 때 스택 포인터가 0x700 이고, 두 번째 태스크(Task 2)가 입력될 때 스택 포인터가 증가되어 0x780이 되었으며, 두 번째 태스크(Task 2)가 종료되어 첫 번째 태스크(Task 1)로 복귀될 때 증가되었던 스택 포인터 Ox780을 반환하고, 이와 마찬가지로 첫 번째 태스크(Task 1)가 종료되면 이전의 스택 포인터 0x700을 반환해야 되지만, 그렇지 못하고 0x710을 반환하는 스택 결함이 발생되는 상황을 나타낸다.Meanwhile, referring to FIG. 3 , when the first task (Task 1) is input, the stack pointer is 0x700, when the second task (Task 2) is input, the stack pointer is increased to 0x780, and the second task (Task 2) ) ends and returns to the first task (Task 1), the increased stack pointer Ox780 is returned. Indicates the situation in which the returned stack fault occurs.

도 4는 상기 도 2에 있어서, 스택에 미리 기록된 히스토리를 바탕으로 스택 결함 원인을 파악하는 과정을 설명하기 위한 흐름도이다. 4 is a flowchart illustrating a process of identifying a cause of a stack defect based on a history previously recorded in the stack in FIG. 2 .

도 4를 참조하면, 스택 결함이 발생할 경우(S301), 중앙처리장치(100)는 이전에 저장했던 스택 히스토리(예 : 컨텍스트와 스택 포인터 값)를 반환한다(S302).Referring to FIG. 4 , when a stack defect occurs (S301), the central processing unit 100 returns a previously stored stack history (eg, context and stack pointer values) (S302).

상기와 같이 스택 히스토리(예 : 컨텍스트와 스택 포인터 값)가 반환되면, 이를 참조하여 중앙처리장치(100)는 비정상 컨텍스트들(즉, 스택 결함의 원인이 되는 후보 컨텍스트들)이 검출될 경우(S303의 예), 해당 비정상 컨텍스트들을 분석하여 스택 결함의 원인(예 : 스택 결함을 발생시키는 컨텍스트)을 파악한다(S304).When the stack history (eg, the context and the stack pointer value) is returned as described above, the central processing unit 100 refers to this when abnormal contexts (ie, candidate contexts that cause a stack defect) are detected (S303). example), the cause of the stack defect (eg, the context causing the stack defect) is identified by analyzing the corresponding abnormal contexts (S304).

상기 스택 결함의 원인을 파악하는 방법에 대해서 도 5를 참조하여 좀 더 구체적으로 설명한다.A method of determining the cause of the stack defect will be described in more detail with reference to FIG. 5 .

도 5는 상기 도 4에 있어서, 최초 설정된 스택 영역 사이즈에 대한 마진 값 이상의 스택이 사용될 경우 임시 스택 영역을 추가로 할당하여 스택 결함 원인을 파악하는 방법을 설명하기 위한 흐름도이다.FIG. 5 is a flowchart for explaining a method of identifying a cause of a stack defect by additionally allocating a temporary stack area when a stack greater than or equal to a margin value for an initially set stack area size is used in FIG. 4 .

도 5를 참조하면, 중앙처리장치(100)는 컨텍스트의 입력(Enter)과 탈출(Exit)이 반복되는 과정에서 스택 사용량이 최초 설정된 스택 영역 사이즈(size)에 대하여 미리 지정된 마진 값(예 : 스택 영역 사이즈 100%에 대하여 80%로 지정된 마진 값)에 도달할 경우(S401), 임시 스택 영역을 동적으로 추가 할당한다(S402).Referring to FIG. 5 , the central processing unit 100 sets a predetermined margin value (eg, the stack When the margin value designated as 80% with respect to the area size 100%) is reached (S401), a temporary stack area is dynamically additionally allocated (S402).

예컨대 어플리케이션 소프트웨어에 최초 설정된 스택 영역의 사이즈가 10(즉, 100%)이라고 가정하고, 미리 지정된 마진 값이 8(즉, 80%)이라고 가정할 때, 상기 어플리케이션 소프트웨어 실행 중 스택 사용량이 상기 미리 지정된 마진 값 8(즉, 80%) 이상이 되면, 중앙처리장치(100)가 임시 스택 영역(예 : 최초 설정된 스택 영역 사이즈의 100%)을 동적으로 추가 할당한다. 상기와 같이 마진 값 이상의 스택 사용이 감지됨에 따라 임시 스택 영역이 동적으로 추가 할당됨으로써, 해당 어플리케이션 소프트웨어 실행 중 스택 결함의 발생을 방지할 수 있는 상태가 되는 것이다.For example, assuming that the size of the stack area initially set in the application software is 10 (that is, 100%) and the preset margin value is 8 (ie, 80%), the stack usage during execution of the application software is When the margin value is 8 (ie, 80%) or more, the central processing unit 100 dynamically additionally allocates a temporary stack area (eg, 100% of the initially set stack area size). As described above, the temporary stack area is dynamically additionally allocated as the stack usage exceeding the margin value is detected, so that it is possible to prevent the occurrence of a stack defect during execution of the corresponding application software.

따라서 이후로 새로운 컨텍스트가 입력될 경우(즉, 스택을 사용하는 새로운 이벤트가 추가로 발생할 경우), 중앙처리장치(100)는 최초 설정된 스택 영역에서 이미 사용된 스택 영역(예 : 80%)과 동적으로 추가 할당된 임시 스택 영역(예 : 100%)에서 추가로 사용된 스택 영역(예 : 25%)의 총 합(예 : 105%)이 최초 설정된 스택 영역의 사이즈(즉, 100%)를 초과한 경우(S403의 예), 스택 결함(에러)이 발생되었음을 알람하고 스택 히스토리(예 : 컨텍스트와 스택 포인터 값)를 반환한다(S405). Therefore, when a new context is subsequently input (that is, when a new event using the stack occurs additionally), the central processing unit 100 dynamically compares the previously used stack area (eg 80%) in the initially set stack area. The total sum (eg 105%) of the additionally used stack region (eg 25%) in the temporary stack region (eg 100%) additionally allocated as In one case (Yes in S403), it alarms that a stack fault (error) has occurred and returns the stack history (eg, context and stack pointer values) (S405).

이때 기존에는 스택 결함이 발생할 경우 컴퓨팅 시스템이 다운되거나 리셋되는 상황이 발생하지만, 본 실시예에서는 스택 결함 에러가 발생된 것만 알람하고 컴퓨팅 시스템이 다운되는 상황은 발생하지 않는다. 즉, 본 실시예에서는 이미 동적으로 추가 할당된 임시 스택 영역(예 : 최초 설정된 스택 영역 사이즈의 100%)을 사용하고 있는 상황이므로, 상기 스택 결함은 복구 가능한 에러가 되는 것이다.At this time, when a stack fault occurs, a situation in which the computing system is down or reset occurs, but in the present embodiment, only the occurrence of a stack fault error is alarmed, and a situation in which the computing system is down does not occur. That is, in the present embodiment, since the dynamically additionally allocated temporary stack area (eg, 100% of the initially set stack area size) is used, the stack defect becomes a recoverable error.

이에 따라 중앙처리장치(10))는 사용자 인터페이스(UI)를 통해 사용자에게 어플리케이션 소프트웨어의 계속 진행(실행) 여부를 체크하여(S406), 계속 진행이 선택될 경우(S406의 예) 상기 S401 단계 내지 S406 단계를 반복 수행하면서 스택 결함이 발생하는 다른 추가 원인(예 : 추가로 스택 결함을 발생시키는 컨텍스트)을 계속해서 파악할 수 있다. 또한 상기 중앙처리장치(10)는 사용자가 계속 진행을 선택하지 않을 경우(S406의 아니오) 계속 진행(실행)을 종료함으로써, 사용자에게 상기 파악된 원인(예 : 스택 결함을 발생시키는 컨텍스트)을 제거하기 위한 작업(예 : 어플리케이션 소프트웨어의 코드 수정)을 수행할 수 있도록 한다.Accordingly, the central processing unit 10) checks whether to continue (execution) of the application software to the user through the user interface (UI) (S406), By repeating step S406, other additional causes of stack faults (eg, contexts that additionally generate stack faults) can be continuously identified. In addition, the central processing unit 10 removes the identified cause (eg, a context causing a stack fault) to the user by terminating the continuing process (execution) when the user does not select to proceed (No in S406). Allows you to perform tasks intended to be performed (eg, modifying the code of application software).

예컨대 상기 중앙처리장치(10)는 상기 스택 히스토리의 분석을 통해(즉, 스택 히스토리에 포함되어 있는 컨텍스트와 스택 포인터 값의 분석을 통해) 어떤 컨텍스트가 스택 포인터를 비정상적으로 증가시키고 복원(Restore)시키지 못했는지 파악하여 사용자 인터페이스(UI)를 통해 표시한다. 즉, 어떤 컨텍스트가 가용한 스택 사이즈보다 많은 스택을 필요로 했는지 파악하여 사용자 인터페이스(UI)를 통해 표시한다. 이에 따라 사용자에게 상기 파악된 원인(예 : 스택 결함을 발생시키는 컨텍스트)을 제거하기 위한 작업(예 : 어플리케이션 소프트웨어의 코드 수정)을 수행할 수 있게 되는 것이다.For example, through the analysis of the stack history (that is, through the analysis of the context and the stack pointer value included in the stack history), the central processing unit 10 abnormally increases and restores the stack pointer. It detects the failure and displays it through the user interface (UI). That is, it identifies which context required more stacks than the available stack size and displays it through the user interface (UI). Accordingly, the user can perform an operation (eg, modifying the code of the application software) to remove the identified cause (eg, the context that causes the stack fault).

상기와 같이 본 실시예는 임의의 어플리케이션 소프트웨어 실행 시 스택 결함의 발생을 방지한 상태(예 : 동적으로 임시 스택 영역을 추가로 할당한 상태)에서 그 스택 결함이 발생할 수 있는 상태가 되었을 경우(즉, 최초 설정된 스택 영역에서 이미 사용된 스택 영역과 동적으로 추가 할당된 임시 스택 영역에서 추가로 사용된 스택 영역의 총 합이 최초 설정된 스택 영역의 사이즈를 초과한 경우), 이 상태(즉, 스택 결함이 발생할 수 있는 상태)가 되는 것을 감지하여 그 원인(즉, 스택 결함이 발생하는 원인)을 진단하거나 파악할 수 있도록 한다. As described above, in the present embodiment, when any application software is executed in a state in which the occurrence of a stack defect is prevented (eg, a state in which a temporary stack area is additionally allocated dynamically), when the stack defect becomes a state (that is, , when the sum of the stack area already used in the initially set stack area and the stack area additionally used in the dynamically additionally allocated temporary stack area exceeds the size of the initially set stack area), this state (i.e., stack fault) state that can occur), and the cause (that is, the cause of the stack fault) can be diagnosed or identified.

한편 상기 실시예에서는 마진 값을 최초 설정된 스택 영역 사이즈에 대하여 설정하였으나, 다른 실시예에서는 상기 마진 값을 다른 방식으로 설정할 수 있다. Meanwhile, in the above embodiment, the margin value is set for the initially set stack region size, but in another embodiment, the margin value may be set in a different way.

도 6은 상기 도 4에 있어서, 최대 스택 사용량과 최초 설정된 스택 영역에서 현재 남은 스택 영역을 비교하여 스택 영역의 부족이 예상될 경우 임시 스택 영역을 추가로 할당하여 스택 결함 원인을 파악하는 다른 방법을 설명하기 위한 예시도이다.6 is another method of determining the cause of a stack defect by additionally allocating a temporary stack area when a shortage of the stack area is expected by comparing the maximum stack usage with the stack area currently remaining in the initially set stack area in FIG. It is an example diagram for explanation.

도 6에 도시된 바와 같이, 중앙처리장치(10)는 컨텍스트 스위칭 시 이벤트가 발생할 때마다 사용했던 최대 스택 사용량을 기록한다. 즉, 누적된 스택 사용량 중 해당 컨텍스트가 사용한 스택의 최대 사용량을 기록한다.As shown in FIG. 6 , the central processing unit 10 records the maximum stack usage used whenever an event occurs during context switching. That is, out of the accumulated stack usage, the maximum usage of the stack used by the context is recorded.

또한 상기 중앙처리장치(10)는 최초 설정된 스택 영역에서 현재 남은 스택 영역의 사이즈를 산출한다.In addition, the central processing unit 10 calculates the size of the stack area currently remaining in the initially set stack area.

또한 상기 중앙처리장치(10)는 현재 남은 스택 영역의 사이즈와 지금까지 해당 컨텍스트가 사용한 스택의 최대 사용량을 비교하여, 즉, 최대 사용량(즉, 필요 Size)에 지정된 마진 값(예 : 20%)을 합산한 용량(즉, 필요 Size + 마진 값)이 현재 남은 스택 영역의 사이즈(즉, 남은 Size)보다 큰 경우, 추가적인 동적 스택 영역의 할당이 필요한 것으로 판단하여 임시 스택 영역을 동적으로 추가 할당한다.In addition, the central processing unit 10 compares the size of the currently remaining stack area with the maximum usage of the stack used by the context so far, that is, the margin value specified for the maximum usage (ie, the required size) (eg 20%) If the combined capacity (i.e., required size + margin value) is larger than the size of the current remaining stack area (i.e., the remaining size), it is determined that additional dynamic stack area allocation is necessary and the temporary stack area is dynamically additionally allocated. .

예컨대 제1 태스크(Task1)의 경우 최대 사용량이 0x20이고 현재 남은 스택 영역의 사이즈도 0x20인 경우 추가적인 동적 스택 할당이 필요한 것으로 판단하여 임시 스택 영역을 동적으로 추가 할당한다. 제2 태스크(Task2)의 경우 최대 사용량이 0x30이고 현재 남은 스택 영역의 사이즈가 0x100인 경우 추가적인 동적 스택 할당이 필요하지 않은 것으로 판단한다. 제3 태스크(Task3)의 경우 최대 사용량이 0x100이고 현재 남은 스택 영역의 사이즈가 0x110인 경우 추가적인 동적 스택 할당이 필요한 것으로 판단하여 임시 스택 영역을 동적으로 추가 할당한다.For example, in the case of the first task Task1, when the maximum usage is 0x20 and the size of the currently remaining stack area is also 0x20, it is determined that additional dynamic stack allocation is required and the temporary stack area is dynamically additionally allocated. In the case of the second task Task2, when the maximum usage is 0x30 and the size of the current remaining stack area is 0x100, it is determined that additional dynamic stack allocation is not required. In the case of the third task (Task3), when the maximum usage is 0x100 and the size of the current remaining stack area is 0x110, it is determined that additional dynamic stack allocation is required and the temporary stack area is dynamically additionally allocated.

이에 따라 해당 어플리케이션 소프트웨어 실행 중 스택 결함의 발생을 방지할 수 있는 상태가 되는 것이다.Accordingly, it is in a state in which the occurrence of a stack defect can be prevented while the corresponding application software is being executed.

이후 상기 도 5에서 설명한 바와 마찬가지로 방식으로, 상기 중앙처리장치(100)는 최초 설정된 스택 영역에 동적으로 추가 할당된 임시 스택 영역에서 사용된 스택 영역의 총 합이 최초 설정된 스택 영역의 사이즈를 초과한 경우, 스택 결함(에러)이 발생되었음을 알람하고 스택 히스토리(예 : 컨텍스트와 스택 포인터 값)를 반환한다. Thereafter, in the same manner as described in FIG. 5 , the central processing unit 100 determines that the sum of the stack areas used in the temporary stack area dynamically additionally allocated to the initially set stack area exceeds the size of the initially set stack area. In this case, it alarms that a stack fault (error) has occurred and returns the stack history (eg, context and stack pointer values).

이에 따라 중앙처리장치(10))는 사용자 인터페이스(UI)를 통해 사용자에게 어플리케이션 소프트웨어의 스택 결함이 발생하는 원인(예 : 스택 결함을 발생시키는 컨텍스트)을 파악할 수 있도록 함으로써, 사용자에게 상기 파악된 원인(예 : 스택 결함을 발생시키는 컨텍스트)을 제거하기 위한 작업(예 : 어플리케이션 소프트웨어의 코드 수정)을 수행할 수 있도록 한다.Accordingly, the central processing unit 10) allows the user to identify the cause (eg, the context in which the stack defect occurs) of the application software occurs to the user through the user interface (UI), thereby providing the user with the identified cause. Allows you to perform actions (eg, modifying code in application software) to eliminate (eg, contexts that cause stack faults).

상기와 같이 본 실시예는 스택 히스토리(즉, 스택 사용 히스토리)를 기록함으로써 오류 발생시에 원인에 대한 정확한 분석이 가능하며, 스택 결함이 발생하지 않더라도 스택에 얼마나 여유가 있는지 검토하고 마진을 설계할 수 있는 효과가 있으며, 특정 소프트웨어 기능이 비정상적으로 많은 스택을 차지하는지 미리 검출할 수 있고, 또한 만약 소프트웨어의 실행중에 스택 결함(오류)가 발생하더라도 프로그램 손상없이 해결이 가능하게 하는 효과가 있다.As described above, in this embodiment, by recording the stack history (i.e., the stack usage history), it is possible to accurately analyze the cause when an error occurs. It has an effective effect, it can detect in advance whether a specific software function occupies an abnormally large stack, and also has the effect of enabling resolution without program damage even if a stack defect (error) occurs during software execution.

이상으로 본 발명은 도면에 도시된 실시예를 참고로 하여 설명되었으나, 이는 예시적인 것에 불과하며, 당해 기술이 속하는 분야에서 통상의 지식을 가진 자라면 이로부터 다양한 변형 및 균등한 타 실시예가 가능하다는 점을 이해할 것이다. 따라서 본 발명의 기술적 보호범위는 아래의 특허청구범위에 의해서 정하여져야 할 것이다. 또한 본 명세서에서 설명된 구현은, 예컨대, 방법 또는 프로세스, 장치, 소프트웨어 프로그램, 데이터 스트림 또는 신호로 구현될 수 있다. 단일 형태의 구현의 맥락에서만 논의(예컨대, 방법으로서만 논의)되었더라도, 논의된 특징의 구현은 또한 다른 형태(예컨대, 장치 또는 프로그램)로도 구현될 수 있다. 장치는 적절한 하드웨어, 소프트웨어 및 펌웨어 등으로 구현될 수 있다. 방법은, 예컨대, 컴퓨터, 마이크로프로세서, 집적 회로 또는 프로그래밍 가능한 로직 디바이스 등을 포함하는 프로세싱 디바이스를 일반적으로 지칭하는 프로세서 등과 같은 장치에서 구현될 수 있다. 프로세서는 또한 최종-사용자 사이에 정보의 통신을 용이하게 하는 컴퓨터, 셀 폰, 휴대용/개인용 정보 단말기(personal digital assistant: "PDA") 및 다른 디바이스 등과 같은 통신 디바이스를 포함한다.As described above, the present invention has been described with reference to the embodiment shown in the drawings, but this is merely exemplary, and various modifications and equivalent other embodiments are possible therefrom by those of ordinary skill in the art. will understand the point. Therefore, the technical protection scope of the present invention should be defined by the following claims. Also, the implementations described herein may be implemented as, for example, a method or process, an apparatus, a software program, a data stream, or a signal. Although discussed only in the context of a single form of implementation (eg, only as a method), implementations of the discussed features may also be implemented in other forms (eg, in an apparatus or a program). The apparatus may be implemented in suitable hardware, software and firmware, and the like. A method may be implemented in an apparatus such as, for example, a processor, which generally refers to a computer, a microprocessor, a processing device, including an integrated circuit or programmable logic device, or the like. Processors also include communication devices such as computers, cell phones, portable/personal digital assistants (“PDAs”) and other devices that facilitate communication of information between end-users.

100 : 중앙처리장치
200 : 메모리부
201 : 스택부
100: central processing unit
200: memory unit
201: stack unit

Claims (16)

중앙처리장치와 스택 메모리를 포함하는 컴퓨팅 시스템에서 스택 결함 원인을 진단하는 방법에 있어서,
어플리케이션 소프트웨어의 실행에 따라 컨텍스트의 입력과 탈출이 반복되는 과정에서, 상기 중앙처리장치가 스택 결함 발생을 감지하는 단계;
상기 스택 결함이 발생할 경우, 상기 중앙처리장치가 스택 히스토리를 반환하는 단계; 및
상기 스택 히스토리가 반환되면, 상기 중앙처리장치가 상기 스택 히스토리에 기초하여 스택 결함을 발생시키는 컨텍스트를 파악하는 단계;를 포함하고,
상기 스택 히스토리에 기초하여 스택 결함을 발생시키는 컨텍스트를 파악하는 단계에서,
상기 중앙처리장치는,
컨텍스트가 입력될 때 저장한 스택 포인터와 상기 컨텍스트가 종료되어 복귀할 때 반환하는 스택 포인터가 다른 경우에 스택 결함을 발생시키는 컨텍스트로 파악하는 것을 특징으로 하는 스택 결함 원인을 진단하는 방법.
A method for diagnosing a cause of a stack fault in a computing system including a central processing unit and a stack memory, the method comprising:
detecting, by the central processing unit, occurrence of a stack defect in a process in which input and exit of a context are repeated according to the execution of application software;
returning, by the central processing unit, a stack history when the stack fault occurs; and
When the stack history is returned, determining, by the central processing unit, a context in which a stack fault occurs based on the stack history;
In the step of identifying a context that causes a stack fault based on the stack history,
The central processing unit,
A method for diagnosing a cause of a stack fault, characterized in that, when the stack pointer stored when a context is input and the stack pointer returned when the context is terminated and returned are different, the context causing the stack fault is identified.
제 1항에 있어서, 상기 스택 히스토리는,
컨텍스트와 스택 포인터 값을 포함하는 것을 특징으로 하는 스택 결함 원인을 진단하는 방법.
The method of claim 1, wherein the stack history comprises:
A method for diagnosing the cause of a stack fault, comprising a context and a stack pointer value.
제 1항에 있어서, 상기 스택 결함 발생을 감지하는 단계 이전에,
상기 스택 결함 발생 시 컴퓨팅 시스템이 다운되거나 리셋되는 것을 방지하기 위하여, 상기 중앙처리장치가, 스택 사용량이 최초 설정된 스택 영역 사이즈에 대하여 미리 지정된 마진 값에 도달하는지 체크하는 단계; 및
상기 스택 사용량이 최초 설정된 스택 영역 사이즈에 대하여 미리 지정된 마진 값에 도달할 경우에 임시 스택 영역을 동적으로 추가 할당하는 단계;를 더 포함하는 것을 특징으로 하는 스택 결함 원인을 진단하는 방법.
The method of claim 1 , wherein prior to the step of detecting the occurrence of the stack fault,
checking, by the central processing unit, whether the stack usage reaches a predetermined margin value with respect to an initially set stack area size in order to prevent the computing system from being down or reset when the stack fault occurs; and
and dynamically allocating a temporary stack area additionally when the stack usage reaches a predetermined margin value with respect to an initially set stack area size.
제 1항에 있어서, 상기 스택 결함 발생을 감지하는 단계 이전에,
상기 스택 결함 발생 시 컴퓨팅 시스템이 다운되거나 리셋되는 것을 방지하기 위하여, 상기 중앙처리장치가, 컨텍스트 스위칭 시 이벤트가 발생할 때마다 사용했던 최대 스택 사용량을 기록하고, 최초 설정된 스택 영역에서 현재 남은 스택 영역의 사이즈를 산출하는 단계; 및
상기 중앙처리장치가, 현재 남은 스택 영역의 사이즈와 해당 컨텍스트가 사용한 스택의 최대 사용량을 비교하여, 상기 최대 사용량에 지정된 마진 값을 합산한 스택 용량이 현재 남은 스택 영역의 사이즈보다 큰 경우, 추가적인 동적 스택 영역의 할당이 필요한 것으로 판단하여 임시 스택 영역을 동적으로 추가 할당하는 단계;를 더 포함하는 것을 특징으로 하는 스택 결함 원인을 진단하는 방법.
The method of claim 1 , wherein prior to the step of detecting the occurrence of the stack fault,
In order to prevent the computing system from being down or reset when the stack fault occurs, the central processing unit records the maximum stack usage each time an event occurs during context switching, and records the stack area currently remaining in the initially set stack area. calculating a size; and
The central processing unit compares the size of the currently remaining stack area with the maximum usage of the stack used by the context, and when the stack capacity obtained by adding the margin value specified to the maximum usage is larger than the size of the currently remaining stack area, additional dynamics The method of diagnosing a cause of a stack defect, further comprising: determining that allocation of a stack area is necessary and dynamically additionally allocating a temporary stack area.
제 3항 또는 4항에 있어서, 상기 스택 결함 발생을 감지하는 단계에서,
상기 중앙처리장치는,
최초 설정된 스택 영역에서 이미 사용된 스택 영역과 상기 동적으로 추가 할당된 임시 스택 영역에서 추가로 사용된 스택 영역의 총 합이 상기 최초 설정된 스택 영역의 사이즈를 초과한 경우, 스택 결함이 발생된 것으로 감지하는 것을 특징으로 하는 스택 결함 원인을 진단하는 방법.
According to claim 3 or 4, in the step of detecting the occurrence of the stack fault,
The central processing unit,
When the sum of the stack area already used in the initially set stack area and the stack area additionally used in the dynamically additionally allocated temporary stack area exceeds the size of the initially set stack area, a stack defect is detected A method for diagnosing the cause of a stack fault, characterized in that
삭제delete 제 1항에 있어서,
상기 스택 결함을 발생시키는 컨텍스트를 파악하는 단계 이후,
상기 중앙처리장치가,
상기 스택 결함을 발생시키는 컨텍스트를 사용자 인터페이스를 통해 표시하는 단계;를 더 포함하는 것을 특징으로 하는 스택 결함 원인을 진단하는 방법.
The method of claim 1,
After identifying the context causing the stack fault,
The central processing unit,
The method of diagnosing a cause of a stack fault further comprising; displaying a context in which the stack fault occurs through a user interface.
제 7항에 있어서, 상기 스택 결함을 발생시키는 컨텍스트를 사용자 인터페이스를 통해 표시하는 단계 이후,
상기 중앙처리장치가 사용자 인터페이스를 통해 사용자에게 어플리케이션 소프트웨어의 계속 진행 여부를 체크하는 단계; 및
사용자가 계속 진행 선택 시, 상기 중앙처리장치가 어플리케이션 소프트웨어를 계속 실행시켜 스택 결함을 발생시키는 다른 컨텍스트를 계속해서 파악하는 단계;를 더 포함하는 것을 특징으로 하는 스택 결함 원인을 진단하는 방법.
The method of claim 7, wherein after displaying the context causing the stack fault through a user interface,
checking, by the central processing unit, whether the application software continues to the user through a user interface; and
The method of diagnosing a cause of a stack defect further comprising: when the user selects to continue, the central processing unit continues to execute the application software to continuously identify another context that causes the stack defect.
컴퓨팅 시스템의 스택 메모리; 및
상기 컴퓨팅 시스템에서 어플리케이션 소프트웨어의 실행에 따라 컨텍스트의 입력과 탈출이 반복되는 과정에서 스택 결함 발생을 감지하는 중앙처리장치;를 포함하고,
상기 스택 결함이 발생할 경우,
상기 중앙처리장치가 스택 히스토리를 반환하고, 상기 반환된 스택 히스토리를 분석하여 스택 결함을 발생시키는 컨텍스트를 파악하되,
상기 중앙처리장치는, 컨텍스트가 입력될 때 저장한 스택 포인터와 상기 컨텍스트가 종료되어 복귀할 때 반환하는 스택 포인터가 다른 경우에 스택 결함을 발생시키는 컨텍스트로 파악하는 것을 특징으로 하는 스택 결함 원인을 진단하는 장치.
stack memory of the computing system; and
a central processing unit that detects the occurrence of a stack defect in the process of repeatedly entering and exiting the context according to the execution of the application software in the computing system; and
If the above stack fault occurs,
The central processing unit returns a stack history and analyzes the returned stack history to determine a context in which a stack fault occurs,
The central processing unit diagnoses the cause of a stack fault, characterized in that, when a stack pointer stored when a context is input and a stack pointer returned when the context is terminated and returned are different, it is determined as a context causing a stack fault. device to do.
제 9항에 있어서, 상기 스택 히스토리는,
컨텍스트와 스택 포인터 값을 포함하는 것을 특징으로 하는 스택 결함 원인을 진단하는 장치.
10. The method of claim 9, wherein the stack history,
A device for diagnosing the cause of a stack fault, characterized in that it includes a context and a stack pointer value.
제 9항에 있어서, 상기 중앙처리장치는,
상기 스택 결함 발생 시 컴퓨팅 시스템이 다운되거나 리셋되는 것을 방지하기 위하여, 스택 결함 발생을 감지하는 단계 이전에, 스택 사용량이 최초 설정된 스택 영역 사이즈에 대하여 미리 지정된 마진 값에 도달하는지 체크하고,
상기 스택 사용량이 최초 설정된 스택 영역 사이즈에 대하여 미리 지정된 마진 값에 도달할 경우에 임시 스택 영역을 동적으로 추가 할당하는 것을 더 포함하는 것을 특징으로 하는 스택 결함 원인을 진단하는 장치.
10. The method of claim 9, wherein the central processing unit,
In order to prevent the computing system from being down or reset when the stack fault occurs, before the step of detecting the occurrence of the stack fault, it is checked whether the stack usage reaches a predetermined margin value for the initially set stack area size,
The apparatus for diagnosing a cause of a stack defect, further comprising dynamically allocating a temporary stack area when the stack usage reaches a predetermined margin value with respect to an initially set stack area size.
제 9항에 있어서, 상기 중앙처리장치는,
상기 스택 결함 발생 시 컴퓨팅 시스템이 다운되거나 리셋되는 것을 방지하기 위하여, 스택 결함 발생을 감지하는 단계 이전에, 컨텍스트 스위칭 시 이벤트가 발생할 때마다 사용했던 최대 스택 사용량을 기록하고, 최초 설정된 스택 영역에서 현재 남은 스택 영역의 사이즈를 산출하고,
현재 남은 스택 영역의 사이즈와 해당 컨텍스트가 사용한 스택의 최대 사용량을 비교하여, 상기 최대 사용량에 지정된 마진 값을 합산한 스택 용량이 현재 남은 스택 영역의 사이즈보다 큰 경우, 임시 스택 영역을 동적으로 추가 할당하는 것을 특징으로 하는 스택 결함 원인을 진단하는 장치.
10. The method of claim 9, wherein the central processing unit,
In order to prevent the computing system from being down or reset when the stack fault occurs, prior to the step of detecting the occurrence of the stack fault, the maximum stack usage used whenever an event occurs during context switching is recorded, and in the initially set stack area, the current Calculate the size of the remaining stack area,
Compares the size of the current remaining stack area with the maximum usage of the stack used by the context, and dynamically allocates a temporary stack area when the sum of the margin value specified for the maximum usage is larger than the size of the current remaining stack area. A device for diagnosing the cause of a stack fault, characterized in that.
제 11항 또는 12항에 있어서, 상기 중앙처리장치는,
최초 설정된 스택 영역에서 이미 사용된 스택 영역과 상기 동적으로 추가 할당된 임시 스택 영역에서 추가로 사용된 스택 영역의 총 합이 상기 최초 설정된 스택 영역의 사이즈를 초과한 경우, 스택 결함이 발생된 것으로 감지하는 것을 특징으로 하는 스택 결함 원인을 진단하는 장치.
According to claim 11 or 12, wherein the central processing unit,
When the sum of the stack area already used in the initially set stack area and the stack area additionally used in the dynamically additionally allocated temporary stack area exceeds the size of the initially set stack area, a stack defect is detected A device for diagnosing the cause of a stack fault, characterized in that.
삭제delete 제 9항에 있어서, 상기 중앙처리장치는,
상기 스택 결함을 발생시키는 컨텍스트를 파악하면,
상기 스택 결함을 발생시키는 컨텍스트를 사용자 인터페이스를 통해 표시하는 것을 특징으로 하는 스택 결함 원인을 진단하는 장치.
10. The method of claim 9, wherein the central processing unit,
If the context causing the stack fault is identified,
The apparatus for diagnosing a cause of a stack fault, characterized in that the context causing the stack fault is displayed through a user interface.
제 15항에 있어서, 상기 중앙처리장치는,
상기 스택 결함을 발생시키는 컨텍스트를 사용자 인터페이스를 통해 표시한 이후, 상기 사용자 인터페이스를 통해 사용자에게 어플리케이션 소프트웨어의 계속 진행 여부를 체크하고,
사용자가 계속 진행 선택 시, 어플리케이션 소프트웨어를 계속 실행시켜 스택 결함을 발생시키는 다른 컨텍스트를 계속해서 파악하는 것을 특징으로 하는 스택 결함 원인을 진단하는 장치.
The method of claim 15, wherein the central processing unit,
After displaying the context causing the stack fault through the user interface, it is checked whether the application software continues to the user through the user interface,
A device for diagnosing the cause of a stack fault, characterized in that when the user selects to continue, the application software is continuously executed to continuously identify other contexts causing the stack fault.
KR1020190151477A 2019-11-22 2019-11-22 Diagnosing method for cause of stack fault and apparatus thereof KR102300712B1 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
KR1020190151477A KR102300712B1 (en) 2019-11-22 2019-11-22 Diagnosing method for cause of stack fault and apparatus thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
KR1020190151477A KR102300712B1 (en) 2019-11-22 2019-11-22 Diagnosing method for cause of stack fault and apparatus thereof

Publications (2)

Publication Number Publication Date
KR20210063519A KR20210063519A (en) 2021-06-02
KR102300712B1 true KR102300712B1 (en) 2021-09-13

Family

ID=76372632

Family Applications (1)

Application Number Title Priority Date Filing Date
KR1020190151477A KR102300712B1 (en) 2019-11-22 2019-11-22 Diagnosing method for cause of stack fault and apparatus thereof

Country Status (1)

Country Link
KR (1) KR102300712B1 (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009205484A (en) 2008-02-28 2009-09-10 Nec Corp Failure cause analysis support device and method, and program
KR100928865B1 (en) 2008-02-28 2009-11-30 주식회사 안철수연구소 Stack expansion and protection methods in computer systems and devices therefor
JP2017162135A (en) * 2016-03-09 2017-09-14 三菱電機株式会社 Information processing device, debug system, and stack overflow detection method

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100866218B1 (en) * 2002-01-08 2008-10-30 삼성전자주식회사 Method for stable tracing stack
KR101334172B1 (en) * 2007-01-05 2013-11-28 삼성전자주식회사 Method and appratus for preventing stack overflow in embedded system
KR102052816B1 (en) * 2018-03-15 2019-12-05 한양대학교 에리카산학협력단 Method for recovering error in non-volatile main memory unit and system therefor

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2009205484A (en) 2008-02-28 2009-09-10 Nec Corp Failure cause analysis support device and method, and program
KR100928865B1 (en) 2008-02-28 2009-11-30 주식회사 안철수연구소 Stack expansion and protection methods in computer systems and devices therefor
JP2017162135A (en) * 2016-03-09 2017-09-14 三菱電機株式会社 Information processing device, debug system, and stack overflow detection method

Also Published As

Publication number Publication date
KR20210063519A (en) 2021-06-02

Similar Documents

Publication Publication Date Title
US8397111B2 (en) Software memory leak analysis using memory isolation
US9658930B2 (en) Method and device for managing hardware errors in a multi-core environment
US7937615B2 (en) Method for improving reliability of multi-core processor computer
JP4770602B2 (en) Electronics
US20080276129A1 (en) Software tracing
US9436534B2 (en) Method and system for preemptive detection of occurrence of faulty conditions based on resource usage
US6629252B1 (en) Method for determining if a delay required before proceeding with the detected interrupt and exiting the interrupt without clearing the interrupt
EP3486781A1 (en) Semiconductor device
US8099717B2 (en) Tracking method for embedded system
EP2645635A1 (en) Cluster monitor, method for monitoring a cluster, and computer-readable recording medium
JP5359601B2 (en) Dump output control device, dump output control program, and dump output control method
US20080133975A1 (en) Method for Running a Computer Program on a Computer System
KR20100010390A (en) Microcomputer and method for controlling thereof
CN108415765B (en) Task scheduling method and device and intelligent terminal
KR102300712B1 (en) Diagnosing method for cause of stack fault and apparatus thereof
JP4761229B2 (en) Operation management apparatus, operation management method and program
US20130318310A1 (en) Processor processing method and processor system
CN111400087A (en) Control method of operating system, terminal and storage medium
KR100697988B1 (en) Apparatus and method for protecting system from excessive occurrence of interrupt
US8312433B2 (en) Operating system aided code coverage
US9348667B2 (en) Apparatus for managing application program and method therefor
US20090100116A1 (en) Electronic equipment and memory managing program
US7814288B2 (en) Protecting memory operations involving zero byte allocations
US7769976B2 (en) Identifying code that wastes virtual memory
CN113886490A (en) Method and system for realizing high availability of stateless computing instances in distributed database

Legal Events

Date Code Title Description
E701 Decision to grant or registration of patent right
GRNT Written decision to grant