CN114780173A - Method for loading plug-in application, computing equipment and storage medium - Google Patents

Method for loading plug-in application, computing equipment and storage medium Download PDF

Info

Publication number
CN114780173A
CN114780173A CN202210431692.XA CN202210431692A CN114780173A CN 114780173 A CN114780173 A CN 114780173A CN 202210431692 A CN202210431692 A CN 202210431692A CN 114780173 A CN114780173 A CN 114780173A
Authority
CN
China
Prior art keywords
plug
version information
application
loading
version
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.)
Granted
Application number
CN202210431692.XA
Other languages
Chinese (zh)
Other versions
CN114780173B (en
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.)
Uniontech Software Technology Co Ltd
Original Assignee
Uniontech Software 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 Uniontech Software Technology Co Ltd filed Critical Uniontech Software Technology Co Ltd
Priority to CN202210431692.XA priority Critical patent/CN114780173B/en
Publication of CN114780173A publication Critical patent/CN114780173A/en
Application granted granted Critical
Publication of CN114780173B publication Critical patent/CN114780173B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE 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/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Stored Programmes (AREA)

Abstract

The invention discloses a method for loading a plug-in an application, a computing device and a storage medium, wherein the method for loading the plug-in the application is executed in the computing device, and comprises the following steps: when a first plug-in loading instruction is monitored, loading a second plug-in of the agent first plug-in an application, wherein at least one version of the first plug-in is resident in the computing equipment, and the second plug-in is associated with each first plug-in; acquiring first version information of a development library depended by an application in operation; determining a target first plug-in matched with the first version information from all the first plug-ins based on the second plug-ins and the first version information; a target first plug-in is loaded in the application.

Description

