CN120066944A - Kernel debugging method and device - Google Patents

Kernel debugging method and device Download PDF

Info

Publication number
CN120066944A
CN120066944A CN202510136247.4A CN202510136247A CN120066944A CN 120066944 A CN120066944 A CN 120066944A CN 202510136247 A CN202510136247 A CN 202510136247A CN 120066944 A CN120066944 A CN 120066944A
Authority
CN
China
Prior art keywords
module
kernel
debugging
dependency
modules
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202510136247.4A
Other languages
Chinese (zh)
Inventor
袁明明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Mgjia Beijing Technology Co ltd
Original Assignee
Mgjia Beijing Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Mgjia Beijing Technology Co ltd filed Critical Mgjia Beijing Technology Co ltd
Priority to CN202510136247.4A priority Critical patent/CN120066944A/en
Publication of CN120066944A publication Critical patent/CN120066944A/en
Pending legal-status Critical Current

Links

Classifications

    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00—Error detection; Error correction; Monitoring
    • G06F11/36—Prevention of errors by analysis, debugging or testing of software
    • G06F11/362—Debugging of software
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00—Error detection; Error correction; Monitoring
    • G06F11/30—Monitoring
    • G06F11/3003—Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302—Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00—Error detection; Error correction; Monitoring
    • G06F11/30—Monitoring
    • G06F11/3055—Monitoring arrangements for monitoring the status of the computing system or of the computing system component, e.g. monitoring if the computing system is on, off, available, not available
    • G—PHYSICS
    • G06—COMPUTING OR CALCULATING; COUNTING
    • G06F—ELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00—Error detection; Error correction; Monitoring
    • G06F11/30—Monitoring
    • G06F11/32—Monitoring with visual or acoustical indication of the functioning of the machine
    • G06F11/324—Display of status information
    • Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

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

Abstract

本发明实施例涉及计算机技术领域,公开了内核调试方法及装置,该方法包括:获取linux系统中各内核模块的依赖关系;基于依赖关系确定各内核模块的调试加载顺序;基于调试加载顺序,在目标调试环境中依次加载各内核模块;监测内核模块的加载状态,并记录异常信息;根据异常信息调整调试加载顺序,以使各内核模块基于调整后的调试加载顺序在目标调试环境进行内核调试。应用本发明的技术方案,能够提高对linux系统中各内核模块的调试效率及效果。

The embodiment of the present invention relates to the field of computer technology, and discloses a kernel debugging method and device, the method comprising: obtaining the dependency relationship of each kernel module in a Linux system; determining the debugging loading order of each kernel module based on the dependency relationship; loading each kernel module in sequence in a target debugging environment based on the debugging loading order; monitoring the loading state of the kernel module and recording abnormal information; adjusting the debugging loading order according to the abnormal information, so that each kernel module performs kernel debugging in the target debugging environment based on the adjusted debugging loading order. The technical solution of the present invention can improve the debugging efficiency and effect of each kernel module in the Linux system.

Description

