Sqlite database monitoring method, device and equipment in ARM environment and medium

By loading a hook library to parse ARM instructions and DLL calls in the ARM environment, real-time monitoring of the SQLite database is achieved, which solves the shortcomings of database status analysis in ARM applications and improves the stability and optimization capabilities of the application.

CN121434005APending Publication Date: 2026-01-30厦门天锐科技股份有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511504764.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-21
Publication Date
2026-01-30

Smart Images

  • Figure CN121434005A_ABST
    Figure CN121434005A_ABST
Patent Text Reader

Abstract

The invention provides a Sqlite database monitoring method and device in an ARM environment, equipment and a medium, and relates to the technical field of computers. The method comprises the following steps: loading a preset hook library when an application runs; analyzing an ARM instruction and a DLL loading function called by the application program by utilizing the hook library so as to judge whether the application program uses a Sqlite database or not; if the application program uses the Sqlite database and does not export the database interface, executing a fuzzy matching rule by utilizing the hook library to output database log information; and if the application program uses the Sqlite database and exports the database interface, directly carrying out hook operation on a database interface function by utilizing the hook library to obtain parameter information and execution state information of the database interface function, and outputting the parameter information and the execution state information to database log information. Compared with the prior art, the method has the advantages that the state of the Sqlite database is monitored in the ARM environment, and robustness and stability in the use process of the Sqlite database of the ARM application program can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computers, in particular to a Sqlite database monitoring method and device in an ARM environment, an electronic device and a storage medium. BACKGROUND

[0002] With the continuous popularity of ARM architecture environment, users and application scenarios using ARM systems are increasingly widespread. At present, a large number of ARM application programs need to use various databases to realize information storage. Among them, the Sqlite open source database is widely integrated in ARM application development due to its lightweight and efficient characteristics.

[0003] In the actual development and application process of the database, most ARM application programs can only realize the basic error information output function. In the process of using the database, performance analysis (such as SQL statement execution efficiency, resource occupation) and error exception troubleshooting (such as interface call failure, data read-write exception positioning) are key links to ensure stable operation of the application, and their importance is self-evident.

[0004] Although the popularity of ARM systems is constantly improving, and the awareness of ARM instruction sets is gradually increasing, the current database monitoring technology in the ARM environment is still relatively scarce. Especially under the background of the wide application of Sqlite databases, if users need to analyze and monitor the real-time state (such as connection state, data operation progress) of the Sqlite database inside the ARM application program during the development of the ARM program business, or need to call and analyze the database interface that is not open to the outside in the application program, they often lack effective technical means. This directly leads to the fact that users cannot accurately obtain key running data (such as interface parameters, SQL execution statements, return status, etc.) of the database, it is difficult to locate potential problems, and ultimately restricts the continuous optimization and stable development of the ARM application program. SUMMARY

[0005] The purpose of the present application is to provide a Sqlite database monitoring method and device in an ARM environment, which can monitor the state of the Sqlite database in the ARM environment.

[0006] In a first aspect, the embodiments of the present application provide a Sqlite database monitoring method in an ARM environment, comprising: loading a preset hook library when the application program is running, the hook library being capable of analyzing the ARM instruction set and finding the calling relationship of the application program to the dynamic link library (DLL); The hook library is used to analyze ARM instructions and DLL loading functions of the application program to determine whether the application program uses the Sqlite database. If the application program uses the Sqlite database and does not export a database interface, the hook library is used to execute a fuzzy matching rule to output log information; the fuzzy matching rule is specifically that whether a pointer parameter and a return value of a function called by the application program contain a Sqlite statement syntax feature is determined, and when the Sqlite statement syntax feature is detected, the pointer parameter and the return value of the corresponding function are output to database log information. If the application program uses the Sqlite database and has exported a database interface, the hook library is used to directly perform hook operation on the database interface function, obtain parameter information and execution state information of the database interface function, and output to database log information.

[0007] In some embodiments of the present application, the hook library is used to analyze ARM instructions and DLL loading functions of the application program to determine whether the application program uses the Sqlite database, including: If the application program calls a DLL loading function to load a DLL related to the Sqlite database, it is determined that the application program uses the Sqlite database. If the application program jumps to a function containing a Sqlite fixed string through a jump instruction, it is determined that the application program uses the Sqlite database.

[0008] In some embodiments of the present application, the hook library is loaded when the application program runs, including: When the application program runs, the preset hook library is injected into a memory space of the application program, so that the hook library and the application program share a memory address, to realize real-time monitoring of application program instructions and function calls.

