Program call stack acquisition method, controller and storage medium

By using message queues in the VxWorks operating system to convert task user state identifiers into kernel state identifiers, bypassing the address space protection mechanism, the exception information transmission from user space to kernel space is realized, and the problem of inefficiency in obtaining the program call stack is solved. Improved diagnosis speed.

CN119065871APending Publication Date: 2024-12-03NIO TECH ANHUI CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411200042.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

Under the VxWorks operating system, the user space and kernel space cannot directly transmit exception program information, resulting in the inability to efficiently obtain the program call stack, affecting the diagnostic efficiency of program crashes or exceptions.

Method used

By obtaining the task user state identity of an exception task in the user space, converting it into a task name, putting it into a message queue, taking out the task name from the kernel space and converting it into a task kernel state identity, and using the kernel space stack trace tool to obtain the program Call stack to bypass the address space protection mechanism to realize information transmission.

Benefits of technology

Improves the efficiency of obtaining the program call stack when a program crashes or exceptions under the VxWorks operating system, simplifies the workflow of developers, and significantly speeds up the problem diagnosis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119065871A_ABST
    Figure CN119065871A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of computers, particularly provides a program call stack acquisition method, a controller and a storage medium, and aims to solve the problem that a program call stack cannot be efficiently and directly acquired under a VxWorks operating system. In order to achieve the purpose, the method comprises the steps that when a program in a user space of the VxWorks operating system is abnormal, a task user state identifier of an abnormal task in the abnormal program is obtained in the user space, the task user state identifier is converted into a task name, the task name is put into a message queue, in a kernel space of the VxWorks operating system, the task name is taken out of the message queue, and the task name is stored in the kernel space of the VxWorks operating system. According to the method, the task name is converted into the task kernel mode identifier, then the program call stack of the abnormal program is obtained, an address space protection mechanism of a VxWorks operating system is bypassed, transmission of task information from a user space to a kernel space in the operating system is achieved, and then the program call stack can be directly obtained in the kernel space; the efficiency of obtaining the program call stack of the abnormal program in the VxWorks operating system is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and specifically provides a method for obtaining a program call stack, a controller, and a storage medium. Background Art

[0002] In the prior art, during the software development process, the program may crash or experience abnormal conditions due to various reasons. These problems are often difficult to accurately capture and diagnose during runtime. In order to analyze these program crashes or program abnormalities, the prior art usually uses the core dump file provided by the operating system to record the program's memory state (including data such as the heap, stack, and global variables) at the time of the crash, the instructions that caused the crash, the register state, and the function call stack information, which is equivalent to a frozen snapshot. By parsing the core dump file, developers can restore the scene when the program crashed and deeply analyze the cause of the program crash.

[0003] However, under the VxWorks operating system, this method needs to be copied to the console (workbench) together with the executable program and the dependent library files before parsing. The parsing process is cumbersome, time-consuming, and inefficient. If a cross-domain log system is used to monitor abnormal programs and obtain the program call stack. Since the cross-domain log system is a user-mode program, it cannot directly call the stack tracking tool in the kernel space to obtain the program call stack. In addition, there is an address space protection mechanism in the VxWorks operating system, that is, each real-time process task has different identifiers in the user space and the kernel space, and there is also a problem that the abnormal data obtained by the cross-domain log system cannot be directly transferred from the user space of the operating system to the kernel space.

[0004] Accordingly, a new solution is needed in the art to solve the above problems. Summary of the invention

[0005] In order to overcome the above-mentioned defects, the present application is proposed to provide a solution or at least partially solve the problem that under the VxWorks operating system, the user space and the kernel space cannot transmit the information of the abnormal program, and thus cannot efficiently and directly obtain the program call stack.

[0006] In a first aspect, the present application provides a method for obtaining a program call stack, comprising:

[0007] When a program in the user space of the VxWorks operating system is abnormal, a task user state identifier of an abnormal task in the abnormal program is obtained in the user space, the task user state identifier is converted into a task name, and the task name is put into a message queue, wherein the task name corresponds to the task user state identifier one by one;

[0008] In the kernel space of the VxWorks operating system, the task name is taken out from the message queue, the taken out task name is converted into a task kernel state identifier, and the program call stack of the abnormal program is obtained according to the task kernel state identifier; the task name corresponds to the task kernel state identifier one by one.

[0009] In a technical solution of the above-mentioned method for obtaining a program call stack, the step of obtaining in the user space a task user state identifier of an abnormal task in an abnormal program includes:

[0010] Based on the cross-domain log system in the user space, obtaining abnormal programs;

[0011] According to the abnormal program, a task user state identifier corresponding to an abnormal task in the abnormal program is obtained.

[0012] In a technical solution of the above-mentioned method for obtaining a program call stack, obtaining an abnormal program based on the cross-domain log system in the user space includes:

[0013] When the program in the user space is abnormal, acquiring the abnormal program based on a crash handling program in the cross-domain log system according to a task abnormality signal in the cross-domain log system;

[0014] The task exception signal is a signal pre-registered in the cross-domain log system and is triggered when the program controlled by the user is abnormal.

[0015] In a technical solution of the above-mentioned method for obtaining a program call stack, the abnormal program is a program in a real-time process, and the method further includes:

[0016] When the real-time process is started, the cross-domain log system is initialized according to preset requirements, so that the crash handling program in the cross-domain log system can capture abnormal programs in the real-time process at any time.

[0017] In a technical solution of the above-mentioned method for obtaining the program call stack, taking out the task name from the message queue includes:

[0018] The message queue is continuously monitored based on the downloadable kernel module in the kernel space to retrieve the task name in the message queue.

[0019] In a technical solution of the above-mentioned method for obtaining a program call stack, obtaining the program call stack of the abnormal program according to the task kernel state identifier includes:

[0020] According to the task kernel state identifier, a stack tracking tool in the kernel space is called to obtain a program call stack of the abnormal program.

[0021] In a technical solution of the above-mentioned method for obtaining the program call stack, converting the retrieved task name into a task kernel state identifier includes:

[0022] Based on the application programming interface of the library function in the VxWorks operating system, the retrieved task name is converted into a task kernel state identifier.

[0023] In a technical solution of the above method for acquiring a program call stack, after acquiring the program call stack of the abnormal program according to the task kernel state identifier, the method further includes:

[0024] Based on the console program in the VxWorks operating system, the program call stack is visualized and displayed, and the program call stack is saved in an exception log file.

[0025] In a third aspect, a controller is provided, which includes at least one processor and at least one memory, wherein the memory is suitable for storing multiple program codes, and the program codes are suitable for being loaded and run by the processor to execute the program call stack acquisition method described in any one of the technical solutions of the above-mentioned program call stack acquisition method.

[0026] In a fourth aspect, a computer-readable storage medium is provided, which stores a plurality of program codes, wherein the program codes are suitable for being loaded and run by a processor to execute the program call stack acquisition method described in any one of the technical solutions of the above-mentioned program call stack acquisition method.

[0027] The above one or more technical solutions of this application have at least one or more of the following Beneficial effects: In the technical solution for implementing the present application, when a program in the user space of the VxWorks operating system is abnormal, the present application obtains the task user state identifier of the abnormal task in the abnormal program in the user space, converts the task user state identifier into a task name, and puts the task name into a message queue. In the kernel space of the VxWorks operating system, the task name is taken out from the message queue, the taken out task name is converted into a task kernel state identifier, and the program call stack of the abnormal program is obtained according to the task kernel state identifier. Through the above configuration, the present application converts between the user state identifier and the kernel state identifier through the task name, and uses the message queue to pass the task name to the kernel space, which can bypass the address space protection mechanism of the VxWorks operating system and realize the transfer of abnormal program information from the user space to the kernel space in the VxWorks operating system. In this way, the limitation that the user state program cannot directly call the stack tracking tool is bypassed, and the program call stack can be directly obtained in the kernel space. Compared with the prior art, the present application effectively improves the efficiency of obtaining the program call stack when a program crashes or anomalies occur in the VxWorks operating system, greatly simplifies the workflow of developers, and improves the speed of problem diagnosis. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The disclosure of the present application will become more easily understood with reference to the accompanying drawings. It is easy for those skilled in the art to understand that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present application. In addition, similar numbers in the drawings are used to represent similar components, among which:

[0029] Figure 1 It is a flowchart of the main steps of a method for obtaining a program call stack according to an embodiment of the present application;

[0030] Figure 2 It is a flowchart of the main steps of obtaining a task user state identifier according to an implementation method of an embodiment of the present application;

[0031] Figure 3 It is a schematic diagram of the main structural block diagram of a method for obtaining a program call stack according to an implementation method of an embodiment of the present application;

[0032] Figure 4 It is a schematic diagram of the main structural block diagram of a controller according to an embodiment of the present application. DETAILED DESCRIPTION

[0033] Some embodiments of the present application are described below with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are only used to explain the technical principles of the present application and are not intended to limit the protection scope of the present application.

[0034] In the description of the present application, "module" and "processor" may include hardware, software or a combination of the two. A module may include hardware circuits, various suitable sensors, communication ports, memory, and may also include software parts, such as program code, or a combination of software and hardware. The processor may be a central processing unit, a microprocessor, an image processor, a digital signal processor or any other suitable processor. The processor has data and / or signal processing functions. The processor may be implemented in software, hardware or a combination of the two. Non-temporary computer-readable storage media include any suitable medium that can store program code, such as a disk, a hard disk, an optical disk, a flash memory, a read-only memory, a random access memory, etc. The term "A and / or B" means all possible combinations of A and B, such as only A, only B or A and B. The term "at least one A or B" or "at least one of A and B" has a similar meaning to "A and / or B" and may include only A, only B or A and B. The singular terms "one" and "the" may also include plural forms.

[0035] Here we first explain some terms involved in this application.

[0036] VxWorks operating system is a real-time operating system (RTOS). It is designed for embedded systems and has the characteristics of real-time, reliability and scalability. It is widely used in aerospace, telecommunications, automotive electronics, defense and industrial automation.

[0037] The VxWorks operating system consists of user space and kernel space. The kernel space is the area where the VxWorks operating system kernel runs, storing the operating system kernel code, data structures, and device drivers. The user space refers to the area where user-mode programs run, including the application code, data, and stack of user-mode programs. In order to ensure that user-mode programs in the user space cannot directly access or modify the data structures and hardware resources in the kernel space, thereby preventing malicious code and software errors from damaging the entire operating system, the VxWorks operating system establishes an address space protection mechanism through measures such as address space management and remapping mechanisms, that is, the kernel space is separated from the user space, and each task (task) of each real-time process (RTP) in the VxWorks operating system has a different identifier (taskId) in the user space and kernel space.

[0038] The program call stack is a data structure used in computer science to store information about running subroutines. It is mainly used to support function calls, pass process parameters, store return information, and save register information for restoring and storing local variables. Every time a program is called, the system will open up a space in the stack to save the execution status. If the program crashes during debugging, the stack information at the time of the problem is usually used to find the error.

[0039] See attached Figure 1 , Figure 1 FIG. 1 is a flow chart of the main steps of a method for obtaining a program call stack according to an embodiment of the present application. Figure 1 As shown, the program call stack acquisition method in the embodiment of the present application mainly includes the following steps S101-S104.

[0040] In this embodiment, the program call stack acquisition method in the embodiment of the present application can be applied to the VxWorks operating system. When an exception occurs in a program in the user space of the VxWorks operating system, the following steps S101 to S104 are performed.