Method for loading plug-in application, computing equipment and storage medium
The application is a divisional application of an invention patent application filed on 25.01.2022, original application number: 2022100835744, title of the invention: a method, a computing device and a storage medium for loading a plug-in an application.
Technical Field
The invention relates to the technical field of computers, in particular to a method for loading a plug-in an application, a computing device and a storage medium.
Background
Typically, both the plug-ins and their dependent applications are built from the same development library. When the application and the plug-in are running, the development library which depends on the application and the plug-in is loaded into the memory, and after the version of the development library is upgraded, for example, the development library needs to be subjected to function updating with a larger amplitude, the original compatibility of the development library is often damaged by the updating, and in order to avoid the influence on the application and the plug-in which are used for a long time, the development libraries with multiple versions need to be integrated in the system. At this time, when the application is running, if the development library on which the application and the plug-in depend belongs to one version, the development library of the version is only loaded in the memory. If the development libraries depended by the applications and the plugins do not belong to one version, the development libraries of different versions can be loaded in the memory, so that cross-dependence between the plugins and the development libraries of different versions is caused, in other words, the plugins depended on the development libraries of the low version can run in the development library environment of the high version or the plugins depended on the development libraries of the high version run in the development library environment of the low version, different versions of the same development library are simultaneously loaded and used, and because the development libraries of a plurality of versions cannot coexist at the same time, abnormality can be caused in the operation of the applications.
Disclosure of Invention
In view of the above, the present invention has been made to provide a method, a computing device and a storage medium for loading a plug-in an application that overcome or at least partially solve the above problems.
According to one aspect of the invention, there is provided a method of loading a plug-in an application, for execution in a computing device, the method comprising: when a first plug-in loading instruction is monitored, loading a second plug-in of the agent first plug-in an application, wherein at least one version of the first plug-in is resident in the computing equipment, and the second plug-in is associated with each first plug-in; acquiring first version information of a development library depended by an application in operation; determining a target first plug-in matched with the first version information from the first plug-ins of at least one version based on the second plug-ins and the first version information; a target first plug-in is loaded in the application.
Optionally, in the method for loading a plug-in an application according to the present invention, the step of loading a second plug-in the application, which is a proxy for the first plug-in, includes: constructing a second plug-in based on the configuration information of each first plug-in, wherein the configuration information at least comprises the identification, the storage path and the second version information of each first plug-in; the second plug-in is loaded with the application.
Optionally, in the method for loading a plug-in an application according to the present invention, the step of obtaining first version information of a development library on which the application runs includes: determining a development library currently loaded by the computing device; and acquiring the first version information from the loaded development library by adopting a symbolic address acquisition function.
Optionally, in the method for loading a plug-in an application according to the present invention, the step of obtaining first version information of a development library on which the application runs includes: reading a current process content mapping space of the computing equipment, and traversing all memory symbol contents in the current process content mapping space; first version information is determined from the memory symbol content.
Optionally, in the method for loading a plug-in an application according to the present invention, the step of obtaining first version information of a development library on which the application runs includes: determining a development library currently loaded by the computing device; acquiring first version information from a loaded development library by adopting a symbolic address acquisition function; detecting whether first version information is acquired or not; if not, reading the current process content mapping space of the computing equipment; traversing all memory symbol contents in the process content mapping space; first version information is determined from the memory symbol content.
Optionally, in the method for loading plug-ins in an application according to the present invention, the step of constructing a second plug-in based on the configuration information of each first plug-in includes: judging whether the storage paths of the first plug-ins have the same superior directory or not; if so, setting the absolute storage path of the second plug-in as an upper directory of the absolute storage path of each first plug-in, and creating the second plug-in under the directory.
Optionally, in the method for loading plug-ins in an application according to the present invention, the step of determining a target first plug-in that matches the first version information from the first plug-ins based on the second plug-ins and the first version information includes: acquiring an absolute storage path of a second plug-in; splicing the absolute storage path with the first version information to obtain an absolute storage path of the target first plug-in unit; and determining the target first plug-in based on the absolute storage path of the target first plug-in.
Optionally, in the method for loading plug-ins in an application according to the present invention, the step of determining a target first plug-in that matches the first version information from the first plug-ins based on the second plug-ins and the first version information includes: judging whether the storage paths of the first plug-ins have the same superior directory or not; if not, matching the first version information with the second version information of each first plug-in; and determining the first plug-in corresponding to the successfully matched second version information as a target first plug-in.
Optionally, in the method for loading a plug-in an application according to the present invention, before the step of loading a second plug-in that proxies the first plug-in the application when the first plug-in loading instruction is monitored, the method further comprises the steps of: acquiring development libraries of all versions corresponding to the application; and constructing a corresponding first plug-in for each version of the development library.
According to yet another aspect of the invention, there is provided a computing device comprising: at least one processor; and a memory storing program instructions, wherein the program instructions are configured to be executed by the at least one processor, the program instructions comprising instructions for performing the above-described method.
According to yet another aspect of the present invention, there is provided a readable storage medium storing program instructions which, when read and executed by a computing device, cause the computing device to perform the above-described method.
According to the scheme of the invention, by constructing the proxy plug-in of the first plug-in, namely the mode of the second plug-in, when the first plug-in is loaded by the application, the dependent library version of the plug-in can be dynamically identified, and single dependent loading is carried out on the plug-in, so that the phenomenon that different versions of the same development library are loaded at the same time is solved. Moreover, by the scheme of automatically selecting the version of the first plug-in, the target first plug-in can be forwarded from the second plug-in, and the loading mode of the traditional plug-in and the subpackage type plug-in which multiple versions depend is compatible.
The above description is only an overview of the technical solutions of the present invention, and the present invention can be implemented in accordance with the content of the description so as to make the technical means of the present invention more clearly understood, and the above and other objects, features, and advantages of the present invention will be more clearly understood.
Drawings
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 drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 illustrates a schematic diagram of the operational mode of a dynamic library;
FIG. 2 is a schematic diagram illustrating the implementation of a Qt dynamic library plug-in;
FIG. 3 is a flowchart illustrating a process of implementing loading of a plug-in via a QPluginLoader class;
FIG. 4 is a schematic diagram illustrating the dependency relationship of the operation of the program A;
FIG. 5 illustrates a block diagram of a computing device 500, according to one embodiment of the invention;
FIG. 6 illustrates a flow diagram of a method 600 for loading a plug-in an application, according to one embodiment of the invention;
FIG. 7 illustrates a proxy mechanism diagram for a second plug-in, according to one embodiment of the invention;
FIG. 8 is a schematic diagram illustrating a dual pass acquisition of a first version of information according to one embodiment of the present invention;
FIG. 9 shows a schematic diagram of a plug-in selection mechanism in accordance with one embodiment of the invention;
fig. 10 is a flowchart illustrating a method for loading a plug-in an application according to an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
A plug-in is a third party program written by following the interface specification of the application. The application program needs to provide various services that enable the plug-in to work properly, including plug-in loading, plug-in application and data interaction. The plug-in can only function depending on the application program, and the application program can still run without depending on the plug-in. Since the dynamic loading of dynamic libraries works very similar to the working principle of plug-ins, almost all developers use the way dynamic libraries when designing plug-ins. A dynamic library is a binary program file that provides a process with the ability to invoke code that is not native to the process itself.
In one specific example, as shown in FIG. 1, FIG. 1 illustrates a schematic diagram of a mode of operation of a dynamic library. Referring to fig. 1, the dynamic library is not linked to the code of the application 1 or the application 2 at the time of program compilation, and is loaded only when the application 1 or the application 2 runs using the contents of the dynamic library. If different programs use the same dynamic library, only one instance of the dynamic library is stored in the memory, and repeated loading is not carried out. Therefore, the dynamic library is utilized to develop the application and the plug-in, and the method has the advantages that the link of the content of the dynamic library can be postponed to the running period of the application 1 or the application 2, the resource sharing among processes can be realized, the link of the dynamic library is completely controllable, and the like.
It should be noted that it is not enough to directly use a dynamic library as a plug-in, and the plug-in the application design needs to ensure compatibility of ABI (interface between two program modules, where usually one program module is a service provided by a library or an operating system, and the other module is a program run by a user) and exists independently of the application itself. In other words, the application compiling does not need to know whether the plug-in exists, and the run-time program does not fail to start due to the lack of the plug-in. The common dynamic library can not realize the characteristics, and the current plug-in is realized only along with the continuous upgrading and reconstruction of developers on the basis of the dynamic library. It should be noted that ABI compatibility means that when a library file is upgraded, an executable file or other library files using the library file does not need to be recompiled, and the functions of the program are not destroyed.
The Qt application development framework is widely applied to and develops GUI (Graphical User Interface) programs, and has two sets of APIs for creating plug-ins: 1. high-level APIs that can extend the functionality of Qt, such as: database drivers, image formats, text coding, custom styles, and the like; 2. the low-level API of the Qt application can be expanded, and the plug-in for expanding the Qt application needs to be realized by sub-classifying proper plug-in base classes, realizing some functions in the plug-in and specifying some macros and the like.
In a specific example, as shown in fig. 2, fig. 2 shows a schematic diagram of an implementation principle of a dynamic library plug-in of Qt. Referring to fig. 2, when the plug-in is constructed by using Qt, some specific symbols are added when the plug-in is compiled, since the dynamic library on the Linux system is an ELF format file (a file used for binary files, executable files, object codes, shared libraries, and core dump format files), which can derive the function symbols therein, after the dynamic library is loaded, Qt locates the memory address of the function by identifying the function symbols in such files, and finally executes it to create the plug-in class, which ensures the independent loading of the plug-in. Besides, a set of proprietary interfaces is provided for the designed plug-in class Qt, and the implementation of the interfaces is completed by the developer and is linked to the ELF file of the plug-in when compiling the plug-in. The application program only needs to care about the calling of the interfaces and does not need to process other interfaces except the interfaces, thereby ensuring the compatibility of ABI.
It should be noted that, when the Qt application is extended by a plug-in, it needs to use QPluginLoader to load the plug-in, and when in use, the plug-in can provide any functions that you want, without being limited to the plug-in type of Qt function (e.g. database driver, image processing). As shown in fig. 3, fig. 3 is a schematic flowchart illustrating a process of implementing loading of a plug-in through a QPluginLoader class. Firstly, a QPlugilLoader searches plug-in files in a specified directory according to plug-in names; subsequently, the QPluginLoader identifies whether the plug-in needs to be loaded by some judgment, and the specific manner is as follows: if the plug-in file exists and the plug-in is not loaded in the memory, the QPluginLoader loads the plug-in through a dlopen function, and if the plug-in is loaded, the QPluginLoader skips a dlopen link; second, when the program uses the contents of this plug-in, the QPluginLoader looks for a specific symbol in the plug-in via the dlsym function. As described above, this particular symbolic address determines the creation of the plug-in class, and finally the loading and creation of the plug-in is completed by calling this particular symbolic address. The header file < dlfcn.h > states some functions that can manipulate the content of the object symbol, which functions may also be defined as macros. Under Linux, dlopen functions can be used for loading dynamic libraries, and dlsym functions can be used for resolving symbols in the dynamic libraries.
Although the technology can be perfectly applied to most scenes in development, the situation of beauty shortage can occur in some scenes. Such as the scenario described below, in which a significant drawback arises from the reuse of the above technique. For the sake of understanding, we shall define certain terms in the following scenarios, such as that a dynamic library developed based on Qt is referred to as "library L", a Qt plug-in written in dependence on library L is referred to as "plug-in P", and an application developed based on Qt and library L is referred to as "application a".
During the development of Qt, when the library L needs to be updated with a larger magnitude of function, such update will often destroy its original compatibility. In order to avoid the influence on the application using the old version library L, it is necessary to integrate a plurality of different versions of the library L in the system. If the library L at the moment has a plurality of versions, the self plug-in P is loaded implicitly when the Qt library runs, and the plug-in loads the library L which depends on the plug-in P into the memory, wherein the version of the library L which the plug-in P depends on is assumed to be 1.0. When the application A is started, the library L which depends on the application A can be loaded, and if the library L which depends on the application A and the library L which depends on the plug-in P belong to the same version, only one library is stored in the memory, so that the problem can be solved. However, if the library L on which the application A depends is inconsistent with the dependency of the plug-in, cross-dependency between the plug-in and the development library of different versions occurs, as shown in FIG. 4, and FIG. 4 shows a schematic diagram of the running dependency relationship of the application A. It should be noted that in FIG. 4, a → b, illustrates that a is loaded by b, or a depends on b. For example, in FIG. 4, library L1.0 is loaded by plug-in P, or plug-in P depends on library L1.0. In other words, the plug-in depending on the development library of the low version runs in the development library environment of the high version, and different versions of the same development library are loaded and used at the same time, and because the development libraries of multiple versions cannot coexist at the same time, the exception or even running may be generated during the running of the program a.
In order to solve the problems in the prior art, the invention provides a scheme. One embodiment of the present invention provides a method of loading a plug-in an application, which may be executed in a computing device. FIG. 5 shows a block diagram of a computing device 500, according to one embodiment of the invention. As shown in FIG. 5, in a basic configuration 502, computing device 500 typically includes a system memory 506 and one or more processors 504. A memory bus 508 may be used for communicating between the processor 504 and the system memory 506.
Depending on the desired configuration, the processor 504 may be any type of processing, including but not limited to: a microprocessor (μ P), a microcontroller (μ C), a Digital Signal Processor (DSP), or any combination thereof. Processor 504 may include one or more levels of cache, such as a level one cache 510 and a level two cache 512, a processor core 514, and registers 516. Example processor cores 514 may include an Arithmetic Logic Unit (ALU), a Floating Point Unit (FPU), a digital signal processing core (DSP core), or any combination thereof. An example memory controller 518 may be used with processor 504, or in some implementations memory controller 518 may be an internal part of processor 504.
Depending on the desired configuration, system memory 506 may be any type of memory, including but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. The physical memory in the computing device is often referred to as volatile memory RAM, and data in the disk needs to be loaded into the physical memory to be read by the processor 504. System memory 506 may include an operating system 520, one or more applications 522, and program data 524. The application 522 is actually a plurality of program instructions that direct the processor 504 to perform corresponding operations. In some embodiments, the application 522 may be arranged to execute instructions on an operating system with the program data 524 by the one or more processors 504 in some embodiments. Operating system 520 may be, for example, Linux, Windows, etc., which includes program instructions for handling basic system services and performing hardware dependent tasks. The application 522 includes program instructions for implementing various user desired functions, and the application 522 may be, for example, but not limited to, a browser, instant messenger, a software development tool (e.g., an integrated development environment IDE, a compiler, etc.), and the like. When the application 522 is installed into the computing device 500, a driver module may be added to the operating system 520.
When computing device 500 is started, processor 504 reads program instructions for operating system 520 from memory 506 and executes them. Applications 522 run on top of operating system 520 and utilize interfaces provided by operating system 520 and the underlying hardware to implement various user-desired functions. When a user launches application 522, application 522 is loaded into memory 506 and processor 504 reads and executes the program instructions of application 522 from memory 506.
The computing device 500 also includes a storage device 532, the storage device 532 including removable storage 536 and non-removable storage 538, each of the removable storage 536 and non-removable storage 538 being connected to the storage interface bus 534.
Computing device 500 may also include an interface bus 540 that facilitates communication from various interface devices (e.g., output devices 542, peripheral interfaces 544, and communication devices 546) to the basic configuration 502 via the bus/interface controller 530. The example output device 542 includes a graphics processing unit 548 and an audio processing unit 550. They may be configured to facilitate communication with various external devices such as a display or speakers via the one or more a/V ports 552. Example peripheral interfaces 544 may include a serial interface controller 554 and a parallel interface controller 556, which may be configured to facilitate communications with external devices such as input devices (e.g., keyboard, mouse, pen, voice input device, touch input device) or other peripherals (e.g., printer, scanner, etc.) via one or more I/O ports 558. An example communication device 546 may include a network controller 560, which may be arranged to facilitate communications with one or more other computing devices 562 over a network communication link via one or more communication ports 564.
A network communication link may be one example of a communication medium. Communication media may typically be embodied by computer readable instructions, data structures, program modules, and may include any information delivery media, such as carrier waves or other transport mechanisms, in a modulated data signal. A "modulated data signal" may be a signal that has one or more of its data set or its changes in such a manner as to encode information in the signal. By way of non-limiting example, communication media may include wired media such as a wired network or private-wired network, and various wireless media such as acoustic, Radio Frequency (RF), microwave, Infrared (IR), or other wireless media. The term computer readable media as used herein may include both storage media and communication media.
Computing device 500 also includes a storage interface bus 534 that couples to bus/interface controller 530. The storage interface bus 534 is coupled to the storage device 532, and the storage device 532 is adapted to store data. Example storage devices 532 may include removable storage 536 (e.g., CD, DVD, usb-disk, removable hard-disk, etc.) and non-removable storage 538 (e.g., hard-disk drive HDD, etc.).
In a computing device 500 according to the invention, the application 522 includes a plurality of program instructions that perform the method 600.
FIG. 6 shows a flow diagram of a method 600 of loading a plug-in an application according to one embodiment of the invention. Method 600 is suitable for execution in a computing device, such as computing device 500 described previously.
As shown in fig. 6, the method 600 is intended to implement a method for performing plugin documentation in an application, starting at step S602, and in step S602, when a first plugin loading instruction is intercepted, a second plugin that proxies the first plugin is loaded in the application, wherein at least one version of the first plugin resides in a computing device, and the second plugin is associated with each first plugin.
In order to overcome the defect that different versions of the same development library are loaded simultaneously in the prior art, the present invention solves the defect by corresponding plug-ins to the versions of the development libraries one to one, in other words, how many development libraries have plug-ins of several versions, specifically, in some embodiments, first, all versions of development libraries corresponding to an application are obtained. Then, for each version of the development library, a corresponding first plug-in is constructed. The specific construction method of the plug-in may refer to the implementation principle of the Qt dynamic library plug-in mentioned in fig. 2, and is not described herein again. Because the Qt plug-in loading mode of the traditional version cannot judge the version of the plug-in dependence library, the invention provides a design idea to sub-package the Qt plug-ins depending on the development libraries of a plurality of versions, namely to create a plug-in depending on the version for each development library depending on a different version. The advantage of this approach is that it helps the plug-in to perform single dependent hosting, solving the problem of non-single dependence from the plug-in perspective.
In addition, it should be noted that the second plug-in is used as a proxy plug-in for each first plug-in, and when the second plug-in is constructed, the second plug-in is loaded first when the application loads the first plug-in, and at this time, only the application, the development library on which the application depends, and the second plug-in are in the memory, and the problem that different versions of the same development library are loaded at the same time does not occur. And then, the second plug-in determines the target first plug-in matched with the version information through the version information of the development library depended by the application, and loads the target first plug-in into the memory, so that the development library depended by the application and the plug-in is ensured to be the same version when the plug-in is loaded by the application.
In a specific example, as shown in FIG. 7, FIG. 7 shows a proxy mechanism diagram for a second plug-in according to one embodiment of the invention. Referring to fig. 7, each first plug-in of different versions is hosted to a second plug-in, the second plug-in obtains version information of each first plug-in advance, and then obtains version information of a development library on which the application depends in runtime, and loads the corresponding first plug-in, and the proxy plug-in functions as a plug-in distributor and is mainly used for managing version information and forwarding real plug-ins. The second plug-in can dynamically identify the version information of the first plug-in, for the traditional Qt plug-in, the plug-in is designed to be capable of performing sub-package management and dynamic version loading on Qt plug-ins of different versions, the method is an update and breakthrough of the traditional technology, and can help developers to better mark the uniqueness of the version information when developing the plug-ins, so that the dependency of an applied development library has uniqueness and effectiveness, and the single dependency on each first plug-in is realized.
Specifically, first, a second plug-in is constructed based on configuration information of each first plug-in, where the configuration information at least includes an identifier, a storage path, and second version information of each first plug-in. In the present invention, in order to ensure that the plug-in loading mechanism compatible with Qt is compatible, for different plug-ins, the generated name of the proxy plug-in (second plug-in) corresponds to the name of the original Qt plug-in (first plug-in), for example, the name of the second plug-in may be named as plug-cache + the name of the first plug-in, which can ensure that the contents of the plug-cache are loaded into the memory first by the QPluginLoader. Moreover, each first plug-in is generally stored in the same parent directory, which facilitates loading and querying, for example, a/B/first plug-in 1, a/B/first plug-in 2, etc. Therefore, when constructing the second plug-in, in order to facilitate the second plug-in to determine the first plug-in, the absolute path of the second plug-in may be set as the upper directory of the absolute storage path of each first plug-in. Specifically, it is determined whether the storage paths of the first plug-ins have the same upper directory. If yes, setting the absolute storage path of the second plug-in as a superior directory of the absolute storage path of each first plug-in, and creating the second plug-in under the directory. Therefore, after the storage path of the second plug-in is determined, the storage path of the target first plug-in can be obtained only by acquiring the version information of the development library and splicing the storage path with the version information of the development library.
In step S604, first version information of a development library on which the application runtime depends is acquired. Acquiring development library version information is the most important link in designing an agent plug-in, and the requirement for acquiring the correct development library dependent version of the application program is ensured to ensure the uniqueness of dependence. In the invention, two modes for acquiring the first version information of the development library depended by the application during running are provided, and the loading is carried out through the content of the loaded development library and the application mapping path respectively. The two schemes are described below:
in a first aspect, first version information is sought from a loaded development library:
first, a development library that has been currently loaded by the computing device is determined.
And then, acquiring the first version information from the loaded development library by adopting a symbolic address acquisition function. The symbolic address obtaining function is dlsym, and is used for obtaining a certain symbolic address of the running development library and obtaining the version number of the development library. The function code is specifically as follows:
Figure BDA0003610942570000121
in a second aspect, the loading is performed by applying a mapping path:
first, the current process content mapping space of the computing device is read, and all the memory symbol contents are traversed. And traversing all memory symbol contents in the progress content mapping space, namely the/proc/self/maps file, by reading the/proc/self/maps file, acquiring the version information of the current development library and then returning.
Then, the first version information is determined from the memory symbol content.
The specific implementation codes are as follows:
Figure BDA0003610942570000122
Figure BDA0003610942570000131
certainly, in order to avoid failure in acquiring the first version information, the two schemes for acquiring the first version information may be combined to form a dual channel for acquiring the first version information, which is specifically as follows:
first, a development library that has been currently loaded by the computing device is determined.
And then, acquiring the first version information from the loaded development library by adopting a symbolic address acquisition function.
And then, detecting whether the first version information is acquired.
And if not, reading the current process content mapping space of the computing equipment.
And traversing all the memory symbol contents in the process content mapping space.
And finally, determining the first version information from the memory symbol content.
In addition, the scheme of loading the application mapping path may be performed first, and if the acquisition fails, the scheme of searching the first version information from the loaded development library may be performed. Of course, the two first version information acquisition schemes may also be performed simultaneously. This is not a limitation of the present application. As shown in fig. 8, fig. 8 is a schematic diagram illustrating a dual channel acquiring a first version of information according to an embodiment of the present invention. Referring to fig. 8, when the first version information needs to be obtained, the computing device simultaneously executes the scheme of loading the first version information by applying the mapping path and the scheme of finding the first version information from the loaded development library. The first version information is acquired by simultaneously carrying out the two schemes, so that the accuracy of acquiring the version information can be improved.
In step S606, a target first plug-in matching the first version information is determined from the first plug-ins of the at least one version based on the second plug-ins and the first version information. It is mentioned in the foregoing that, when the first cards have the same upper directory, the storage path of the second card is set to the upper directory of each first card. At this time, the absolute storage path of the second plug-in may be directly acquired. And then, splicing the absolute storage path with the first version information to obtain the absolute storage path of the target first plug-in. And finally, determining the target first plug-in based on the absolute storage path of the target first plug-in.
Of course, when the first plugins do not have the same upper directory, since the second plugins already know the storage paths of the first plugins at the time of construction, the first version information can be matched with the second version information of the first plugins. And then, determining the first plug-in corresponding to the successfully matched second version information as a target first plug-in.
In step S608, the target first plug-in is loaded in the application.
It should be noted that, in the present invention, the mode of automatically selecting a plug-in is compatible with the plug-in loading mechanism of Qt. That is, both the conventional Qt plug-in and the multi-version dependent adapted packetizing plug-in can be loaded in the manner of the present invention. The compatibility is achieved by the multi-version selection mechanism described in this section, the specific invocation timing of the plug-in selection mechanism in this case is shown in fig. 9, and fig. 9 shows a schematic diagram of the plug-in selection mechanism according to an embodiment of the present invention. Referring to fig. 9, when a Qt plug-in (first plug-in) needs to be loaded, QPluginLoader first loads an address of a real plug-in (target first plug-in) through the above proxy plug-in (second plug-in), calls a create method in the second plug-in, selects an appropriate plug-in for loading through the proxy plug-in, and finally completes forwarding from the proxy plug-in to the real plug-in through a plug-in selection mechanism.
The following illustrates the working of the plug-in selection mechanism by a simple example code:
Figure BDA0003610942570000141
Figure BDA0003610942570000151
the above codes are part of the implementation in the selection mechanism, and in order to ensure the way of continuously using Qt to load the plug-in, the implementation of the selection mechanism needs to be similar to the way of the original plug-in. In contrast, the create function at this point has completed forwarding for the single dependent plug-in. This is a simple plug-in selection mechanism, and a complex create function can be customized to add more control information. Of course, advanced plug-ins based on Qt may use this approach for multi-version plug-in selection. This is not a limitation of the present application.
In a specific example, as shown in fig. 10, fig. 10 is a flowchart illustrating a method for loading a plug-in an application according to an embodiment of the present invention. The method for loading the plug-in the application specifically comprises the following steps:
1. the application loads the first plug-in.
2. A second plug-in is constructed.
3. The second plug-in obtains its own absolute path.
4. And judging whether the absolute path is successfully acquired, and if so, performing the step 5. Otherwise, the plug-in loading error is indicated.
5. First version information of the development library on which the application depends is sought from the loaded dynamic library.
6. And judging whether the first version information is successfully acquired or not, and if so, performing the step 9. If not, go to step 7.
7. And matching the first version information of the current development library from/proc/self/maps.
8. And judging whether the first version information is successfully matched, if so, performing the step 9. If not, the plug-in loading error is indicated.
9. And splicing the absolute path of the second plug-in with the first version information to form a storage path of the singly dependent target first plug-in.
10. And loading the target first plug-in into the memory.
11. And judging whether the loading is successful, if so, performing step 12. If not, the plug-in loading fails.
12. Successfully loads the plug-in and returns the plug-in pointer.
From the whole point of view, it can be seen that all operations are completed during the operation, when the application starts to load the Qt plug-in, the first one loaded is the proxy plug-in, after all operations of the proxy plug-in are completed, the real plug-in pointer is returned, and the application loads the real plug-in into the memory.
From a local point of view, the agent plug-in first obtains its own absolute path, which is a way to obtain the path of the current library file at runtime. The role of acquiring this path is: this path can help the proxy plugin to access the path to the real plugin, since the real plugin is hosted by the proxy plugin. If the absolute path is successfully obtained, the proxy plugin needs to obtain the version information of other libraries depended by the real plugin, and if the absolute path is not successfully obtained, the proxy plugin directly exits due to loading errors.
The method provided by the invention can dynamically identify the dependent library version of the plug-in by constructing the proxy plug-in when the plug-in is loaded by the application, and performs single dependent loading aiming at the plug-in, thereby solving the phenomenon that different versions of the same development library are loaded simultaneously. Moreover, by the scheme of automatically selecting the version of the Qt plug-in, the real plug-in can be forwarded from the proxy plug-in, and the loading mode of the traditional Qt plug-in and the sub-package plug-in adapting to multi-version dependence is compatible.
The various techniques described herein may be implemented in connection with hardware or software or, alternatively, with a combination of both. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embodied in tangible media, such as removable hard drives, U.S. disks, floppy disks, CD-ROMs, or any other machine-readable storage medium, wherein, when the program is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention.
In the case of program code execution on programmable computers, the computing device will generally include a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. Wherein the memory is configured to store program code; the processor is configured to perform the method of the invention according to instructions in said program code stored in the memory.
By way of example, and not limitation, readable media includes readable storage media and communication media. Readable storage media store information such as computer readable instructions, data structures, program modules or other data. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. Combinations of any of the above are also included within the scope of readable media.
In the description provided herein, algorithms and displays are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems may also be used with examples of this invention. The required structure for constructing such a system is apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose preferred embodiments of the invention.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features 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. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, 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 or units or components of the devices in the examples disclosed herein may be arranged in a device as described in this embodiment or alternatively may be located in one or more devices different from the devices in this example. The modules in the foregoing examples may be combined into one module or may be further divided into multiple sub-modules.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. 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. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
Furthermore, some of the described embodiments are described herein as a method or combination of method elements that can be performed by a processor of a computer system or by other means of performing the described functions. A processor having the necessary instructions for carrying out the method or method elements thus forms a means for carrying out the method or method elements. Further, the elements of the apparatus embodiments described herein are examples of the following apparatus: the means for performing the functions performed by the elements for the purpose of carrying out the invention.
As used herein, unless otherwise specified the use of the ordinal adjectives "first", "second", "third", etc., to describe a common object, merely indicate that different instances of like objects are being referred to, and are not intended to imply that the objects so described must be in a given sequence, either temporally, spatially, in ranking, or in any other manner.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of this description, will appreciate that other embodiments can be devised which do not depart from the scope of the invention as disclosed herein. Moreover, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter. Accordingly, many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the appended claims. The present invention has been disclosed by way of illustration and not limitation with respect to the scope of the invention, which is defined by the appended claims.