[0009] In some embodiments of the present application, the method further includes: According to the database log information, a state of the Sqlite database is analyzed.

[0010] In a second aspect, an embodiment of the present application provides an ARM environment Sqlite database monitoring device, including: A loading module is configured to load a preset hook library when an application program runs, and the hook library can analyze an ARM instruction set and find a calling relationship of the application program to a dynamic link library (DLL). a judging module configured to parse the ARM instruction and the DLL loading function of the application program calling by using the hook library, to determine whether the application program uses the Sqlite database; a monitoring module configured to, if the application program uses the Sqlite database and does not export the database interface, output log information by using the hook library to execute a fuzzy matching rule; the fuzzy matching rule is specifically that, whether the pointer parameter and the return value of the function called by the application program contain the Sqlite statement syntax feature is determined, and when the Sqlite statement syntax feature is detected, the pointer parameter and the return value of the corresponding function are output to the database log information; if the application program uses the Sqlite database and has exported the database interface, the hook library is directly used to perform hook operation on the database interface function, to obtain the parameter information and the execution state information of the database interface function, and to output to the database log information.

[0011] In some embodiments of the present application, the judging module is specifically configured to: if the application program calls the DLL loading function to load the DLL related to the Sqlite database, it is determined that the application program uses the Sqlite database; if the application program calls the jump instruction to jump to the function containing the Sqlite fixed string, it is determined that the application program uses the Sqlite database.

[0012] In some embodiments of the present application, the loading module is specifically configured to: when the application program runs, the preset hook library is injected into the memory space of the application program, so that the hook library and the application program share the memory address, to realize real-time monitoring of the application program instruction and the function calling.

[0013] In some embodiments of the present application, the device further comprises: an analyzing module configured to analyze the state of the Sqlite database according to the database log information.

[0014] In a third aspect, the present application provides an electronic device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor executes the computer program to implement the method of the first aspect.

[0015] In a fourth aspect, the present application provides a computer readable storage medium, which stores computer readable instructions, and the computer readable instructions are executable by a processor to implement the method of the first aspect.

[0016] Compared with the prior art, the ARM environment Sqlite database monitoring method provided by the application loads the preset hook library when the application program runs; the ARM instruction and the DLL loading function called by the application program are parsed by using the hook library to determine whether the application program uses the Sqlite database; if the application program uses the Sqlite database and the database interface is not exported, the hook library is used to execute the fuzzy matching rule to output the database log information; if the application program uses the Sqlite database and the database interface has been exported, the hook library is used to directly perform hook operation on the database interface function, obtain the parameter information and the execution state information of the database interface function, and output to the database log information. Compared with the prior art, the application realizes the monitoring of the Sqlite database state in the ARM environment, and can improve the robustness and stability of the ARM application program in the Sqlite database use process. BRIEF DESCRIPTION OF DRAWINGS

[0017] Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The accompanying drawings are included to provide a description of the preferred embodiments and are not intended to limit the scope of the present application. Moreover, the same reference numerals are used throughout the same figures. In the drawings: Figure 1 A flow chart of an ARM environment Sqlite database monitoring method provided by an embodiment of the application is shown; Figure 2 A flow chart of a specific ARM environment Sqlite database monitoring method provided by an embodiment of the application is shown; Figure 3 A structural schematic diagram of an ARM environment Sqlite database monitoring device provided by an embodiment of the application is shown; Figure 4 A schematic diagram of an electronic device provided by an embodiment of the application is shown. DETAILED DESCRIPTION

[0018] Exemplary embodiments of the present disclosure will be described in detail with reference to the drawings. Although exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments described herein. Rather, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be accurately conveyed to those skilled in the art.

[0019] It should be noted that, unless otherwise specified, the technical terms or scientific terms used in the present application should be understood as the general meaning understood by those skilled in the art to which the present application belongs.

[0020] In addition, the terms "first" and "second" and the like are used to distinguish different objects, rather than to describe a particular order. Moreover, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a list of steps or units is not limited to the listed steps or units, but can optionally further include other steps or units not listed, or can optionally further include other steps or units inherent to such processes, methods, products, or devices.

[0021] Reference is made to Figure 1 , Figure 1 is a flowchart of an ARM environment Sqlite database monitoring method provided by the embodiment of the application, comprising the following steps S101-S104: S101, loading a preset hook library when an application program is running, the hook library being capable of analyzing an ARM instruction set and finding a calling relationship of the application program to a dynamic link library DLL; Specifically, the step S101 of loading the preset hook library when the application program is running is specifically: injecting the preset hook library into a memory space of the application program when the application program is running, so that the hook library and the application program share a memory address, to realize real-time monitoring of application program instructions and function calls.