Kernel debugging method and device
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a kernel debugging method and device.
Background
Linux is a widely used open source operating system, and kernel debugging of the Linux is crucial to stability and performance optimization of the system. However, the complexity of the Linux kernel makes debugging work quite challenging. In the related art, a customized Linux kernel debugging tool is generally adopted for debugging the Linux kernel, but in a debugging environment, the system is suspended or cannot normally run due to improper loading sequence of kernel modules, so that the debugging efficiency and effect are affected.
Disclosure of Invention
In view of the above problems, the embodiment of the invention provides a kernel debugging method and device.
According to one aspect of the embodiment of the invention, a kernel debugging method is provided and applied to a linux system, and the method comprises the steps of obtaining the dependency relationship of kernel modules in the linux system, determining the debugging loading sequence of the kernel modules based on the dependency relationship, loading the kernel modules in a target debugging environment based on the debugging loading sequence, monitoring the loading state of the kernel modules and recording abnormal information, and adjusting the debugging loading sequence according to the abnormal information so that the kernel modules can carry out kernel debugging in the target debugging environment based on the adjusted debugging loading sequence. Through the process, the debugging efficiency and the debugging effect on each kernel module in the linux system can be improved.
In an alternative embodiment, obtaining the dependency relationship of each kernel module in the linux system includes:
acquiring configuration files of the kernel modules, and obtaining the module names of the kernel modules based on the configuration files;
Reading corresponding metadata based on the module name;
Analyzing the dependent fields in the metadata to obtain the names of the dependent modules;
based on the names of the dependent modules, the dependent relation of each kernel module in the linux system is obtained.
In an alternative embodiment, obtaining the module name of each kernel module based on the configuration file includes:
Reading definition blocks of each kernel module in the configuration file;
The module name of the kernel module is extracted based on the name tag in the defined block.
In an alternative embodiment, the module name of each kernel module is obtained based on the configuration file, and the method further includes:
Acquiring repeated names in the module names, and marking the kernel modules with repeated names as conflict modules;
And counting conflict positions and quantity of the conflict modules, and generating corresponding error reports and configuration inspection reminding information based on the conflict positions and quantity so as to remind a user to inspect the configuration files based on the error reports.
In an alternative embodiment, obtaining duplicate names in the module names and marking the kernel module with duplicate names as a conflict module includes:
Constructing a name set based on the module name;
Recording the occurrence times of the names of all the modules in the name set through a hash table;
If the occurrence number of any module name is greater than 1, marking the kernel module corresponding to the module name as a conflict module.
In an alternative embodiment, counting the conflict positions and numbers of the conflict modules, and generating corresponding error reports and configuration checking reminding information based on the conflict positions and numbers to remind a user to check the configuration file based on the error reports, including:
summarizing the names and the occurrence positions of the conflict modules into a conflict list;
Generating corresponding error content based on the conflict list;
Acquiring the character number of the error content;
If the number of characters is greater than the character threshold, generating an error abstract based on error content;
And generating a corresponding error report and configuration checking reminding information based on the error abstract so as to remind a user to check the configuration file based on the error report file.
In an alternative embodiment, determining the debug loading order of each kernel module based on the dependency includes:
Constructing a dependency graph based on the dependency relationship;
Sequencing the dependency graphs through a topological sequencing algorithm to obtain a dependency sequencing result;
And determining the debugging loading sequence of each kernel module based on the dependency sequencing result.
In an alternative embodiment, building a dependency graph based on dependencies includes:
Creating a directed acyclic graph;
adding a dependent node in the directed acyclic graph based on the module name of each kernel module;
adding directed edges between the dependent nodes based on the dependent relationships;
A dependency graph is constructed based on the dependency nodes and directed edges.
In an alternative embodiment, the dependency graph is constructed based on the dependency relationship, and further includes:
if the number of the directed edges is larger than the square root of the node quantity of the dependent nodes, verifying the dependent relationship again based on the target verification strategy;
Based on the verified dependency relationship, adjusting the dependency node and the directed edge to obtain an adjusted dependency node and an adjusted directed edge;
And constructing a dependency graph based on the adjustment of the dependency nodes and the adjustment of the directed edges.
According to another aspect of the embodiment of the invention, a kernel debugging device is provided, which is applied to a linux system and comprises a relation acquisition module, a sequence determination module, a kernel loading module, an exception recording module and a kernel debugging module, wherein the relation acquisition module is used for acquiring the dependency relation of each kernel module in the linux system, the sequence determination module is used for determining the debugging loading sequence of each kernel module based on the dependency relation, the kernel loading module is used for sequentially loading each kernel module in a target debugging environment based on the debugging loading sequence, the exception recording module is used for monitoring the loading state of each kernel module and recording exception information, and the kernel debugging module is used for adjusting the debugging loading sequence according to the exception information so that each kernel module can carry out kernel debugging in the target debugging environment based on the adjusted debugging loading sequence. Through the modules, the debugging efficiency and the debugging effect of each kernel module in the linux system can be improved.
According to another aspect of the embodiment of the invention, there is provided a computer device including a processor, a memory, a communication interface and a communication bus, the processor, the memory and the communication interface completing communication with each other through the communication bus, the memory storing at least one executable instruction, the executable instruction causing the processor to perform the operations of the aforementioned method for debugging a kernel.
According to yet another aspect of an embodiment of the present invention, there is provided a computer-readable storage medium having stored therein at least one executable instruction for causing a computer device/apparatus to perform the operations of the foregoing kernel debugging method.
According to yet another aspect of the embodiments of the present invention, there is provided a computer program product comprising computer instructions for causing a computer to perform the operations of the kernel debugging method of the first aspect or any corresponding implementation manner thereof.
The foregoing description is only an overview of the technical solutions of the embodiments of the present invention, and may be implemented according to the content of the specification, so that the technical means of the embodiments of the present invention can be more clearly understood, and the following specific embodiments of the present invention are given for clarity and understanding.
Drawings
The drawings are only for purposes of illustrating embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to designate like parts throughout the figures. In the drawings:
FIG. 1 shows a flow diagram of a kernel debugging method provided by the invention;
FIG. 2 is a schematic diagram illustrating another process of a kernel debugging method according to the present invention;
FIG. 3 is a schematic flow chart of a kernel debugging method according to the present invention;
Fig. 4 shows a schematic structural diagram of a kernel debugging device provided by the invention;
fig. 5 shows a schematic structural diagram of a computer device provided by the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
Fig. 1 shows a flowchart of a first embodiment of a kernel debugging method of the present invention, which is applied to a linux system. As shown in fig. 1, the method comprises the steps of:
And 110, acquiring the dependency relationship of each kernel module in the linux system.
Specifically, the dependency relationship of each kernel module in the linux system is realized by performing static analysis on kernel source codes of the linux system. Specifically, firstly analyzing kernel source codes of a linux system, extracting dependency relationship information among kernel modules, and constructing a corresponding dependency relationship graph. Then, when target software is developed, according to the function to be developed and the corresponding target main thread, the kernel module related to the target main thread is found in the dependency graph, and the kernel module to be debugged and the dependency relationship thereof are further determined, so that the dependency relationship of each kernel module in the linux system is accurately obtained, and powerful support is provided for subsequent kernel debugging work.
Further, when the kernel source code of the linux system is analyzed, an existing source code analysis tool or an analysis script can be written by itself, and deep analysis can be performed on header files, source files, calling relations among modules and the like in the kernel source code, so that accuracy and completeness of the extracted dependency relation information are ensured. Meanwhile, in order to intuitively show the dependency relationship among the kernel modules, the constructed dependency relationship graph can adopt various expression forms such as a tree graph, a mesh graph and the like, so that the understanding and analysis of developers are facilitated.
Step 120, determining the debugging loading sequence of each kernel module based on the dependency relationship.
Specifically, when determining the debugging loading sequence of each kernel module based on the dependency relationship, the dependency level and the calling relationship between the kernel modules need to be comprehensively considered. First, for independent kernel modules without dependency, debug loading can be directly performed. Secondly, for the kernel modules with the dependency relationship, debugging and loading are needed to be sequentially carried out according to the order from low to high of the dependency level, so that all the kernel modules on which the dependency relationship exists are ensured to be loaded and initialized correctly before a certain kernel module is loaded. In addition, according to the cyclic dependency condition among kernel modules, the problem of loading failure caused by cyclic dependency is avoided by adjusting the module design or loading strategy. Through reasonable debugging loading sequence, correct operation and mutual cooperation of each kernel module in target software can be ensured.
In an alternative embodiment, the kernel modules may also be ordered based on a preset kernel module loading rule. I.e. before the kernel starts, the loading priority of each module is determined according to certain logic and rules. These rules may be formulated based on various factors such as dependencies, initialization time, or security. By the pre-ordering, the critical modules can be ensured to be loaded preferentially, and the possibility of loading conflict and failure is reduced. For example, assuming that one kernel module depends on another base module, the loading priority of the base module will be higher in the preset rule, ensuring that the dependency is satisfied.
In addition, the stability and performance of the system also need to be considered in the formulation of the loading rules of the kernel module. For some modules with larger influence on the stability of the system, the modules can be set to have higher loading priority so as to ensure that the system can quickly enter a stable state. Meanwhile, for the modules with longer initialization time or larger resource occupation, the loading time of the modules can be reasonably arranged, and the system resource shortage or response delay caused by starting is avoided. In terms of security, modules that involve security verification or protection functions may be set to high priority loading to effectively resist external attacks or intrusion by malware. By comprehensively considering various factors, a scientific and reasonable kernel module loading rule is formulated, and the overall performance and safety of the system can be further improved.
Step 130, loading each kernel module in the target debugging environment in turn based on the debugging loading sequence.
Specifically, based on the debugging loading sequence, in the process of loading each kernel module in sequence in the target debugging environment, the loading state of each kernel module can be monitored in real time, so that each kernel module can be loaded and operated correctly. Meanwhile, related information in the loading process, such as loading time, loading results and the like, can be recorded so as to facilitate subsequent analysis and optimization. If any problem is encountered in the loading process, such as unsatisfied module dependency, loading failure and the like, the loading process is immediately stopped, and a corresponding error prompt is given so that a developer can locate and solve the problem in time. In addition, a developer adjusts the loading sequence and loading parameters according to actual requirements so as to meet the debugging requirements in different scenes, thereby ensuring that the kernel module is correctly loaded in a target debugging environment according to a preset sequence and laying a solid foundation for subsequent system debugging and testing work.
In an alternative embodiment, after the kernel module ordering is completed, when the ordering result is applied to the actual loading process, the kernel scheduler may manage to ensure that each module is loaded in a given order. In this process, the target debug environment provides the necessary supporting tools, such as logging, breakpoint debugging, etc., helping the developer to better observe and control the loading behavior of the kernel module. For example, a development team builds a target debug environment on a virtual machine, uses KVM (kernel-based virtual machine) and QEMU (quick emulation), and performs the loading process of kernel modules in the target debug environment, thereby facilitating the observation and debugging of each detail of kernel launch.
And 140, monitoring the loading state of the kernel module and recording abnormal information.
As described above, by continuously monitoring the loading state of the kernel module loading process, it is possible to immediately capture and record relevant information when a problem occurs. Therefore, the method is not only helpful for timely finding problems, but also can provide important data support for subsequent problem analysis.
In an alternative embodiment, the exception information may include a kernel module name, an error code, an occurrence time, a context, etc. of the failed load. For example, the results of each load of the kernel module are recorded by the kernel log system dmesg and error messages in the log are checked periodically by the klogd process to ensure that any anomalies are quickly found and handled.
In addition, in order to improve the stability of the system, when a loading failure of a certain kernel module is detected, the module can be further tried to be reloaded, or other appropriate recovery measures can be taken according to error codes and context. For example, if the loading fails because the dependency relationship is not satisfied, an attempt may be made to load the missing dependent module before reloading the target module, so that the impact on the entire system due to the kernel module loading failure may be minimized.
And step 150, adjusting the debugging loading sequence according to the abnormal information so that each kernel module can perform kernel debugging in the target debugging environment based on the adjusted debugging loading sequence.
Specifically, when the debug loading order is adjusted, the exception information may be analyzed to determine which kernel modules may have their loading order conflicting or failing, and the loading order may be adjusted accordingly. For example, if a kernel module depends on services or resources provided by other modules, the system will ensure that these dependent modules are loaded before the target module. If the exception information indicates that a certain kernel module fails to load because of a dependency problem, the adjusted debug load order may preferentially load other modules on which the module depends to ensure that the dependency is satisfied. In addition, if a module still fails after multiple attempts to load, the system may mark it as "non-loadable" and skip the module during subsequent debugging to avoid unnecessary waiting and errors.
By the method, loading failure caused by improper loading sequence can be effectively avoided, and therefore kernel debugging efficiency and success rate are improved. Meanwhile, references and bases can be provided for subsequent kernel development and debugging by recording the loading sequence and the debugging result after each adjustment.
In an alternative embodiment, when abnormal loading of the kernel module is detected, an adjustment mechanism can be triggered, namely, the dependency relationship and other influencing factors of the module are reevaluated, and further, the loading sequence is optimized and adjusted, so that the problem is solved under the condition that the whole system is not stopped, and the stability and the robustness of the system are improved. For example, assuming that suspension occurs when a certain network driving module is loaded, analysis finds that the module has the problem of initializing resource contention, at this time, the loading sequence of the module can be postponed backwards by adjusting a configuration file or using a special debugging tool, so that other key modules which do not involve resource contention are loaded first, and normal operation of the system is restored. Thus, not only the current suspension problem can be solved, but also similar situations which may occur in the future can be prevented.
According to the kernel debugging method, various problems possibly occurring in the loading process of the kernel module are effectively solved through reasonable sequencing, gradual loading, real-time monitoring and dynamic adjustment, and particularly, the problem of system suspension caused by improper loading sequence is solved, so that the efficiency and the success rate of kernel debugging are greatly improved.
FIG. 2 shows a flow chart of another embodiment of the kernel debugging method of the present invention, applied to a linux system. As shown in fig. 2, the method comprises the steps of:
step 210, obtaining the dependency relationship of each kernel module in the linux system.
Specifically, the step 210 includes:
step 2101, obtaining a configuration file of the kernel module, and obtaining a module name of each kernel module based on the configuration file.
In an alternative embodiment, when the module name of each kernel module is obtained based on the configuration file, the definition block of each kernel module in the configuration file can be read, and the module name of the kernel module is extracted based on the name label in the definition block. That is, the module name of each kernel module is extracted by reading the kernel module information from the configuration file of the kernel module, so as to determine the specific kernel module to be processed subsequently.
Specifically, each module definition block in the configuration file can be separated by reading the configuration file row by row or segment by segment. Module names are extracted based on name tags in the definition blocks. This process looks up and extracts key fields representing the module name from the read module definition block. The field is commonly referred to as a name tag. For example, in a configuration file, if there is an entry such as alias sound-slot-0snd-card-0, this step needs to be able to identify that the name tag here is snd-card-0.
In an alternative implementation manner, duplicate names in the module names can be obtained, the kernel module with duplicate names is marked as a conflict module, conflict positions and number of the conflict modules are counted, and corresponding error reports and configuration checking reminding information are generated based on the conflict positions and number so as to remind a user to check the configuration file based on the error reports.
Specifically, after the module names of all the kernel modules are extracted, they need to be compared to check whether a plurality of modules are given the same name. In case the same name is found, these modules are regarded as conflicting modules and are specifically marked. If two or more defined entries use the same name tag, then these entries are identified as conflicting.
If the number of conflict modules C is greater than 0, the conflict modules are recorded and the user is prompted to check the configuration file. Here C refers to the total number of all conflict modules that have been detected. The range of values of the total number of conflict modules is theoretically greater than or equal to zero, but the most ideal state is that no conflict occurs (c=0). The rule setting has the significance that whether potential problems exist in the configuration file is judged by detecting whether C >0 exists or not, and a user is timely reminded to pay attention to the potential problems so as to ensure the stability and predictability of the system. When C >0 is found, the program can record all conflict module information in the log, and can give out clear warning information to guide the user to carry out examination and correction on the corresponding configuration item, so that loading failure or other unknown behaviors caused by configuration errors can be avoided.
In an alternative embodiment, when the repeated names in the module names are obtained and the kernel module with repeated names is marked as the conflict module, a name set can be constructed based on the module names, the occurrence times of the module names in the name set are recorded through a hash table, and if the occurrence times of any one of the module names are greater than 1, the kernel module corresponding to the module name is marked as the conflict module.
Specifically, firstly traversing all the extracted module names to construct a name set, aiming at acquiring all the module names from each kernel module of the system, ensuring no omission, and putting the module names into one set to obtain the name set. The purpose of the name set is to facilitate subsequent processing and lookup operations. For example, the module names extracted from the Linux kernel may include module a, module B, and module C, and put them into a set { module a, module B, and module C }.
Then, when the hash table is used to record the number of times each name appears, the hash table is an efficient storage and query data structure, and can quickly count the number of times each module name (name) appears in the collection. In particular implementations, each name and its number of occurrences may be stored in a hash table while traversing the module name set. For example, if the set of module names is { module A, module B, module A, module C }, the hash table records result as { module A:2, module B:1, module C:1}. If a certain name occurs more than 1, it is marked as a conflict module. The parameter F here represents the number of occurrences of the module name recorded in the hash table, and its value range is a non-negative integer. When F >1, it means that the module name appears at least twice, and should be marked as a conflicting module. For example, in the hash table { module A:2, module B:1, module C:1} in the previous step, the number of occurrences of module A is 2, and thus is marked as a collision module.
Then, a list of all conflicting modules is output and an error report is generated, aiming to collect all module names marked as conflicting, form a list and generate a detailed error report for the developer to further deal with these problems. Assuming that module a is the conflict module, the final output list of conflict modules is module a, and a corresponding error report is generated detailing which module names have duplicate problems, helping the developer locate and resolve the problem quickly.
In summary, in the whole process, the uniqueness of the module name in the system is ensured by traversing the module name set, recording the occurrence times by using the hash table, marking the conflict module and generating an error report, and the stability and the reliability of the system are improved. F >1 is based on the assumption that the module name should normally be unique, and if the same name appears multiple times, this means that there is a potential conflict, which requires special attention and handling.
In an alternative implementation, when counting conflict positions and numbers of conflict modules and generating corresponding error reports and configuration check reminding information based on the conflict positions and numbers so as to remind a user to check configuration files based on the error reports, names and occurrence positions of the conflict modules can be summarized into a conflict list, corresponding error contents are generated based on the conflict list, the character number of the error contents is acquired, if the character number is larger than a character threshold value, an error abstract is generated based on the error contents, and corresponding error reports and configuration check reminding information are generated based on the error abstract so as to remind the user to check the configuration files based on the error report files.
Specifically, when the conflicting module names and the occurrence positions are assembled into a list, the system traverses all the modules in the current running environment, the compatibility among the modules is checked, and once the compatibility problem among one or more modules is found, the names of the modules and the positions of the modules in a memory or a file system are recorded, so that a detailed data base is provided for subsequent processing. When generating detailed error reports based on the list, a text containing details of conflicting modules, including but not limited to module version, conflict cause, and possible solutions, may be created using the data generated in the previous step. This can help system administrators or developers quickly locate the root cause of the problem and take action to fix the problem.
And then, the generated error report is saved to a position predefined by a user or a configuration file, such as a file under a specific directory, so that related personnel can review at any time. And the data storage is ensured to be safe and reliable, and meanwhile, the later problem tracking and history comparison are also convenient. If the report length L exceeds the set maximum length M, then the first M characters are truncated and the ellipsis added. L represents the total character number of the actually generated error report, M is a preset maximum allowable length value, the average recommended value is set between 2000 and 5000 characters, and the specific optimal value can be flexibly adjusted according to the actual application requirements. The purpose of this operation is to prevent the error report file from becoming too large, resulting in memory space being strained or difficult to transfer, while ensuring that the critical contents of the report are preserved.
For example, assume that when a kernel of a Linux system is debugged, it is detected that two network driver modules cannot be loaded simultaneously due to different implementation details. From this list, the system generates detailed error reports explaining why two drivers cannot coexist and makes a suggestion to reconfigure or uninstall one of the modules. The report is ultimately saved to the system/var/log directory, and the file size is controlled to not more than 3000 characters in view of security and access efficiency. Furthermore, L may reach or even exceed 3000, and if M is set to 3000, the excess will be indicated by an ellipsis, ensuring that the file does not exceed a defined maximum size. This arrangement effectively balances the requirements of information integrity and resource management.
Step 2102, corresponding metadata is read based on the module name.
The metadata generally includes various attributes and information of the modules. The dependency fields in the metadata are analyzed and the dependency module names are recorded. This means that dependency information of a specified module is extracted from the metadata file. Information of each dependent module is recursively parsed according to recorded dependent module names until all dependent modules are parsed. Where D represents the number of directly dependent modules of the current module at each parsing. Usually, the initial value of D is the number directly depended on by the module, and when the recursion analysis is completed, D should be 0, which indicates that there are no more dependences to analyze.
Through the steps, the information of the kernel module and all the dependency relations of the kernel module can be comprehensively and in detail, and the problem can be accurately positioned and the performance can be optimized in the process of debugging and maintaining the kernel.
And 2103, analyzing the dependent fields in the metadata to obtain the name of the dependent module.
And 2104, acquiring the dependency relationship of each kernel module in the linux system based on the name of the dependency module.
Step 220, determining the debugging loading sequence of each kernel module based on the dependency relationship.
Please refer to step 120 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step 230, loading each kernel module in the target debug environment in turn based on the debug loading order.
Please refer to step 130 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step 240, monitoring the loading state of the kernel module and recording the exception information.
Please refer to step 140 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step 250, adjusting the debugging loading sequence according to the abnormal information, so that each kernel module performs kernel debugging in the target debugging environment based on the adjusted debugging loading sequence.
Please refer to step 150 in the embodiment shown in fig. 1 in detail, which is not described herein.
In summary, the kernel debugging method of the embodiment of the invention obtains the dependency relationship of each kernel module in the linux system, determines the debugging loading sequence of each kernel module based on the dependency relationship, sequentially loads each kernel module in a target debugging environment based on the debugging loading sequence, monitors the loading state of the kernel module and records abnormal information, and adjusts the debugging loading sequence according to the abnormal information so that each kernel module can carry out kernel debugging in the target debugging environment based on the adjusted debugging loading sequence, thereby improving the debugging efficiency and effect of each kernel module in the linux system.
FIG. 3 shows a flow chart of another embodiment of the kernel debugging method of the present invention, applied to a linux system. As shown in fig. 3, the method comprises the steps of:
step 310, obtaining the dependency relationship of each kernel module in the linux system.
Please refer to step 210 in the embodiment shown in fig. 2 in detail, which is not described herein.
Step 320, determining the debug loading sequence of each kernel module based on the dependency.
Specifically, the step 320 includes:
step 3201, building a dependency graph based on the dependencies.
Step 3202, the dependency graph is ordered by a topology ordering algorithm, and a dependency ordering result is obtained.
Step 3203, determining the debug loading sequence of each kernel module based on the dependency ranking result.
In an alternative embodiment, when the kernel modules are ordered based on a preset kernel module loading rule, first, dependency information of the kernel modules is obtained. This means that by analyzing the configuration file or other metadata of the kernel module, the other modules that each module needs to depend on are determined. Such information is typically contained in a configuration file of the module or in a dependency list generated during compilation. For example, by reading a file, the dependency relationship between the modules may be obtained. Then, a dependency graph is constructed according to the dependency information, so that the obtained dependency information is converted into a graph representation, namely, each module is a node in the graph, and the dependency between the modules is represented as an edge. For example, if module A depends on module B, then A through B will have a directed edge in the dependency graph. This graph structure enables the subsequent ordering algorithm to be performed efficiently. The dependency graph is then ranked using a topological ranking algorithm. The topology ordering algorithm is applicable to a directed acyclic graph DAG, which can arrange nodes in a certain order such that all the preceding nodes of each node are arranged in front of it. In particular, common topology ordering algorithms such as Kahn's algorithm or depth-first search DFS may be applied to the present scenario. For example, in one embodiment, the dependency graph may be processed using the Kahn algorithm to obtain an ordered list of modules that conform to the dependency relationship. And finally, adjusting the loading sequence of the kernel module according to the sequencing result to ensure the correct dependency relationship of the loading module. The last step is to rearrange the loading order of the kernel modules according to the sorting result after the topology sorting is completed. By the aid of the method, all modules can be loaded in sequence according to the correct dependency relationship, and the problem caused by improper loading sequence is avoided. For example, assuming that the topological ordered module loading sequence is B- > C- > a, during actual loading, the module B will be loaded first, then the module C and finally the module a, so that all the dependency relationships can be guaranteed to be processed correctly.
It can be understood that the steps can not only effectively manage the loading sequence of the kernel module and optimize the kernel debugging process, but also help to improve the stability and reliability of the system, thereby simplifying the workload of development and maintenance personnel.
In an alternative implementation, when the dependency graph is built based on the dependency relationship, the directed acyclic graph can be built first, the dependency nodes are added in the directed acyclic graph based on the module names of the kernel modules, the directed edges are added between the dependency nodes based on the dependency relationship, and the dependency graph is built based on the dependency nodes and the directed edges.
In an alternative implementation mode, when the dependency graph is built based on the dependency relationship, if the number of the directed edges is larger than the square root of the node quantity of the dependency node, verifying the dependency relationship again based on the target verification policy, adjusting the dependency node and the directed edge based on the verified dependency relationship to obtain an adjusted dependency node and an adjusted directed edge, and building the dependency graph based on the adjusted dependency node and the adjusted directed edge.
In creating a Directed Acyclic Graph (DAG), a data structure is first created that represents a series of nodes and relationships between them, which are unidirectional and do not have any circular paths. In this data structure, nodes represent specific kernel modules or functions, while directed edges represent dependencies from one module to another. For example, when debugging a Linux kernel, an empty DAG may be created to record how modules call or rely on each other.
When nodes are added in the graph based on the dependency information, the corresponding modules or functions can be added as nodes in the DAG according to the actual dependency conditions of the kernel modules or functions. Specifically, assuming that the core portion being analyzed contains four critical modules, this step is to add these four modules as independent nodes to the empty DAG in order to subsequently establish the connection relationship between them.
When the directed edges are added between the nodes according to the dependency relationship, the corresponding nodes in the directed edge connection graph can be used according to the actual dependency condition. The direction of the directed edge indicates the direction of invocation or dependency. For example, in dealing with network stack problems, if a TCP module is found to need to rely on an IP module to operate, a directed edge should be drawn in the direction that the TCP module node points to the IP module node, indicating the existence of such a dependency.
Further, if the number of directed edges E is greater than the square root of the number of nodes N, then additional dependency verification is performed to ensure the correctness of the graph, where E represents the number of directed edges and N represents the number of nodes. The formula sqrt { N } < E here mainly acts to initiate additional dependency verification mechanisms to ensure that the quality of the final debug results is not affected by false positives when the graph becomes more complex (the connections between nodes are abnormally many). In this inequality, N can increase from 1 to thousands or more, while E needs to be a non-negative integer. The optimal setting under this condition is that there is no absolute standard, as it depends on the specific system size and complexity, but the overall goal is to reduce the possible misconfigurations. When this condition is met, meaning that there are too many complex connections or potential circular dependencies in the system, it is necessary to further check the validity and necessity of the dependency, avoiding debugging difficulties or system performance degradation due to logic errors. For example, when the number of directed edges in a large Linux kernel system is detected to be far more than an expected value, some redundant or abnormal dependence items are successfully found by triggering an additional verification process, so that the whole kernel structure is simplified, and the debugging efficiency and stability are improved.
In order to ensure the accuracy of the constructed dependency graph, additional dependency verification is needed to check whether potential errors or missing dependency exists in the graph, and whether each node and connection thereof in the graph are accurate or not can be verified by comparing dependency descriptions in kernel source codes or documents. If any inconsistency is found, the previous steps need to be returned to correct until it is ensured that all dependencies are correctly represented in the graph. The verification process not only improves the accuracy of the dependency graph, but also provides a more reliable basis for subsequent debugging work.
In the verification process, various technical means such as static code analysis, dynamic test and the like can be adopted to comprehensively check the correctness of the dependency relationship. Static code analysis can automatically identify and extract the dependency relationship between modules by scanning kernel source codes, and then compare the dependency relationship with a dependency graph. The dynamic test is to observe whether the actually occurring dependency is consistent with the graph through the process of loading and unloading the monitoring module when the system is running. The combined use of these verification means can greatly improve the accuracy and reliability of dependency graph construction. Meanwhile, in order to ensure the effectiveness and high efficiency of the verification process, we also need to continuously optimize and adjust the verification policy to adapt to kernel systems with different scales and complexity.
In addition, to ensure that the construction of the dependency graph is both efficient and accurate, a staged verification strategy is employed in the construction process. In the initial stage, namely the collection stage of the dependency information, basic data integrity and consistency check is carried out, so that the error or contradictory information is prevented from being introduced into the subsequent graph construction step. With the gradual construction of the dependency graph, each node or edge is added, local verification logic is triggered immediately, so that newly added elements cannot destroy the whole structure of the graph, such as checking whether loops are formed or whether defined dependency rules are violated.
After the dependency graph is completely constructed, in addition to the additional verification based on the ratio of the number of directed edges to the number of nodes, a full graph traversal check is performed to finally confirm the correctness of the graph. This step not only includes verification of node and edge presence, connectivity, but also can check the semantic correctness of the dependency relationships in depth, such as ensuring no loop dependencies, no missing dependencies, etc. Through the multi-level verification measures, the accuracy and the reliability of the dependency graph can be guaranteed to the greatest extent, and a solid foundation is provided for subsequent kernel debugging work.
In an alternative embodiment, the graph structure may be initialized first when creating a Directed Acyclic Graph (DAG), all dependencies are traversed, each module is taken as a node of the graph, the nodes with the dependencies are connected using edges, and if there are cyclic dependencies, i.e., loop R is formed between the nodes, the loop nodes are recorded and anomalies are thrown, where R represents the loop nodes.
Initializing a graph structure refers to creating an initial graph object to prepare the data structure for subsequent operations. This graph object contains an empty set of nodes and an empty set of edges for gradual filling in subsequent steps. This step ensures a clear and orderly underlying environment, enabling the graph to be efficiently constructed and managed.
Traversing all the dependency relationships, and taking each module as a node of the graph. This process entails traversing all modules in the system, identifying a unique identity for each module, and adding it to the graph structure as a node in the graph. The modules herein may be components, functional modules, or kernel modules of the system, etc. The key of this step is to accurately extract and record the information of each module, ensuring the integrity of the graph.
The nodes with dependencies are connected using edges. In this process, edges are added between nodes with direct or indirect dependencies according to the dependencies between modules traversed previously. For example, assuming that module A depends on module B, and module B depends on module C, the corresponding edges A→B and B→C would be added between the three modules. The expression of such dependencies ensures that the graph can correctly represent the dependency structure in the system.
If there is a loop dependency, i.e., a loop R is formed between nodes, the loop nodes are recorded and the exception is thrown. The key here is to detect if a loop is present in the graph. The presence of a loop can cause the system to fail because it can be infinitely circular, ultimately leading to resource exhaustion or deadlock. Loops may be detected by a topology ordering algorithm or other graph traversal method. If a loop is found, all nodes in the loop are recorded and an exception is thrown to interrupt further graph construction operations. This step ensures that the created graph is loop-free, conforming to the definition of a directed loop-free graph (DAG).
In one embodiment, a system for debugging a Linux kernel is assumed, which comprises a plurality of modules, each module having its own functions and dependencies. Then, edges are added according to the dependency between the modules.
For parameter R, it represents a set of nodes forming a loop, which is a set. Ranging from the simplest loop (e.g., a→b→a) containing at least two nodes to a complex loop consisting of multiple nodes. The optimal value is that no loop exists, namely R is an empty set, so that the normal construction and use of the graph can be ensured. The purpose of setting this parameter R is to be able to quickly and accurately identify and handle the loop dependency problem in the graph, ensuring that the resulting graph is an efficient Directed Acyclic Graph (DAG).
Next, when the initialization graph structure is acquired, an empty node set and edge set may be created first. This step ensures that there is no data pollution in the initial state, providing a clean starting point for empty nodes and edges. Node classes and edge classes are defined. Node classes and edge classes typically contain the necessary attributes and methods to enable the components of the graph to properly represent their functions. For example, in a system for debugging a Linux kernel, nodes may represent different kernel modules, while edges may represent call relationships or dependencies between modules. Next, the nodes and their attributes are managed using a hash table. By using hash tables, a large number of nodes can be efficiently searched and managed, ensuring fast access to node attributes and related information. In this embodiment, the attributes of the nodes may include a module name, a path, version information, and the like.
If the size S of the hash table is greater than the total number of modules T, optimization is performed to reduce the storage space, wherein S represents the size of the hash table and T represents the total number of modules. Where S is a natural number reflecting the number of entries in the hash table and T is also a natural number representing the number of modules in the system. When S > T, it is indicated that there is an excessive space in the hash table, which may result in resource waste. In this case, storage may be optimized by deleting unnecessary hash table entries or compressing the hash table. Specifically, after traversing all nodes, it can be checked whether there are redundant slots in the hash table and cleaned. In addition, the use of a dynamically sized hash table may also be considered, with the hash table being sized according to the actual situation, to optimize storage.
For example, assuming a Linux kernel debug system containing 10 modules, a hash table is initially created that can hold 100 entries. After initializing the graph structure and adding all nodes, only 10 actually used nodes are found, where s=100 and t=10, and a large number of empty entries are obvious. To reduce storage space, redundant hash table entries may be deleted or the hash table may be resized to a more appropriate size, such as to accommodate only 10 entries. Through such optimization, the performance and efficiency of the system can be effectively improved.
Next, in managing nodes and their attributes using hash tables, since hash tables are an efficient management tool, the data retrieval speed can be increased, especially in the case of handling a large number of nodes and their attributes. The method comprises the following specific steps:
First, all nodes are traversed and added to the hash table. This ensures that all nodes in the system can be managed and retrieved efficiently. For example, assume that there are multiple kernel module nodes in the system, each containing the name, version, and state information of a module. After traversing the nodes, they will be inserted one by one into the hash table.
Second, each node is assigned a unique identifier. This identifier is used to distinguish between different nodes, ensuring that each node has a unique corresponding location in the hash table. For example, in one particular embodiment, the unique identifier may be generated by combining the name and type of the node. Specifically, if the name of the node is netfilter, the type is module, and the unique identifier may be netfilter_module.
Further, attributes of the node, such as name, type, etc., are recorded. This step ensures that the information of each node is accurately recorded, facilitating subsequent queries and operations. For example, a node netfilter may have attributes, name netfilter, type module, state active.
Finally, if the conflict rate H in the hash table is larger than the preset threshold value Q, the hash table is reinitialized by adopting larger hash table capacity so as to improve the searching efficiency. Here, H represents a collision rate of the hash table, that is, a ratio of the number of collisions in the hash table due to the same hash address, Q represents a preset collision rate threshold, and the preset collision rate threshold is generally set between 0.1 and 0.3, and a specific optimal value depends on performance requirements of an actual application scenario. For example, assuming that the current hash table collision rate h=0.35 exceeds the preset threshold q=0.3, then the re-initialization will be triggered and the new hash table may be twice as large, e.g. increasing from 1024 to 2048. After the hash table is reinitialized, all nodes recalculate the hash value and insert the hash value into the new hash table, so that the conflict rate is reduced, and the performance and the stability of the system are improved.
Through the steps, the nodes and the attributes thereof can be efficiently managed and inquired when the Linux kernel is debugged, and the running efficiency and the reliability of the system are ensured.
Step 330, loading each kernel module in the target debug environment in turn based on the debug loading order.
Please refer to step 130 in the embodiment shown in fig. 1 in detail, which is not described herein.
Step 340, the loading state of the kernel module is monitored, and the exception information is recorded.
Please refer to step 140 in the embodiment shown in fig. 1 in detail, which is not described herein.
And step 350, adjusting the debugging loading sequence according to the abnormal information so that each kernel module can perform kernel debugging in the target debugging environment based on the adjusted debugging loading sequence.
Please refer to step 150 in the embodiment shown in fig. 1 in detail, which is not described herein.
The kernel debugging method comprises the steps of orderly arranging all kernel modules to be loaded through a preset kernel module loading rule, then loading the kernel modules one by one in a target debugging environment according to the ordered sequence, monitoring the loading condition of each kernel module in real time by a system in the process so as to capture any possible abnormal condition in time and record the abnormal condition in detail, and finally further optimizing and adjusting the loading sequence of the kernel modules according to the recorded abnormal information, so that the problems of system suspension and the like caused by improper loading sequence are avoided or solved.
The method aims at solving the problems of unstable system and even crash caused by improper loading sequence of kernel modules in a systematic and step-wise manner. Firstly, through reasonably planning the loading sequence of the kernel module, the modules with definite dependency relationships can be loaded according to the correct sequence, so that the failure probability caused by dependency deletion is reduced. Then, a real-time monitoring mechanism is introduced in the actual loading process, so that potential loading failure can be immediately found and recorded, and precious first-hand data can be provided for subsequent problem diagnosis. Most critical is based on these real-time recorded anomaly information. Meanwhile, the loading sequence is dynamically adjusted through a feedback mechanism, so that the debugging efficiency is improved, the phenomenon of system suspension can be obviously reduced, and the smoothness and high efficiency of the Linux kernel debugging process are ensured.
Fig. 4 shows a schematic structural diagram of an embodiment of a kernel debugging device of the present invention, which is applied to a linux system. As shown in fig. 4, the apparatus includes:
A relationship obtaining module 410, configured to obtain a dependency relationship of each kernel module in the linux system;
an order determining module 420, configured to determine a debug loading order of each kernel module based on the dependency relationship;
the kernel loading module 430 is configured to sequentially load each kernel module in the target debug environment based on the debug loading sequence;
the exception recording module 440 is configured to monitor a loading state of the kernel module and record exception information;
the kernel debugging module 450 is configured to adjust a debugging loading sequence according to the exception information, so that each kernel module performs kernel debugging in the target debugging environment based on the adjusted debugging loading sequence.
In an alternative embodiment, the relationship acquisition module 410 includes:
The configuration file acquisition sub-module is used for acquiring the configuration file of the kernel module and acquiring the module name of each kernel module based on the configuration file;
the metadata reading sub-module is used for reading corresponding metadata based on the module name;
The metadata analysis sub-module is used for analyzing the dependent fields in the metadata to obtain the names of the dependent modules;
And the dependency relationship acquisition sub-module is used for acquiring the dependency relationship of each kernel module in the linux system based on the name of the dependency module.
In an alternative embodiment, the relationship acquisition module 410 further includes:
The definition block reading sub-module is used for reading definition blocks of all kernel modules in the configuration file;
And the module name extraction sub-module is used for extracting the module name of the kernel module based on the name label in the definition block.
In an alternative embodiment, the relationship acquisition module 410 further includes:
The conflict module marking sub-module is used for acquiring repeated names in the module names and marking the kernel module with repeated names as a conflict module;
And the conflict information statistics sub-module is used for counting conflict positions and quantity of the conflict modules, and generating corresponding error reports and configuration checking reminding information based on the conflict positions and quantity so as to remind a user to check the configuration file based on the error reports.
In an optional implementation manner, the conflict module marks the sub-module, is specifically configured to construct a name set based on module names, records the occurrence times of each module name in the name set through a hash table, and marks the kernel module corresponding to the module name as the conflict module if the occurrence times of any module name is greater than 1.
In an optional implementation manner, the conflict information statistics sub-module is specifically configured to aggregate names and occurrence positions of the conflict modules into a conflict list, generate corresponding error content based on the conflict list, acquire the number of characters of the error content, generate an error abstract based on the error content if the number of characters is greater than a character threshold, and generate corresponding error report and configuration check reminding information based on the error abstract so as to remind a user to check a configuration file based on the error report file.
In an alternative embodiment, the order determination module 420 includes:
the dependency graph construction submodule is used for constructing a dependency graph based on the dependency relationship;
the dependency graph ordering sub-module is used for ordering the dependency graphs through a topological ordering algorithm to obtain a dependency ordering result;
and the loading sequence determining submodule is used for determining the debugging loading sequence of each kernel module based on the dependency sequencing result.
In an alternative implementation mode, the dependency graph construction submodule is specifically used for creating a directed acyclic graph, dependency nodes are added in the directed acyclic graph based on module names of all kernel modules, directed edges are added among the dependency nodes based on the dependency relationships, and the dependency graph is constructed based on the dependency nodes and the directed edges.
In an alternative implementation mode, the dependency graph construction submodule is specifically used for verifying the dependency relationship again based on the target verification policy if the number of the directed edges is larger than the square root of the node quantity of the dependency nodes, adjusting the dependency nodes and the directed edges based on the verified dependency relationship to obtain adjusted dependency nodes and adjusted directed edges, and constructing the dependency graph based on the adjusted dependency nodes and the adjusted directed edges.
Further functional descriptions of the above respective modules and units are the same as those of the above corresponding method embodiments, and are not repeated here.
Through the device and the components thereof, the technical scheme provided by the embodiment of the invention has the following advantages:
Referring to fig. 5, fig. 5 is a schematic structural diagram of a computer device according to an alternative embodiment of the present invention, and as shown in fig. 5, the computer device includes one or more processors 510, a memory 520, and interfaces for connecting components, including a high-speed interface and a low-speed interface. The various components are communicatively coupled to each other using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the computer device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In some alternative embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple computer devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 510 is illustrated in fig. 5.
Processor 510 may be a central processor, a network processor, or a combination thereof. Wherein the processor 510 may further comprise a hardware chip. The hardware chip may be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general-purpose array logic, or any combination thereof.
Wherein the memory 520 stores instructions executable by the at least one processor 510 to cause the at least one processor 510 to perform methods that implement the embodiments described above.
The memory 520 may include a storage program area that may store an operating system, an application program required for at least one function, and a storage data area that may store data created according to the use of the computer device of the presentation of a applet landing page, etc. In addition, memory 520 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, memory 520 may optionally include memory located remotely from processor 510, which may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the internet, intranets, server clusters, mobile communication networks, and combinations thereof.
Memory 520 may include volatile memory, such as random access memory, nonvolatile memory, such as flash memory, hard disk, or solid state disk, and memory 520 may also include combinations of the above.
The computer device also includes a communication interface 530 for the computer device to communicate with other devices or communication networks.
The embodiment of the invention also provides a computer readable storage medium, which stores at least one executable instruction, and the executable instruction enables the computer equipment/kernel debugging device to execute the kernel debugging method in any method embodiment when running on the computer equipment/kernel debugging device.
The embodiment of the invention also provides a computer program product, which comprises computer instructions for causing a computer to execute the kernel debugging method of the first aspect or any implementation manner corresponding to the first aspect.
The algorithms or displays presented herein are not inherently related to any particular computer, virtual system, or other apparatus. In addition, embodiments of the present invention are not directed to any particular programming language.
In the description provided herein, numerous specific details are set forth. It will be appreciated, however, that embodiments of the invention may be practiced without such specific details. Similarly, in the above description of exemplary embodiments of the invention, various features of embodiments of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. Wherein the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the apparatus of the embodiments may be adaptively changed and disposed in one or more apparatuses different from the embodiments. The modules or units or components of the embodiments may be combined into one module or unit or component and, furthermore, they may be divided into a plurality of sub-modules or sub-units or sub-components. Except that at least some of such features and/or processes or elements are mutually exclusive.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, third, etc. do not denote any order. These words may be interpreted as names. The steps in the above embodiments should not be construed as limiting the order of execution unless specifically stated.