Claims (10)

1. A method of loading a plug-in an application, executed in a computing device, the method comprising:
acquiring development libraries of all versions corresponding to the application;
constructing a corresponding first plug-in for the development library of each version;
when a first plug-in loading instruction is monitored, loading a second plug-in which proxies the first plug-in the application, wherein at least one version of the first plug-in resides in the computing equipment, and the second plug-in is associated with each first plug-in;
acquiring first version information of a development library depended by the application in operation;
determining a target first plug-in matched with the first version information from the first plug-ins of the at least one version based on the second plug-ins and the first version information;
loading the target first plug-in the application.
2. The method of claim 1, wherein the step of loading a second plug-in the application that proxies the first plug-in comprises:
constructing the second plug-in based on configuration information of each first plug-in, wherein the configuration information at least comprises an identifier, a storage path and second version information of each first plug-in;
loading the second plug-in with the application.
3. The method of claim 1, wherein the step of obtaining first version information of a development library on which the application runtime depends comprises:
determining a development library currently loaded by the computing device;
and acquiring the first version information from the loaded development library by adopting a symbolic address acquisition function.
4. The method of claim 1, wherein the step of obtaining first version information of a development library on which the application runtime depends comprises:
reading a current process content mapping space of the computing equipment, and traversing all memory symbol contents in the current process content mapping space;
and determining the first version information from the memory symbol content.
5. The method of claim 1, wherein the step of obtaining first version information of a development library on which the application runtime depends comprises:
determining a development library that has been currently loaded by the computing device;
acquiring the first version information from the loaded development library by adopting a symbolic address acquisition function;
detecting whether the first version information is acquired or not;
if not, reading the current process content mapping space of the computing equipment;
traversing all memory symbol contents in the process content mapping space;
and determining the first version information from the memory symbol content.
6. The method of claim 2, wherein the building the second plug-in based on the configuration information of each first plug-in comprises:
judging whether the storage paths of the first plug-ins have the same superior directory or not;
and if so, setting the absolute storage path of the second plug-in as a superior directory of the absolute storage path of each first plug-in, and creating the second plug-in under the directory.
7. The method of claim 6, wherein the step of determining a target first plug-in from each first plug-in that matches the first version information based on the second plug-in and the first version information comprises:
acquiring an absolute storage path of the second plug-in;
splicing the absolute storage path with the first version information to obtain an absolute storage path of the target first plug-in;
and determining the target first plug-in based on the absolute storage path of the target first plug-in.
8. The method of claim 2, wherein the step of determining a target first plug-in from each first plug-in that matches the first version information based on the second plug-in and the first version information comprises:
judging whether the storage paths of the first plug-ins have the same superior directory or not;
if not, matching the first version information with second version information of each first plug-in;
and determining the first plug-in corresponding to the successfully matched second version information as the target first plug-in.
9. A computing device, comprising:
at least one processor; and
a memory having stored thereon program instructions configured to be executed by the at least one processor, the program instructions comprising instructions for performing the method of any one of claims 1-8.
10. A readable storage medium storing program instructions that, when read and executed by a computing device, cause the computing device to perform the method of any of claims 1-8.
CN202210431692.XA 2022-01-25 2022-01-25 Method for loading plug-in application, computing device and storage medium Active CN114780173B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210431692.XA CN114780173B (en) 2022-01-25 2022-01-25 Method for loading plug-in application, computing device and storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210431692.XA CN114780173B (en) 2022-01-25 2022-01-25 Method for loading plug-in application, computing device and storage medium
CN202210083574.4A CN114138376B (en) 2022-01-25 2022-01-25 Method for loading plug-in application, computing equipment and storage medium

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN202210083574.4A Division CN114138376B (en) 2022-01-25 2022-01-25 Method for loading plug-in application, computing equipment and storage medium