[0022] S102, using the hook library to analyze ARM instructions and DLL loading functions called by the application program, to determine whether the application program uses a Sqlite database; Specifically, the step S102 can be implemented as follows: If the application program calls a DLL loading function to load a DLL related to the Sqlite database, it is determined that the application program uses the Sqlite database. If the application program calls a jump instruction to jump into a function containing a Sqlite fixed string, it is determined that the application program uses the Sqlite database.

[0023] Specifically, when the application program is running, the ARM process first loads the related hook library, finds the DLL calling relationship of the application program by analyzing the ARM instruction set, to determine whether the Sqlite related DLL is loaded. For example, when the "Sqlite.dll" similar string DLL is loaded by the LoadLibrary and other related functions, and when the B / LDR instruction is called to jump into the function containing the Sqlite fixed string, it is determined that the Sqlite related DLL is loaded.

[0024] S103, if the application uses the Sqlite database and does not export the database interface, the hook library is used to execute fuzzy matching rules to output database log information; the fuzzy matching rules are specifically: judging whether the pointer parameters and return values of the functions called by the application contain Sqlite statement syntax features, and when detecting that the Sqlite statement syntax features are contained, outputting the pointer parameters and return values of the corresponding functions to the database log information; Specifically, when the hook library analyzes the application integrated with the Sqlite database related DLL or Lib library and the database interface is not exported, the hook library outputs the database log information through the following fuzzy matching rules: By judging whether the pointer parameters and return values contain some syntax features of the Sqlite statement, such as the pointer address containing the "SQLite format" string feature at the beginning and the "Select" string being contained in the string pointer, the log is further outputted.

[0025] Taking the Sqlite3_prepare_v2 function as an example, the function parameter contains the Sqlite statement string, which generally contains the "Select" or "Insert" string statement, so that the function can be filtered out as the sqlite_exec execution function or the Sqlite3_prepare_v2 function through the judgment.

[0026] Further taking the sqlite_exec function as an example, the function parameter contains the Sqlite statement string, which can contain the "begin transaction;" "commit transaction;" string statement, so that the function can be filtered out as the exec execution function through the judgment.

[0027] It can be seen that the application can identify the Sqlite database interface rule through the fuzzy matching of the ARM instruction set, so as to obtain the database information.

[0028] S104, if the application uses the Sqlite database and has exported the database interface, the hook library is directly used to perform hook operation on the database interface function, to obtain the parameter information and execution state information of the database interface function, and to output to the database log information.

[0029] Specifically, when the hook library analyzes that the application exports the database interface, the required function can be directly hooked.

[0030] Taking bindText as an example, the third parameter is the string to be inserted into the database. Since the application has exported this function, this string can be directly output to the log. The execution status can also be determined by the return value of the database interface, and the status log should be output accordingly.

[0031] Taking Sqlite3_prepare_v2 as an example, the second parameter is the string of the SQL statement to be executed. Since the application has exported this function, it can directly output this string to the log, and at the same time know the number of fields in the corresponding database table and the field names when executing the statement.

[0032] In some embodiments, the SQLite database monitoring method under the ARM environment provided in this application further includes the step of analyzing the SQLite database status based on the database log information. For example, analyzing the SQLite database connection status, data operation progress, etc.

[0033] For ease of understanding, this application provides the following: Figure 2 The flowchart shown is a specific method for monitoring SQLite databases in an ARM environment, including the following steps: 1. Use the ARM environment application to load the hook library.

[0034] 2. Load some pre-defined ARM instruction set fuzzy matching rules.

[0035] 3. Determine if the application uses a SQLite database: If not, the analysis ends.

[0036] If so, proceed to determine whether to export the database interface.

[0037] 4. Regarding the determination result of whether to export the database interface: If not, perform a fuzzy matching function and use a hook to HOOK the suspicious function.

[0038] If so, then hook the database interface to monitor the database status.

[0039] This application addresses the robustness and stability of applications in the ARM environment. Based on a hook library, it extracts database interface functions from the ARM application's memory space by parsing the ARM instruction set. This allows for the analysis and monitoring of SQLite database usage behavior in ARM applications, resolving issues such as the inability to monitor interface parameters and SQLite execution statements when the database interface is not exposed to users after integrating SQLite into an ARM application. Similarly, it can directly hook interfaces from ARM applications that have exported their database interfaces, enabling users to analyze and optimize the database.