Claims (10)

1. The kernel debugging method is characterized by being applied to a linux system, and comprises the following steps:
Acquiring the dependency relationship of each kernel module in the linux system;
determining the debugging loading sequence of each kernel module based on the dependency relationship;
Based on the debugging loading sequence, loading each kernel module in the target debugging environment in turn;
Monitoring the loading state of the kernel module and recording abnormal information;
And adjusting the debugging loading sequence according to the abnormal information so that each kernel module can perform kernel debugging in the target debugging environment based on the adjusted debugging loading sequence.
2. The method of claim 1, wherein the obtaining the dependency relationship of each kernel module in the linux system includes:
Acquiring configuration files of the kernel modules, and acquiring the module names of the kernel modules based on the configuration files;
Reading corresponding metadata based on the module name;
analyzing the dependent fields in the metadata to obtain the names of the dependent modules;
And acquiring the dependency relationship of each kernel module in the linux system based on the name of the dependency module.
3. The method of claim 2, wherein the obtaining a module name for each of the kernel modules based on the configuration file comprises:
Reading definition blocks of each kernel module in the configuration file;
And extracting the module name of the kernel module based on the name label in the definition block.
4. The method of claim 2, wherein the deriving a module name for each of the kernel modules based on the configuration file further comprises:
acquiring repeated names in the module names, and marking the kernel module with repeated names as a conflict module;
And counting conflict positions and quantity of the conflict modules, and generating corresponding error reports and configuration checking reminding information based on the conflict positions and quantity so as to remind a user to check the configuration file based on the error reports.
5. The method of claim 4, wherein the obtaining the duplicate name of the module name and marking the kernel module with duplicate names as a conflict module comprises:
constructing a name set based on the module name;
recording the occurrence times of the names of the modules in the name set through a hash table;
If the occurrence number of any module name is greater than 1, marking the kernel module corresponding to the module name as a conflict module.
6. The method of claim 4, wherein counting the number and location of conflicts for the conflict module and generating corresponding error reports and configuration check reminder information based on the number and location of conflicts to remind a user to check the configuration file based on the error reports comprises:
Summarizing the names and the occurrence positions of the conflict modules into a conflict list;
generating corresponding error content based on the conflict list;
Acquiring the character number of the error content;
If the number of characters is larger than a character threshold value, generating an error abstract based on the error content;
And generating a corresponding error report and configuration checking reminding information based on the error abstract so as to remind a user to check the configuration file based on the error report file.
7. The method of claim 2, wherein determining a debug load order for each of the kernel modules based on the dependencies comprises:
constructing a dependency graph based on the dependency relationship;
Sequencing the dependency graphs through a topological sequencing algorithm to obtain a dependency sequencing result;
And determining the debugging loading sequence of each kernel module based on the dependency sequencing result.
8. The method of claim 7, wherein the building a dependency graph based on the dependencies comprises:
Creating a directed acyclic graph;
adding a dependent node in the directed acyclic graph based on the module name of each kernel module;
adding directed edges between the dependent nodes based on the dependent relationships;
The dependency graph is constructed based on the dependency nodes and the directed edges.
9. The method of claim 8, wherein the building a dependency graph based on the dependencies further comprises:
If the number of the directed edges is larger than the square root of the node quantity of the dependent nodes, verifying the dependent relationship again based on a target verification strategy;
Based on the verified dependency relationship, adjusting the dependency node and the directed edge to obtain an adjustment dependency node and an adjustment directed edge;
And constructing the dependency graph based on the adjustment dependent nodes and the adjustment directed edges.
10. A kernel debugging device, applied to a linux system, the device comprising:
the relation acquisition module is used for acquiring the dependency relation of each kernel module in the linux system;
The order determining module is used for determining the debugging loading order of each kernel module based on the dependency relationship;
the kernel loading module is used for loading each kernel module in the target debugging environment in sequence based on the debugging loading sequence;
the exception recording module is used for monitoring the loading state of the kernel module and recording exception information;
The kernel debugging modules are used for adjusting the debugging loading sequence according to the abnormal information so that each kernel module can carry out kernel debugging in the target debugging environment based on the adjusted debugging loading sequence.
CN202510136247.4A 2025-02-07 2025-02-07 Kernel debugging method and device Pending CN120066944A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202510136247.4A CN120066944A (en) 2025-02-07 2025-02-07 Kernel debugging method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202510136247.4A CN120066944A (en) 2025-02-07 2025-02-07 Kernel debugging method and device