[0041] Step S101: In the user space of the VxWorks operating system, a task user state identifier of an abnormal task in an abnormal program is obtained.

[0042] In this embodiment, the abnormal program is a user-mode application program in the user space of the VxWorks operating system, which may include multiple tasks. The task user-mode identifier is an identifier corresponding to the task running in the user space when an abnormal program occurs.

[0043] Among them, a task is an execution unit in the operating system. It is the smallest unit for the operating system to allocate and manage computer resources and can be run, scheduled and managed independently.

[0044] In one embodiment, please refer to the attached Figure 2 , Figure 2 FIG. 1 is a flow chart of the main steps of obtaining a task user state identifier according to an implementation of an embodiment of the present application. Figure 2 As shown, step S101 may further include the following steps S1011-S1012:

[0045] Step S1011: Based on the cross-domain log system in the user space, obtain the abnormal program.

[0046] Step S1012: According to the abnormal program, obtain the task user state identifier corresponding to the abnormal task in the abnormal program.

[0047] In this embodiment, the cross-domain log system is an open source log system, which is mainly used to collect, analyze and store log information of the VxWorks operating system.

[0048] In one implementation, step S1011 may further include:

[0049] When a program in the user space is abnormal, the abnormal program is obtained based on a crash handler in the cross-domain log system according to a task abnormality signal in the cross-domain log system.

[0050] In this embodiment, the task exception signal is a signal pre-registered in the cross-domain log system and is triggered when a program in the user space is abnormal.

[0051] Specifically, the task abnormality signal may include the following signals:

[0052] The "Signal Abort" signal (SIGABRT) is triggered when a termination exception (Abort) occurs in a user space program; the "Floating Point Exception" signal (SIGFPE) is triggered when a floating point exception (Floating Point Exception) occurs in the program; the "Illegal Instruction" signal (SIGILL) is triggered when an illegal instruction exception (Illegal Instruction) occurs in the program; the "Memory Segmentation Error" signal (SIGSEGV) is triggered when a segmentation error or segmentation violation exception (Segmentation Violation) occurs in the program; the "Process Termination" signal (SIGTERM) is triggered when a program abnormal termination (Termination) occurs.

[0053] In one implementation, the abnormal program may be a program in a real-time process.

[0054] Among them, the real-time process (RTP) is a user-mode application that includes programs (code and data), stacks, heaps, tasks belonging to this real-time process, and various software objects created by the real-time process and other resources it manages.

[0055] In this implementation, before step S101, the present application may further include the following step S201:

[0056] Step S201: when starting a real-time process, the cross-domain log system is initialized according to preset requirements, so that the crash handling program in the cross-domain log system can capture abnormal programs in the real-time process at any time.

[0057] Among them, those skilled in the art can perform initialization operations on the cross-domain log system according to the needs of actual applications. For example, a task exception signal can be registered in the cross-domain log system. For example, an init_crash_dump() function can be executed in the cross-domain log system.

[0058] Step S102: Convert the task user state identifier into a task name, and put the task name into a message queue.

[0059] In this embodiment, the task name corresponds to the task user state identifier one by one.

[0060] In one implementation, the conversion between the task user state identifier and the task name can be completed by using the application programming interface of the library function in the VxWorks operating system.

[0061] Step S103: In the kernel space of the VxWorks operating system, the task name is taken out from the message queue.

[0062] In one embodiment, step S103 may further include: based on the downloadable kernel module in the kernel space, continuously monitoring the message queue to take out the task name in the message queue. That is, when the downloadable kernel module monitors that a task name is put into the message queue, the task names in the message queue can be taken out in sequence. When there are multiple task names in the message queue, the task names can be taken out according to the order in which the task names are put in.

[0063] The downloadable kernel module (Downloadable Kernel Module, DKM) is an application module created in advance in the kernel space and used to directly call the stack tracing tool.