[0040] The beneficial effects of the SQLite database monitoring method under the ARM environment provided in this application are as follows: This application provides a SQLite database monitoring method for an ARM environment. It loads a pre-defined hook library during application runtime; uses the hook library to parse ARM instructions and DLL loading functions called by the application to determine whether the application uses a SQLite database; if the application uses a SQLite database but has not exported the database interface, the hook library executes fuzzy matching rules to output database log information; if the application uses a SQLite database and has exported the database interface, the hook library directly performs hook operations on the database interface functions to obtain parameter information and execution status information of the database interface functions, and outputs this information to the database log. Compared to existing technologies, this application achieves SQLite database status monitoring in an ARM environment, improving the robustness and stability of ARM applications using SQLite databases.

[0041] In the above embodiments, a method for monitoring SQLite databases in an ARM environment is provided. Correspondingly, this application also provides a device for monitoring SQLite databases in an ARM environment. The device for monitoring SQLite databases in an ARM environment provided in this application can implement the above-described method for monitoring SQLite databases in an ARM environment. This device can be implemented through software, hardware, or a combination of both. For example, the device may include integrated or separate functional modules or units to perform the corresponding steps in the above methods.

[0042] Please refer to Figure 3 As shown, this application provides a SQLite database monitoring device 10 under an ARM environment, comprising: The loading module 101 is used to load a preset hook library when the application runs. The hook library can parse the ARM instruction set and find the application's call relationship to the dynamic link library (DLL). The judgment module 102 is used to parse the ARM instructions and DLL loading functions called by the application using the hook library to determine whether the application uses a SQLite database; The monitoring module 103 is used to, if the application uses a SQLite database and has not exported the database interface, execute fuzzy matching rules using the hook library to output log information; the fuzzy matching rules specifically refer to: determining whether the pointer parameters and return values ​​of the functions called by the application contain SQLite statement syntax features, and when SQLite statement syntax features are detected, outputting the pointer parameters and return values ​​of the corresponding functions to the database log information; if the application uses a SQLite database and has already exported the database interface, then the hook library is used to directly perform hook operations on the database interface function to obtain the parameter information and execution status information of the database interface function, and outputting it to the database log information.

[0043] In some embodiments of this application, the determination module 102 is specifically used for: If the application calls the DLL loading function to load a SQLite database-related DLL, then it is determined that the application uses a SQLite database. If the application calls a jump instruction and jumps to a function containing the SQLite fixed string, then it is determined that the application uses a SQLite database.

[0044] In some embodiments of this application, the loading module 101 is specifically used for: During application runtime, a pre-defined hook library is injected into the application's memory space, allowing the hook library to share memory addresses with the application, thereby enabling real-time monitoring of application instructions and function calls.

[0045] In some embodiments of this application, the apparatus further includes: The analysis module is used to analyze the database log information to obtain the status of the SQLite database.

[0046] The SQLite database monitoring device under the ARM environment provided in this application embodiment and the SQLite database monitoring method under the ARM environment provided in this application embodiment are based on the same inventive concept and have the same beneficial effects as the methods they adopt, run or implement.

[0047] This application also provides an electronic device corresponding to the method provided in the foregoing embodiments. The electronic device can be an electronic device for a client, such as a mobile phone, laptop, tablet computer, desktop computer, etc., to execute the SQLite database monitoring method in the ARM environment described above.

[0048] Please refer to Figure 4 This illustrates a schematic diagram of an electronic device provided by some embodiments of this application. For example...Figure 4 As shown, the electronic device 20 includes: a processor 200, a memory 201, a bus 202, and a communication interface 203. The processor 200, the communication interface 203, and the memory 201 are connected via the bus 202. The memory 201 stores a computer program that can run on the processor 200. When the processor 200 runs the computer program, it executes the SQLite database monitoring method under the ARM environment provided in any of the foregoing embodiments of this application.

[0049] The memory 201 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 203 (which can be wired or wireless), such as the Internet, wide area network, local area network, or metropolitan area network.

[0050] Bus 202 can be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The memory 201 is used to store programs. After receiving an execution instruction, the processor 200 executes the program. The SQLite database monitoring method under the ARM environment disclosed in any of the foregoing embodiments of this application can be applied to the processor 200, or implemented by the processor 200.

[0051] The processor 200 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 200 or by instructions in software form. The processor 200 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules may reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in memory 201. The processor 200 reads the information in memory 201 and, in conjunction with its hardware, completes the steps of the above method.