Publications (2)

Publication Number Publication Date
CN114780173A true CN114780173A (en) 2022-07-22
CN114780173B CN114780173B (en) 2023-12-05

Family

ID=80381556

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202210083574.4A Active CN114138376B (en) 2022-01-25 2022-01-25 Method for loading plug-in application, computing equipment and storage medium
CN202210431692.XA Active CN114780173B (en) 2022-01-25 2022-01-25 Method for loading plug-in application, computing device and storage medium

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN202210083574.4A Active CN114138376B (en) 2022-01-25 2022-01-25 Method for loading plug-in application, computing equipment and storage medium

Country Status (1)

Country Link
CN (2) CN114138376B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114138376B (en) * 2022-01-25 2022-06-24 统信软件技术有限公司 Method for loading plug-in application, computing equipment and storage medium

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106325921A (en) * 2016-08-16 2017-01-11 北京奇虎科技有限公司 Method and device for releasing associated plugins
CN106354832A (en) * 2016-08-31 2017-01-25 广州品唯软件有限公司 System, equipment and method for data release
CN108197020A (en) * 2017-12-28 2018-06-22 掌阅科技股份有限公司 Plug-in unit method of calibration, electronic equipment and computer storage media
US20180321956A1 (en) * 2017-05-02 2018-11-08 Kai-Ting Amy Wang Multi-version asynchronous dynamic software update system and method for applications with multiple threads
CN111857860A (en) * 2019-04-30 2020-10-30 烽火通信科技股份有限公司 Method and system for realizing safe loading of plug-in
US20200379781A1 (en) * 2019-05-28 2020-12-03 Netapp, Inc. Methods and systems for plugin development in a networked computing environment
CN112667306A (en) * 2019-10-15 2021-04-16 华为终端有限公司 Method, device and storage medium for installing plug-in
CN113760313A (en) * 2020-06-05 2021-12-07 中兴通讯股份有限公司 Method, device and equipment for upgrading cloud platform, cloud platform system and storage medium
CN114138376B (en) * 2022-01-25 2022-06-24 统信软件技术有限公司 Method for loading plug-in application, computing equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014159943A2 (en) * 2013-03-14 2014-10-02 Bitvore Corp. Dynamically loaded plugin architecture
CN110134457A (en) * 2019-04-17 2019-08-16 深圳壹账通智能科技有限公司 Plug-in loading method and device

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106325921A (en) * 2016-08-16 2017-01-11 北京奇虎科技有限公司 Method and device for releasing associated plugins
CN106354832A (en) * 2016-08-31 2017-01-25 广州品唯软件有限公司 System, equipment and method for data release
US20180321956A1 (en) * 2017-05-02 2018-11-08 Kai-Ting Amy Wang Multi-version asynchronous dynamic software update system and method for applications with multiple threads
CN108197020A (en) * 2017-12-28 2018-06-22 掌阅科技股份有限公司 Plug-in unit method of calibration, electronic equipment and computer storage media
CN111857860A (en) * 2019-04-30 2020-10-30 烽火通信科技股份有限公司 Method and system for realizing safe loading of plug-in
US20200379781A1 (en) * 2019-05-28 2020-12-03 Netapp, Inc. Methods and systems for plugin development in a networked computing environment
CN112667306A (en) * 2019-10-15 2021-04-16 华为终端有限公司 Method, device and storage medium for installing plug-in
CN113760313A (en) * 2020-06-05 2021-12-07 中兴通讯股份有限公司 Method, device and equipment for upgrading cloud platform, cloud platform system and storage medium
CN114138376B (en) * 2022-01-25 2022-06-24 统信软件技术有限公司 Method for loading plug-in application, computing equipment and storage medium

