Information acquisition method and device and electronic equipment
By setting instrumentation code in the Linux kernel to obtain the running status information of the work queue callback function, the problem of difficulty in analyzing the system performance is solved, and detailed monitoring and optimization of computer system performance is achieved.
Patent Information
- Application Number
- CN202411515772.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-29
- Publication Date
- 2025-02-18
AI Technical Summary
The existing technology is difficult to monitor and analyze the operating information of work queues in the Linux kernel, which leads to difficulty in analyzing and optimizing computer system performance.
By setting the instrumentation code before and after the callback function execution, the running status information of the callback function is obtained, including the run start time, address, name and run time, etc.
It realizes the acquisition of detailed operating status information of the callback function, helps developers to quickly locate the reasons that affect system performance, and simplifies the system performance analysis and optimization process.
Smart Images

Figure CN119473652A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the technical field of electronic equipment, and specifically relates to an information acquisition method, device and electronic equipment. Background Art
[0002] As modern computer systems have increasing performance requirements, operating system kernels (especially the Linux kernel) play a vital role in achieving efficient resource management and scheduling. Work queues are an important mechanism in the Linux kernel for scheduling delay processing.
[0003] In the Linux kernel, work queues are mainly used to handle operations that cannot be directly executed in certain contexts (such as interrupts), such as processing after disk I / O operations are completed, processing after network data packets are received, etc. Each work queue is processed by a kernel thread (such as a kworker thread), which runs on different central processing unit (CPU) cores to effectively take advantage of multi-core hardware.
[0004] In the Linux kernel, the work queue mechanism relies on kworker threads to handle asynchronous tasks. However, in user mode, we can only see kworker threads with names such as kworker / 0:1 and kworker / 1:2 running work items, and cannot obtain specific running information of the work queue. The current kernel version does not have the ability to monitor the running information of the work queue. Due to the lack of detailed information monitoring of the work items in the work queue, it becomes very difficult to analyze and optimize system performance. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide an information acquisition method, device and electronic device to solve the problem of difficulty in performance analysis of a computer system.
[0006] In order to solve the above technical problems, this application is implemented as follows:
[0007] In a first aspect, an embodiment of the present application provides an information acquisition method, comprising:
[0008] Before the callback function is executed, obtaining first information through a first stub code corresponding to the callback function;
[0009] After the callback function is executed, obtaining second information through a second plug-in code corresponding to the callback function;
[0010] The first information and the second information are used to determine the running status information of the callback function.
[0011] In a second aspect, an embodiment of the present application provides an information acquisition device, including:
[0012] A first acquisition module, used for acquiring first information through a first plug-in code corresponding to the callback function before the callback function is executed;
[0013] A second acquisition module, configured to acquire second information through a second plug-in code corresponding to the callback function after the callback function is executed;
[0014] The first information and the second information are used to determine the running status information of the callback function.
[0015] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect are implemented.
[0016] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored, and when the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0017] In a fifth aspect, an embodiment of the present application further provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction to implement the method described in the first aspect.
[0018] In a sixth aspect, an embodiment of the present application provides a computer program product, which is stored in a storage medium and is executed by at least one processor to implement the method described in the first aspect.
[0019] In an embodiment of the present application, a first plug-in code and a second plug-in code are set for a callback function, and first information is obtained through the first plug-in code before the callback function is executed, and second information is obtained through the second plug-in code after the callback function is executed. The developer can determine the running status information of the callback function based on the first information and the second information, thereby solving the problem of difficulty in performance analysis of the computer system. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 This is one of the flowcharts of the information acquisition method of the embodiment of the present application;
[0021] Figure 2 is a schematic diagram of the location of the interface in the embodiment of the present application;
[0022] Figure 3 This is the second flow chart of the information acquisition method of the embodiment of the present application;
[0023] Figure 4 is a schematic diagram of the structure of an information acquisition device according to an embodiment of the present application;
[0024] Figure 5 It is one of the structural schematic diagrams of the electronic device according to the embodiment of the present application;
[0025] Figure 6 This is the second structural schematic diagram of the electronic device according to the embodiment of the present application. DETAILED DESCRIPTION
[0026] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.
[0027] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0028] The network processing method, device and electronic device provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0029] like Figure 1 As shown, an embodiment of the present application provides an information acquisition method, the method comprising:
[0030] Step 101: before the callback function is executed, first information is obtained through a first plug-in code corresponding to the callback function;
[0031] Step 102: After the callback function is executed, obtain second information through a second plug-in code corresponding to the callback function;
[0032] The first information and the second information are used to determine the running status information of the callback function.
[0033] In this embodiment, the callback function is a callback function specified by a pending work item in a work queue of the operating system kernel. The operating system kernel is, for example, Linux. In the work queue process of Linux, process_one_work plays a key role. Its main function is to take out a pending work item from the work queue and execute the callback function specified by the work item (run the work content specified by the developer). The callback function is a function body defined by the developer using the kernel work queue, and is used to execute specific work in the work item. The operation of the kernel work queue is to continuously execute various callback functions.
[0034] This application obtains first information through the first plugging code corresponding to the callback function before the callback function is executed, such as the running start time, address, name, running times, etc. of the callback function. After the callback function is executed, the second information is obtained through the second plugging code corresponding to the callback function, such as the running time of the callback function, and the running status of the callback function can be determined according to the first information and the second information.
[0035] The first stub code is, for example: register_trace_hook("workqueue_execute_start", wq_start_hook); indicating that the position before the callback function is executed (workqueue_execute_start) jumps to the wq_start_hook function body;
[0036] The second stub code is, for example: register_trace_hook("workqueue_execute_end", wq_end_hook); which means jumping to the wq_end_hook function body at the position (workqueue_execute_end) after the callback function is executed.
[0037] The above code inserts stubs at two points before (workqueue_execute_start) and after (workqueue_execute_end) the callback function is executed. Before the callback function is executed, it jumps to the "wq_start_hook" function body to obtain the first information. After the callback function is executed, it jumps to the "wq_end_hook" function body to obtain the second information.
[0038] In this way, relevant information of the callback function is recorded before and after the callback function runs. The recorded information can provide the number of initiators and the total running time of each initiator, helping developers to quickly locate the reasons that affect system performance in the kernel work queue; the recorded information directly provides the specific work queue initiator, and the content can be accurate to the specific function body. Developers do not need to further analyze and locate the initiator of the log or tracking information, so that developers can easily read the running information of the work queue, and there is no need to capture tracking information when analyzing the same problem.
[0039] In an embodiment of the present application, a first plug-in code and a second plug-in code are set for a callback function, and first information is obtained through the first plug-in code before the callback function is executed, and second information is obtained through the second plug-in code after the callback function is executed. The developer can determine the running status information of the callback function based on the first information and the second information, thereby solving the problem of difficulty in performance analysis of the computer system.
[0040] Optionally, the first information includes at least one of the following: the address of the callback function, the name of the callback function, the number of times the callback function is run, and the current start time of the callback function;
[0041] The second information includes at least one of the following: the current running time of the callback function and the total running time of the callback function.
[0042] In this embodiment, by acquiring the first information and the second information related to the callback function, the developer can determine the running status of the callback function according to the first information and the second information.
[0043] As an optional embodiment, the method further includes:
[0044] Insert the first insertion code at the first code position of the callback function; the first code position is the position before the execution code of the callback function;
[0045] The second stub code is inserted at a second code position of the callback function; the second code position is a position after the execution code of the callback function.
[0046] In this embodiment, the first code position is the position before the execution code of the callback function, for example, the critical position before the execution code of the callback function starts running. Before the callback function starts running, the first stub code is executed to obtain the first information; for example: before the execution code of the callback function starts running, jump to the wq_start_hook function body to obtain the address, name, running times, running start time and other information of the callback function.
[0047] The second code position is the position after the execution code of the callback function, for example, the critical position after the execution code of the callback function ends. After the execution code of the callback function starts running, the second plug-in code is executed to obtain the second information; for example: after the execution code of the callback function starts running, jump to the wq_end_hook function body to obtain the duration of the callback function running this time, so that the total running time of the callback function can be determined according to the duration of the current running.
[0048] As an optional embodiment, the method further includes:
[0049] An information recording table of the callback function is created, where the information recording table is used to record the first information and the second information.
[0050] In this embodiment, when the first information is obtained through the first plug-in code corresponding to the callback function, the first information can be recorded in the information recording table; when the second information is obtained through the second plug-in code corresponding to the callback function, the second information can be recorded in the information recording table. In this way, the developer can obtain the running status of the callback function according to the content recorded in the information recording table. Among them, an information recording table can be created for each callback function, or an information recording table can be created for multiple callback functions to record the specific information of each callback function that has been run in the system work queue. The information recording table is, for example, a hash table.
[0051] Optionally, the record items of the information record table include at least one of the following:
[0052] The address of the callback function;
[0053] The number of times the callback function is run;
[0054] The total runtime of the callback function;
[0055] The start time of each execution of the callback function;
[0056] The name of the callback function.
[0057] In this embodiment, the structure of the information record table is as follows:
[0058] struct kworker_entry{
[0059] unsigned long address;
[0060] unsigned long long count;
[0061] unsigned long long time;
[0062] long long start_time;
[0063] char symbol[MAX_SYMBOL_LEN];
[0064] struct hlist_node hash;
[0065] };
[0066] The structure includes: the address of the callback function (address), the number of executions of the callback function (count), the total execution time of the callback function (time), the start time of each execution of the callback function (start_time), and the name of the callback function in the code (symbol). The start time of each execution of the callback function is used to calculate the execution time of this execution.
[0067] As an optional embodiment, the method further includes:
[0068] Before the callback function is executed, a first stub code corresponding to the callback function is run;
[0069] Using the address of the callback function as a key value, querying in the information record table of the callback function;
[0070] If the record item of the callback function is not found, a record item of the callback function is created in the information record table. Optionally, the first information of the callback function is recorded after the record item is created.
[0071] Optionally, if a record item of the callback function is found in the information record table, the information recorded in the record item is updated according to the acquired first information.
[0072] In this embodiment, after the first stub code is inserted at the first code position, when preparing to run the code of the callback function, the address of this function is used as the key value to query the information record table of the callback function. If the information of the function cannot be found, a new record item is created in the table to record the running status of the function. Optionally, when creating a new record item, the "sprint_symbol_no_offset" method of the Linux kernel can be used to obtain the function name of the function and record it in the symbol of the record item. After finding or creating a new record item, perform the following operations:
[0073] Add one to the number of runs (count);
[0074] Record the current time as the start time of the record item (that is, the start time of this run), so that the running time can be calculated later when the function exits the runtime.
[0075] As an optional embodiment, the method further includes:
[0076] After the callback function is executed, the second stub code corresponding to the callback function is executed; the address of the callback function is used as a key value, and an inquiry is performed in the information record table of the callback function to obtain the execution start time of the callback function;
[0077] Determine the current running time of the callback function according to the current time and the running start time;
[0078] The total running time of the callback function is determined according to the current running time.
[0079] Optionally, the second information of the callback function in the information recording table is updated according to the current running time and the total running time.
[0080] In this embodiment, the callback function is entered for post-processing at the second code position. When exiting the callback function, the address of this function is used as the key value to query the corresponding record item in the information record table of the callback function, and the current time is subtracted from the start time of this operation (start_time) in the record item to obtain the duration of this operation, and add it to the total running time (time) of the function to complete the record update of the work item.
[0081] As an optional embodiment, the method further includes: creating an interface in the kernel space, wherein the interface is used to query the information record table of the callback function.
[0082] In this embodiment, the function of the interface is to allow developers to easily obtain the statistical information of the kernel work queue at any time. Figure 2 As shown: the interface is established in the kernel space.
[0083] Optionally, the method further includes: receiving a first input; and in response to the first input, determining the running status information of the callback function based on the first information and the second information in the information recording table of the callback function.
[0084] In this embodiment, the first input may be a command input by a user (such as a developer). Through the first input, the first information and the second information corresponding to the callback function may be obtained from the information recording table, thereby determining the running state of the callback function.
[0085] For example, when the interface is named "kworker_stat", the developer or application can use the command "cat / proc / kworker_stat" to obtain the statistics of the kernel work queue from the bottom layer. The format is: number of runs, running time (ms), function name [module name], and the output result example is as follows:
[0086] 14,22212385,fun1[module1]
[0087] 234,129741353,fun2
[0088] 1,220573,fun3[module2]
[0089] 1,30976406,fun4
[0090] It should be noted that this application does not limit the execution order of creating the insertion points, interfaces, and information record tables.
[0091] In the traditional way, if developers want to understand the running status of the system's kernel work queue, they need to capture tracing information (trace), and they need to perform multiple tedious steps, such as: configuring the type of information to be captured on the computer, importing the configuration information into the mobile phone and starting to capture, exporting the trace file to the terminal after the capture is completed, and using tools to help analyze. This application creates an interface so that developers do not need to capture traces when they want to understand the running status of the system's kernel work queue, and can intuitively display problematic work items and specific initiators, making it easier to analyze performance and power consumption issues, and helping developers optimize the performance and power consumption of the system.
[0092] In the work queue process of the operating system kernel (such as Linux), process_one_work plays a key role. Its main function is to take out a work item to be processed from the work queue and execute the callback function specified by the work item (run the work content specified by the developer). The information acquisition process of the embodiment of the present application is as follows Figure 3 As shown, including:
[0093] Step 31, work item acquisition: take out a work item to be processed from the work queue. It contains all necessary information of the work item, such as callback function pointer, pointer to the work queue, etc. Among them, the callback function pointer points to the address of the callback function, which is used to find the callback function and run it.
[0094] Step 32: Acquire relevant resources: Acquire the necessary "locks" to ensure that the work items are processed correctly in a concurrent environment.
[0095] Among them, a system with multiple CPU cores (such as a mobile phone) can run programs in parallel. At the same time, multiple CPU cores may be running kernel work queues. In order to avoid data problems caused by such concurrent operation, a synchronization mechanism is needed to ensure that only one party is operating a work queue at the same time. The "lock" is one of the synchronization mechanisms. Only the party that obtains the lock can operate the work queue. After the operation is completed and the lock is released, others can obtain the lock and operate the work queue, thereby avoiding problems caused by the work queue being modified by multiple parties concurrently.
[0096] Step 33, insert a stub at the first code position before the callback function starts to execute, run the first insert stub code to obtain first information, and record the first information in the information recording table of the callback function. The content of the first information is not repeated here.
[0097] Step 34, execute callback function: call the callback function specified by the work item. The callback function is user-defined and is used to execute the actual work task, thereby realizing asynchronous execution of the task.
[0098] Step 35, insert a stub at the second code position where the callback function is executed, run the second inserting code to obtain second information, and record the second information in the information recording table of the callback function. The content of the second information is not repeated here.
[0099] Step 36: Release related resources: release related locks and update the status information of the work queue.
[0100] Step 37, error handling and cleanup: If an error occurs during the execution of the callback function, corresponding error handling and cleanup work is required, including: recording error logs, releasing allocated resources, etc.
[0101] This embodiment allows developers to understand the operating status of the kernel work queue of the system without having to capture traces, and can intuitively display problematic work items and specific initiators, making it easier to analyze performance and power consumption issues and helping developers optimize the performance and power consumption of the system.
[0102] The embodiment of the present application provides a user-mode interface, which allows developers to easily read the operation information of the work queue, and no longer needs to capture tracking information when analyzing the same problem. The number of initiators and the total running time of each initiator are provided to help developers quickly locate the reasons that affect system performance in the kernel work queue; the information record table can directly provide the specific work queue initiator, and the content is accurate to the specific function body, without the need for developers to further analyze and locate the initiator of the log or tracking information, thereby helping to quickly solve the abnormality of the operating system kernel work queue, and assist in the analysis of the performance bottleneck of some systems in the operating system kernel work queue, and help optimize system performance.
[0103] like Figure 4 As shown, the embodiment of the present application further provides an information acquisition device 400, including:
[0104] A first acquisition module 410 is used to acquire first information through a first plug-in code corresponding to the callback function before the callback function is executed;
[0105] A second acquisition module 420 is used to acquire second information through a second plug-in code corresponding to the callback function after the callback function is executed;
[0106] The first information and the second information are used to determine the running status information of the callback function.
[0107] Optionally, the device further comprises:
[0108] A first plugging module, used for plugging the first plugging code at a first code position of the callback function; the first code position is a position before the execution code of the callback function;
[0109] The second plugging module is used to plug the second plugging code at a second code position of the callback function; the second code position is a position after the execution code of the callback function.
[0110] Optionally, the device further comprises:
[0111] The first creation module is used to create an information recording table of the callback function, and the information recording table is used to record the first information and the second information.
[0112] Optionally, the record items of the information record table include at least one of the following:
[0113] The address of the callback function;
[0114] The number of times the callback function is run;
[0115] The total runtime of the callback function;
[0116] The start time of each execution of the callback function;
[0117] The name of the callback function.
[0118] Optionally, the device further comprises:
[0119] A first running module, used for running a first stub code corresponding to the callback function before the callback function is executed;
[0120] A first query module, used to query the information record table of the callback function by using the address of the callback function as a key value;
[0121] The second creation module is used to create a record item of the callback function in the information record table if the record item of the callback function is not found.
[0122] Optionally, the first information includes at least one of the following: the address of the callback function, the name of the callback function, the number of times the callback function is run, and the current start time of the callback function;
[0123] The second information includes at least one of the following: the current running time of the callback function and the total running time of the callback function.
[0124] Optionally, the device further comprises:
[0125] A first running module, used for running a second stub code corresponding to the callback function after the callback function is executed;
[0126] A second query module is used to query the information record table of the callback function by using the address of the callback function as a key value to obtain the running start time of the callback function;
[0127] A first determining module, used to determine the current running time of the callback function according to the current time and the running start time;
[0128] The second determining module is used to determine the total running time of the callback function according to the current running time.
[0129] Optionally, the device further comprises:
[0130] The third creation module is used to create an interface in the kernel space, and the interface is used to query the information record table of the callback function.
[0131] Optionally, the device further comprises:
[0132] A receiving module, configured to receive a first input;
[0133] A response module is used to determine the running status information of the callback function based on the first information and the second information in the information recording table of the callback function in response to the first input.
[0134] In an embodiment of the present application, a first plug-in code and a second plug-in code are set for a callback function, and first information is obtained through the first plug-in code before the callback function is executed, and second information is obtained through the second plug-in code after the callback function is executed. The developer can determine the running status information of the callback function based on the first information and the second information, thereby solving the problem of difficulty in performance analysis of the computer system.
[0135] The information acquisition device in the embodiment of the present application can be an electronic device, or a component in the electronic device, such as an integrated circuit or a chip. The electronic device can be a terminal, or it can be other devices other than the terminal. Exemplarily, the electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, a vehicle-mounted electronic device, a mobile Internet device (Mobile Internet Device, MID), an augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) device, a robot, a wearable device, an ultra-mobile personal computer (ultra-mobile personal computer, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and can also be a server, a network attached storage (Network Attached Storage, NAS), a personal computer (personal computer, PC), a television (television, TV), a teller machine or a self-service machine, etc., and the embodiment of the present application is not specifically limited.
[0136] The information acquisition device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.
[0137] The information acquisition device provided in the embodiment of the present application can achieve Figures 1 to 3 To avoid repetition, the various processes implemented by the method embodiment are not described here.
[0138] Optional, such as Figure 5As shown, an embodiment of the present application also provides an electronic device 500, including a processor 501, a memory 502, and a program or instruction stored in the memory 502 and executable on the processor 501. When the program or instruction is executed by the processor 501, each process of the above-mentioned information acquisition method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0139] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.
[0140] Figure 6 A schematic diagram of the hardware structure of an electronic device to implement an embodiment of the present application.
[0141] The electronic device 600 includes but is not limited to: a radio frequency unit 601, a network module 602, an audio output unit 603, an input unit 604, a sensor 605, a display unit 606, a user input unit 607, an interface unit 608, a memory 609, and a processor 610.
[0142] Those skilled in the art will appreciate that the electronic device 600 may also include a power source (such as a battery) for supplying power to each component, and the power source may be logically connected to the processor 610 through a power management system, thereby implementing functions such as managing charging, discharging, and power consumption management through the power management system. Figure 6 The electronic device structure shown in the figure does not constitute a limitation on the electronic device. The electronic device may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be described in detail here.
[0143] The processor 610 is used to: before the callback function is executed, obtain the first information through the first plug-in code corresponding to the callback function;
[0144] After the callback function is executed, obtaining second information through a second plug-in code corresponding to the callback function;
[0145] The first information and the second information are used to determine the running status information of the callback function.
[0146] Optionally, the processor 610 is further configured to: insert the first insertion code at a first code position of the callback function; the first code position is a position before the execution code of the callback function;
[0147] The second stub code is inserted at a second code position of the callback function; the second code position is a position after the execution code of the callback function.
[0148] Optionally, the processor 610 is further used to: create an information recording table of the callback function, where the information recording table is used to record the first information and the second information.
[0149] Optionally, the record items of the information record table include at least one of the following:
[0150] The address of the callback function;
[0151] The number of times the callback function is run;
[0152] The total runtime of the callback function;
[0153] The start time of each execution of the callback function;
[0154] The name of the callback function.
[0155] Optionally, the processor 610 is further configured to:
[0156] Before the callback function is executed, a first stub code corresponding to the callback function is run;
[0157] Using the address of the callback function as a key value, querying in the information record table of the callback function;
[0158] If no record item of the callback function is found, a record item of the callback function is created in the information record table.
[0159] Optionally, the first information includes at least one of the following: the address of the callback function, the name of the callback function, the number of times the callback function is run, and the current start time of the callback function;
[0160] The second information includes at least one of the following: the current running time of the callback function and the total running time of the callback function.
[0161] Optionally, the processor 610 is further configured to:
[0162] After the callback function is executed, run the second stub code corresponding to the callback function;
[0163] Using the address of the callback function as a key value, querying in the information record table of the callback function to obtain the running start time of the callback function;
[0164] Determine the current running time of the callback function according to the current time and the running start time;
[0165] The total running time of the callback function is determined according to the current running time.
[0166] Optionally, the processor 610 is further used to: create an interface in the kernel space, where the interface is used to query the information record table of the callback function.
[0167] Optionally, the processor 610 is further configured to: receive a first input;
[0168] In response to the first input, the running state information of the callback function is determined based on the first information and the second information in the information recording table of the callback function.
[0169] It should be understood that in the embodiment of the present application, the input unit 604 may include a graphics processor (GPU) 6041 and a microphone 6042, and the graphics processor 6041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 606 may include a display panel 6061, and the display panel 6061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 607 includes a touch panel 6071 and at least one of other input devices 6072. The touch panel 6071 is also called a touch screen. The touch panel 6071 may include two parts: a touch detection device and a touch controller. Other input devices 6072 may include, but are not limited to, a physical keyboard, function keys (such as a volume control button, a switch button, etc.), a trackball, a mouse, and a joystick, which will not be repeated here.
[0170] The memory 609 can be used to store software programs and various data. The memory 609 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, an application program or instructions required for at least one function (such as a sound playback function, an image playback function, etc.), etc. In addition, the memory 609 may include a volatile memory or a non-volatile memory, or the memory 609 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM) and a direct memory bus random access memory (DRRAM). The memory 609 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.
[0171] The processor 610 may include one or more processing units; optionally, the processor 610 integrates an application processor and a modem processor, wherein the application processor mainly processes operations related to an operating system, a user interface, and application programs, and the modem processor mainly processes wireless communication signals, such as a baseband processor. It is understandable that the modem processor may not be integrated into the processor 610.
[0172] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned information acquisition method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0173] The processor is the processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory ROM, a random access memory RAM, a magnetic disk or an optical disk.
[0174] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned information acquisition method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0175] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.
[0176] An embodiment of the present application provides a computer program product, which is stored in a storage medium. The program product is executed by at least one processor to implement the various processes of the information acquisition method embodiment as described above, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0177] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.
[0178] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.
Claims
1. A method for obtaining information, characterized in that: include: Before the callback function is executed, obtaining first information through a first stub code corresponding to the callback function; After the callback function is executed, obtaining second information through a second plug-in code corresponding to the callback function; The first information and the second information are used to determine the running status information of the callback function.
2. The method according to claim 1, characterized in that The method further comprises: Insert the first insertion code at the first code position of the callback function; the first code position is the position before the execution code of the callback function; The second stub code is inserted at a second code position of the callback function; the second code position is a position after the execution code of the callback function.
3. The method according to claim 1, characterized in that The method further comprises: An information recording table of the callback function is created, where the information recording table is used to record the first information and the second information.
4. The method according to claim 3, characterized in that: The record items of the information record table include at least one of the following: The address of the callback function; The number of times the callback function is run; The total runtime of the callback function; The start time of each execution of the callback function; The name of the callback function.
5. The method according to claim 4, characterized in that The method further comprises: Before the callback function is executed, a first stub code corresponding to the callback function is run; Using the address of the callback function as a key value, querying in the information record table of the callback function; If no record item of the callback function is found, a record item of the callback function is created in the information record table.
6. The method according to claim 1, characterized in that The first information includes at least one of the following: the address of the callback function, the name of the callback function, the number of times the callback function is run, and the current start time of the callback function; The second information includes at least one of the following: the current running time of the callback function and the total running time of the callback function.
7. The method according to claim 3, characterized in that The method further comprises: An interface is created in the kernel space, where the interface is used to query the information record table of the callback function.
8. The method according to claim 3, characterized in that The method further comprises: receiving a first input; In response to the first input, the running state information of the callback function is determined based on the first information and the second information in the information recording table of the callback function.
9. An information acquisition device, characterized in that: include: A first acquisition module, used for acquiring first information through a first plug-in code corresponding to the callback function before the callback function is executed; A second acquisition module, configured to acquire second information through a second plug-in code corresponding to the callback function after the callback function is executed; The first information and the second information are used to determine the running status information of the callback function.
10. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the programs or instructions are executed by the processor, the steps of the information acquisition method according to any one of claims 1 to 8 are implemented.