[0064] Step S104: converting the retrieved task name into a task kernel state identifier, and acquiring the program call stack of the abnormal program according to the task kernel state identifier.

[0065] In this embodiment, the task kernel state identifier is the identifier corresponding to the task in the kernel space where the exception occurs in the abnormal program. The task name corresponds to the task kernel state identifier one by one.

[0066] In one implementation, converting the retrieved task name into a task kernel state identifier may further include:

[0067] Based on the application programming interface of the library function in the VxWorks operating system, the retrieved task name is converted into a task kernel state identifier.

[0068] In one implementation, obtaining the program call stack of the abnormal program according to the task kernel state identifier may further include:

[0069] According to the task kernel state identifier, a stack trace tool in the kernel space is called to obtain the program call stack of the abnormal program.

[0070] In this embodiment, the stack trace tool (dbgStacktrace) is a commonly used debugging tool for directly obtaining the program call stack of an abnormal program.

[0071] In one implementation, the program call stack may be visualized based on a console program in a VxWorks operating system, and the program call stack may be saved in an exception log file.

[0072] In some implementations, operations such as capturing abnormal programs in the above-mentioned program call stack acquisition method, acquiring task user state identifiers, and converting between user state identifiers and task names can also be integrated into the cross-domain log system to make the process of program exception tracking and diagnosis more automated and systematic.

[0073] In one embodiment, please refer to the attached Figure 3 , Figure 3 FIG. 1 is a schematic diagram of the main structure of a method for obtaining a program call stack according to an implementation of an embodiment of the present application. Figure 3 As shown, in this implementation, the method for obtaining a program call stack may include the following steps S301 to S305:

[0074] Step S301: when an exception occurs in a real-time process in the user space, a user state identifier corresponding to the abnormal task in the real-time process is obtained based on a cross-domain log system.