[0052] The electronic device provided in this application embodiment and the SQLite database monitoring method under the ARM environment provided in this application embodiment are based on the same inventive concept and have the same beneficial effects as the methods they adopt, run or implement.

[0053] This application also provides a computer-readable storage medium corresponding to the SQLite database monitoring method under the ARM environment provided in the foregoing embodiments, wherein a computer program (i.e., a program product) is stored thereon. When the computer program is run by a processor, it executes the SQLite database monitoring method under the ARM environment provided in any of the foregoing embodiments.

[0054] It should be noted that examples of the computer-readable storage medium may also include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other optical and magnetic storage media, which will not be elaborated here.

[0055] The computer-readable storage medium provided in the above embodiments of this application and the SQLite database monitoring method under the ARM environment provided in the embodiments of this application are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by the applications stored therein.

[0056] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application, and they should all be covered within the scope of the claims and specification of this application.

Claims

1. A method for monitoring a Sqlite database in an ARM environment, characterized in that, The application comprises the following steps: loading a preset hook library at the runtime of an application, the hook library being capable of analyzing an ARM instruction set and finding a calling relationship of the application to a dynamic link library (DLL); analyzing ARM instructions and a DLL loading function called by the application by using the hook library to determine whether the application uses a Sqlite database; if the application uses a Sqlite database and does not export a database interface, executing a fuzzy matching rule by using the hook library to output database log information, the fuzzy matching rule being specifically that whether a pointer parameter and a return value of a function called by the application contain a Sqlite statement syntax feature is determined, and when the Sqlite statement syntax feature is detected, the pointer parameter and the return value of the corresponding function are output to the database log information; if the application uses a Sqlite database and has exported a database interface, directly performing hook operation on a database interface function by using the hook library to obtain parameter information and execution state information of the database interface function and output them to the database log information.

2. The method of claim 1, wherein, The step of analyzing ARM instructions and a DLL loading function called by the application by using the hook library to determine whether the application uses a Sqlite database comprises the following steps: if the application calls a DLL loading function to load a DLL related to a Sqlite database, it is determined that the application uses a Sqlite database; if the application jumps to a function containing a Sqlite fixed string by using a jump instruction, it is determined that the application uses a Sqlite database.

3. The method of claim 1, wherein, The step of loading a preset hook library at the runtime of an application comprises the following step: at the runtime of an application, injecting a preset hook library into a memory space of the application, so that the hook library and the application share a memory address, thereby realizing real-time monitoring of application instructions and function calls.

4. The method of claim 1, wherein, The method further comprises the following step: analyzing a state of a Sqlite database according to the database log information.

5. An ARM environment under Sqlite database monitoring device, characterized in that, The application comprises the following steps: a loading module is configured to load a preset hook library at the runtime of an application, the hook library being capable of analyzing an ARM instruction set and finding a calling relationship of the application to a dynamic link library (DLL); a judging module is configured to analyze ARM instructions and a DLL loading function called by the application by using the hook library to determine whether the application uses a Sqlite database; The monitoring module is configured to, if the application program uses the Sqlite database and the database interface is not exported, execute a fuzzy matching rule using the hook library to output database log information; the fuzzy matching rule is specifically that it is judged whether a pointer parameter and a return value of a function called by the application program contain a Sqlite statement syntax feature, and when it is detected that the Sqlite statement syntax feature is contained, the pointer parameter and the return value of the corresponding function are output to the database log information; if the application program uses the Sqlite database and the database interface is exported, the hook library is used to directly perform hook operation on the database interface function, to obtain parameter information and execution state information of the database interface function, and to output the parameter information and the execution state information to the database log information.

6. The apparatus of claim 5, wherein, The judging module is specifically configured to: If the application program calls a DLL loading function to load a DLL related to the Sqlite database, it is determined that the application program uses the Sqlite database. If the application program jumps to a function containing a Sqlite fixed string through a jump instruction, it is determined that the application program uses the Sqlite database.

7. The apparatus of claim 5, wherein, The loading module is specifically configured to: During application program running, a preset hook library is injected into a memory space of the application program, so that the hook library and the application program share a memory address, to realize real-time monitoring of application program instructions and function calls.

8. The apparatus of claim 5, wherein, The device further includes: An analysis module configured to analyze the database log information to obtain a state of the Sqlite database.

9. An electronic device comprising: A memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor, when executing the computer program, implements the method of any one of claims 1 to 4.

10. A computer-readable storage medium, characterized in that, A computer readable medium having stored thereon computer readable instructions executable by a processor to implement the method of any one of claims 1 to 4.