Publications (1)

Publication Number Publication Date
CN120066944A true CN120066944A (en) 2025-05-30

Family

ID=95787065

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202510136247.4A Pending CN120066944A (en) 2025-02-07 2025-02-07 Kernel debugging method and device

Country Status (1)

Country Link
CN (1) CN120066944A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN120386536A (en) * 2025-06-25 2025-07-29 浪潮电子信息产业股份有限公司 Kernel driver module uninstallation method, electronic device, program product, and medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN120386536A (en) * 2025-06-25 2025-07-29 浪潮电子信息产业股份有限公司 Kernel driver module uninstallation method, electronic device, program product, and medium

Similar Documents

Publication Publication Date Title
US10372594B2 (en) Method and device for retrieving test case based on code coverage
Padgham et al. Model-based test oracle generation for automated unit testing of agent systems
US8782609B2 (en) Test failure bucketing
Chen et al. Understanding exception-related bugs in large-scale cloud systems
US10255158B2 (en) Monitoring and diagnostics of business transaction failures
CN111045927A (en) Performance test evaluation method and device, computer equipment and readable storage medium
CN114579203B (en) Script file checking method and device, electronic equipment and storage medium
CN110633211A (en) Test method, device, server and medium for multi-interface
CN111694612A (en) Configuration checking method, device, computer system and storage medium
CN111124872A (en) Branch detection method and device based on difference code analysis and storage medium
CN111913878A (en) Program analysis result-based bytecode instrumentation method, device and storage medium
US8799716B2 (en) Heap dump occurrence detection
US7712087B2 (en) Methods and systems for identifying intermittent errors in a distributed code development environment
CN116401676A (en) Automatic detection method and device for data loopholes, electronic equipment and storage medium
CN121070314A (en) Test code repairing method and related equipment
CN112445706A (en) Program abnormal code acquisition method and device, electronic equipment and storage medium
US7913265B2 (en) Method of loading software with an intermediate object oriented language in a portable device
CN111884858B (en) Equipment asset information verification method, device, system and medium
CN112612773A (en) Database synchronization test method and device, computer equipment and storage medium
CN114722927B (en) Crash clustering method, device, electronic device and storage medium
CN119862167B (en) File operation tracking method and device, computer equipment and storage medium
CN114936111A (en) Front-end variable anomaly detection and restoration method, device, equipment and storage medium
US20220058260A1 (en) Binary image stack cookie protection
US20240248691A1 (en) Detecting software code anomalies based on organizational information
CN111736848A (en) Packet conflict positioning method and device, electronic equipment and readable storage medium

Legal Events

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