[0075] In this implementation, the crash handling program of the cross-domain log system (equivalent to the attached Figure 3 The crashhandler in the real-time process monitors multiple real-time processes at the same time. When a real-time process is abnormal, the user state identifier corresponding to the abnormal task in the real-time process is obtained.

[0076] In this embodiment, the real-time process may include Figure 3 RTP_1, RTP_2... and RTP_n in the "user state identifier" can be equivalent to the attached Figure 3 'taskIdself' in .

[0077] In one implementation, if an exception occurs in a real-time process, the real-time process will be automatically captured by a signal processing function (signalHandler()) of a crash handling program.

[0078] In one implementation, the crash handling program may obtain the user state identifier of the abnormal task through the taskIdSelf() function.

[0079] Step S302: In the cross-domain log system, the user state identifier is converted into a task name, and the task name is passed to the message queue.

[0080] In this embodiment, the task name is equivalent to the attached Figure 3 The 'taskName' in the message queue is equivalent to the attached Figure 3 'msgQueue' in .

[0081] In this implementation, the acquired user state identifier may be converted into a task name through the taskName() function.

[0082] Step S303: based on the downloadable kernel module, taking out and reading task names in sequence from the message queue.

[0083] In this embodiment, the downloadable kernel module is equivalent to the attached Figure 3 'DKM Modules' in .

[0084] In this embodiment, the downloadable kernel module can establish a connection with the cross-domain log system through a message queue in advance to transfer the task name.

[0085] Step S304: Convert the task name into a corresponding kernel state identifier in the kernel space.

[0086] In this embodiment, the kernel state flag is equivalent to the attached Figure 3 The 'taskId' in the

[0087] In this implementation, the kernel state identifier of the task name in the kernel space may be obtained through the taskNameToId() function.

[0088] Step S305: Based on the downloadable kernel module, a call stack tracking tool is used to obtain a program call stack corresponding to the kernel state identifier.

[0089] In this embodiment, the stack trace tool is equivalent to the attached Figure 3 'dbgStackTrace' in .

[0090] In this implementation, the acquired program call stack information may be saved in a crash_dump.log file designed by the cross-domain log system.

[0091] In this embodiment, after an exception occurs in a program in the user space, the above steps S101 to S104 can be performed as an execution cycle, that is, to obtain the task user state identifier corresponding to the abnormal task in an abnormal program, complete the conversion of the task user state identifier to the task kernel state identifier through the task name, and then directly obtain the program call stack according to the task user state identifier, etc., as an execution cycle. If an exception occurs in another program in the user space, a new execution cycle can be started and entered.

[0092] Based on the above steps S101-S104, the embodiment of the present application performs the conversion between the task user state identifier and the task kernel state identifier through the task name, and uses the message queue to transfer the abnormal program information from the user space to the kernel space, bypassing the address space protection mechanism of the VxWorks operating system, and realizing the transfer of the abnormal program information from the user space to the kernel space in the operating system. In this way, the address space protection mechanism of the VxWorks operating system can be bypassed, and the program call stack can be directly obtained in the kernel space. Compared with the prior art, the embodiment of the present application effectively improves the efficiency of obtaining the program call stack when a program crash or anomaly occurs in the VxWorks operating system, greatly simplifies the workflow of developers, and improves the speed of problem diagnosis.

[0093] It should be pointed out that although the various steps in the above embodiments are described in a specific order, those skilled in the art can understand that in order to achieve the effect of the present application, different steps do not have to be executed in such an order. They can be executed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present application.

[0094] It is understood by those skilled in the art that all or part of the processes in the method for implementing the above-mentioned embodiment of the present application can also be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of each of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device, medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, electric carrier signal, telecommunication signal and software distribution medium that can carry the computer program code. It should be noted that the content contained in the computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable storage media do not include electric carrier signals and telecommunication signals.

[0095] Furthermore, the present application also provides a controller. Figure 4 , Figure 4 Schematic diagram of the main structure of the controller according to an embodiment of the present application. Figure 4 As shown, in a controller embodiment according to the present application, the controller includes a processor and a memory, the memory can be configured to store a program for executing the program call stack acquisition method of the above method embodiment, and the processor can be configured to execute the program in the memory, which includes but is not limited to the program for executing the program call stack acquisition method of the above method embodiment. For ease of explanation, only the parts related to the embodiment of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present application. The controller can be a controller device formed by various electronic devices.

[0096] In the embodiment of the present application, the controller may be a controller device formed by various electronic devices. In some possible implementations, the controller may include multiple memories and multiple processors. The program for executing the program call stack acquisition method of the above method embodiment may be divided into multiple subprograms, each of which may be loaded and run by a processor to execute different steps of the program call stack acquisition method of the above method embodiment. Specifically, each subprogram may be stored in different memories, and each processor may be configured to execute programs in one or more memories to jointly implement the program call stack acquisition method of the above method embodiment, that is, each processor executes different steps of the program call stack acquisition method of the above method embodiment, to jointly implement the program call stack acquisition method of the above method embodiment.

[0097] The above-mentioned multiple processors may be processors deployed on the same device. For example, the above-mentioned controller may be a high-performance device composed of multiple processors, and the above-mentioned multiple processors may be processors configured on the high-performance device. In addition, the above-mentioned multiple processors may also be processors deployed on different devices. For example, the above-mentioned controller may be a server cluster, and the above-mentioned multiple processors may be processors on different servers in the server cluster.

[0098] Furthermore, the present application also provides a computer-readable storage medium. In a computer-readable storage medium embodiment according to the present application, the computer-readable storage medium can be configured to store a program for executing the program call stack acquisition method of the above-mentioned method embodiment, and the program can be loaded and run by the processor to implement the above-mentioned program call stack acquisition method. For ease of explanation, only the parts related to the embodiment of the present application are shown. For specific technical details not disclosed, please refer to the method part of the embodiment of the present application. The computer-readable storage medium can be a memory device formed by various electronic devices. Optionally, the computer-readable storage medium in the embodiment of the present application is a non-temporary computer-readable storage medium.

[0099] Further, it should be understood that since the setting of each module is only for illustrating the functional units of the device of the present application, the physical devices corresponding to these modules may be the processor itself, or a part of the software in the processor, a part of the hardware, or a part of the combination of software and hardware. Therefore, the number of each module in the figure is only schematic.

[0100] It is understood by those skilled in the art that each module in the device can be adaptively split or merged. Such splitting or merging of specific modules will not cause the technical solution to deviate from the principle of the present application, and therefore, the technical solutions after splitting or merging will fall within the protection scope of the present application.

[0101] So far, the technical solutions of the present application have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present application is obviously not limited to these specific embodiments. Without departing from the principles of the present application, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present application.

Claims

1. A method for obtaining a program call stack, characterized in that: Applicable to VxWorks operating system, including: When a program in the user space of the VxWorks operating system is abnormal, a task user state identifier of an abnormal task in the abnormal program is obtained in the user space, the task user state identifier is converted into a task name, and the task name is put into a message queue, wherein the task name corresponds to the task user state identifier one by one; In the kernel space of the VxWorks operating system, the task name is taken out from the message queue, the taken out task name is converted into a task kernel state identifier, and the program call stack of the abnormal program is obtained according to the task kernel state identifier; the task name corresponds to the task kernel state identifier one by one.

2. The method for obtaining a program call stack according to claim 1, wherein: The step of obtaining the task user state identifier of the abnormal task in the abnormal program in the user space includes: Based on the cross-domain log system in the user space, obtaining abnormal programs; According to the abnormal program, a task user state identifier corresponding to an abnormal task in the abnormal program is obtained.

3. The method for obtaining a program call stack according to claim 2, wherein: The obtaining of abnormal programs based on the cross-domain log system in the user space includes: When the program in the user space is abnormal, acquiring the abnormal program based on a crash handling program in the cross-domain log system according to a task abnormality signal in the cross-domain log system; The task exception signal is a signal pre-registered in the cross-domain log system and is triggered when the program controlled by the user is abnormal.

4. The method for obtaining a program call stack according to claim 3, wherein: The abnormal program is a program in a real-time process, and the method further includes: When the real-time process is started, the cross-domain log system is initialized according to preset requirements, so that the crash handling program in the cross-domain log system can capture abnormal programs in the real-time process at any time.

5. The method for obtaining a program call stack according to claim 1, wherein: The taking out the task name from the message queue comprises: The message queue is continuously monitored based on the downloadable kernel module in the kernel space to retrieve the task name from the message queue.

6. The method for obtaining a program call stack according to claim 1, wherein: The acquiring the program call stack of the abnormal program according to the task kernel state identifier includes: According to the task kernel state identifier, a stack tracking tool in the kernel space is called to obtain a program call stack of the abnormal program.

7. The method for obtaining a program call stack according to claim 1, wherein: The step of converting the retrieved task name into a task kernel state identifier includes: Based on the application programming interface of the library function in the VxWorks operating system, the retrieved task name is converted into a task kernel state identifier.

8. The method for obtaining a program call stack according to claim 1, wherein: After obtaining the program call stack of the abnormal program according to the task kernel state identifier, the method further includes: Based on the console program in the VxWorks operating system, the program call stack is visualized and displayed, and the program call stack is saved in an exception log file.

9. A controller, comprising at least one processor and at least one memory, wherein the memory is suitable for storing a plurality of program codes, characterized in that: The program code is suitable for being loaded and run by the processor to execute the program call stack acquisition method according to any one of claims 1 to 8.

10. A computer-readable storage medium storing a plurality of program codes, characterized in that: The program code is suitable for being loaded and run by a processor to execute the program call stack acquisition method according to any one of claims 1 to 8.