Also Published As

Publication number Publication date
CN114138376B (en) 2022-06-24
CN114138376A (en) 2022-03-04
CN114780173B (en) 2023-12-05

Similar Documents

Publication Publication Date Title
EP1577767B1 (en) Code rewriting
US9183007B2 (en) Dynamic determination of application server runtime classloading
JP4878715B2 (en) Method, computer system and computer readable recording medium for patching applications that do not conform to operating system
US8266588B2 (en) Creating projects in a rational application developer workspace
JPH0836488A (en) Method and device for checking run-time error using dynamic patching
KR20150024842A (en) Adaptive portable libraries
US20160292450A1 (en) System and method for controlling access of machine code to operating system resources
CN114816417B (en) Cross compiling method, device, computing equipment and storage medium
CN114691240A (en) Drive hardware configuration information loading method, device and system and computing equipment
CN114924810B (en) Heterogeneous program execution method, heterogeneous program execution device, computing equipment and readable storage medium
CN102364433B (en) Method for realizing Wine construction tool transplanting on ARM (Advanced RISC Machines) processor
CN114138376B (en) Method for loading plug-in application, computing equipment and storage medium
CN109558121A (en) Development approach, device, equipment and the storage medium of interface drive program
CN113805971B (en) Application program running method, computing device and storage medium
CN113821272B (en) Application program running method, computing device and storage medium
US10175966B2 (en) Linker rewriting to eliminate TOC pointer references
CN113641389B (en) Software upgrading method, device and equipment based on OpenCPU
CN111949301B (en) Application program hot update method, device and computer readable storage medium
US20180196676A1 (en) Reduced save and restore instructions for call-clobbered registers
CN111209056B (en) Method and device for loading function, readable storage medium and electronic equipment
CN115794260B (en) Simple dynamic loading method for DSP software library
EP4350504A1 (en) Cross-linking method and apparatus, electronic device, and storage medium
US20050114633A1 (en) Method and system for executing data-relative code within a non data-relative environment
CN114866451B (en) iOS end route communication improvement method, device, storage medium and equipment
AU2016100581A4 (en) Compilation method for linking region-specific computer logic

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
GR01 Patent grant
GR01 Patent grant