[go: up one dir, main page]

CN111625378B - Remote source code checking method and device - Google Patents

Remote source code checking method and device Download PDF

Info

Publication number
CN111625378B
CN111625378B CN202010469941.5A CN202010469941A CN111625378B CN 111625378 B CN111625378 B CN 111625378B CN 202010469941 A CN202010469941 A CN 202010469941A CN 111625378 B CN111625378 B CN 111625378B
Authority
CN
China
Prior art keywords
target
port
class
source code
remote
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.)
Active
Application number
CN202010469941.5A
Other languages
Chinese (zh)
Other versions
CN111625378A (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.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information 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 Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN202010469941.5A priority Critical patent/CN111625378B/en
Publication of CN111625378A publication Critical patent/CN111625378A/en
Application granted granted Critical
Publication of CN111625378B publication Critical patent/CN111625378B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • G06F9/548Object oriented; Remote method invocation [RMI]
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/53Decompilation; Disassembly
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/544Remote

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the disclosure provides a remote source code viewing method, a remote source code viewing device, electronic equipment and a storage medium. And pre-programming an agent program comprising port starting logic and decompilation tool calling logic, and establishing a communication channel between the agent program and the target process so as to acquire class information of the target process through the communication channel. And receiving the target class of the target process selected by the remote equipment user through a designated port started by the agent program, calling a decompilation tool to acquire the source code of the target class, and finally transmitting the source code to the remote equipment through the designated port so as to facilitate remote viewing. The scheme can support the user to select the target class in the remote equipment, and automatically return the corresponding source code to the remote equipment for viewing, so that the operation is simple and convenient, and the time consumption is short.

Description

Remote source code checking method and device
Technical Field
The disclosure relates to the technical field of computers, and in particular relates to a remote source code viewing method, a remote source code viewing device, electronic equipment and a storage medium.
Background
After modifying the code and deploying the new code corresponding to the service to the on-line device, the developer sometimes needs to confirm whether the service currently running on the device has used the corresponding correct code.
But the service that is deployed is completed using compiled bytecode, whose corresponding source code is not viewable. In the conventional scheme, source codes are also commonly packaged in a packaging deployment, and when the source code of a certain service needs to be confirmed, the corresponding package is decompressed by using an online device and the source code is checked.
The traditional scheme increases the operation cost of packing and occupies more memory resources of on-line equipment. The whole source code checking process is also complex, a developer needs to decompress the storage path of the project package in the online equipment, the project package needs to be decompressed to a certain folder during checking, and then the project package is checked according to the name of the project package after entering the folder, so that the operation is complex and the time is long.
Disclosure of Invention
Aiming at the technical problems, the embodiment of the disclosure provides a remote source code checking method, which comprises the following steps:
according to a first aspect of an embodiment of the present disclosure, there is provided a source code remote viewing method, which configures an agent in a target device operated by a target process, the method including:
after a communication channel is established between the agent program and the target process, a designated port of the target device is started;
receiving a target class in a target process selected by a user through remote equipment through the designated port, and acquiring a byte code corresponding to the target class through the communication channel;
Invoking a decompilation tool pre-configured in target equipment to decompilate the byte code so as to acquire a source code corresponding to the byte code;
and sending the source code to remote equipment for display through the designated port.
Optionally, the agent is a Java agent, and a communication channel is established between the agent and the target process, including:
And establishing a communication channel between the Java agent program and the target process by utilizing the Attach function provided by the Java virtual machine.
Optionally, the designated port of the target device is an HTTP port of the target device, and the receiving, by the designated port, the target class in the target process selected by the user through the remote device includes:
Receiving a viewing instruction of a target class input by a user on a WEB page through an HTTP port, wherein the viewing instruction of the target class at least comprises a class identifier of the target class, an IP address of target equipment and a port number of the HTTP port.
Optionally, the designated port of the target device is an HTTP port of the target device, and the sending the source code to the remote device for presentation through the designated port includes:
and transmitting the source code to a WEB page of the remote equipment through an HTTP port, and displaying the source code through the WEB page.
Optionally, after the designated port of the target device is started, the method further includes:
Determining the loaded class in the target process;
Based on a preset showing policy, showing the loaded class on a WEB page of the remote device through a designated port so as to enable a user to select a target class to be checked, wherein the preset showing policy at least comprises: the loaded classes of the specified type are exposed, or the loaded classes are exposed in a specified order.
According to a second aspect of embodiments of the present disclosure, there is provided a source code remote viewing apparatus that configures an agent in a target device on which a target process is running, the apparatus comprising:
The port starting module is configured to start a designated port of the target device after a communication channel is established between the control agent program and the target process;
The information receiving module is configured to receive a target class in a target process selected by a user through the remote equipment through the designated port, and acquire byte codes corresponding to the target class through the communication channel;
The decompilation module is configured to call a decompilation tool pre-configured in the target equipment to decompil the byte code so as to acquire a source code corresponding to the byte code;
And the information sending module is configured to send the source code to a remote device for display through the designated port.
Optionally, the agent is a Java agent, and the port start module is configured to, when a communication channel is established between the agent and the target process:
And establishing a communication channel between the Java agent program and the target process by utilizing the Attach function provided by the Java virtual machine.
Optionally, the designated port of the target device is an HTTP port of the target device, and the information receiving module, when receiving, through the designated port, a target class in a target process selected by a user through a remote device, is configured to:
Receiving a viewing instruction of a target class input by a user on a WEB page through an HTTP port, wherein the viewing instruction of the target class at least comprises a class identifier of the target class, an IP address of target equipment and a port number of the HTTP port.
Optionally, the designated port of the target device is an HTTP port of the target device, and when the source code is sent to the remote device through the designated port to be displayed, the information sending module is configured to:
and transmitting the source code to a WEB page of the remote equipment through an HTTP port, and displaying the source code through the WEB page.
Optionally, the apparatus further includes a class information display module configured to:
Determining the loaded class in the target process;
Based on a preset showing policy, showing the loaded class on a WEB page of the remote device through a designated port so as to enable a user to select a target class to be checked, wherein the preset showing policy at least comprises: the loaded classes of the specified type are exposed, or the loaded classes are exposed in a specified order.
According to a third aspect of embodiments of the present disclosure, there is provided an electronic device, comprising: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the method according to the first aspect.
According to a fourth aspect of embodiments of the present disclosure, there is provided a storage medium, which when executed by a processor of an electronic device, enables the electronic device to perform the method as described in the first aspect.
The embodiment of the disclosure provides a remote source code viewing method, a remote source code viewing device, electronic equipment and a storage medium. And pre-programming an agent program comprising port starting logic and decompilation tool calling logic, and establishing a communication channel between the agent program and the target process so as to acquire class information of the target process through the communication channel. And receiving the target class of the target process selected by the remote equipment user through a designated port started by the agent program, calling a decompilation tool to acquire the source code of the target class, and finally transmitting the source code to the remote equipment through the designated port so as to facilitate remote viewing. The scheme can support the user to select the target class in the remote equipment, and automatically return the corresponding source code to the remote equipment for viewing, so that the operation is simple and convenient, and the time consumption is short.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of embodiments of the disclosure.
Moreover, not all of the above-described effects need be achieved by any of the embodiments of the present disclosure.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the following description will briefly introduce the drawings that are required to be used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are only some embodiments described in the embodiments of the present disclosure, and other drawings may also be obtained according to these drawings for a person having ordinary skill in the art.
FIG. 1 is a flow chart of a source code remote viewing method shown in an exemplary embodiment of the present disclosure;
FIG. 2 is a schematic diagram of a remote device and target device connection relationship as illustrated in an exemplary embodiment of the present disclosure;
FIG. 3 is another flow chart of a source code remote viewing method shown in an exemplary embodiment of the present disclosure;
FIG. 4 is another flow chart of a source code remote viewing method shown in an exemplary embodiment of the present disclosure;
FIG. 5 is another schematic diagram of a remote device and target device connection relationship shown in an exemplary embodiment of the present disclosure;
FIG. 6 is an interactive schematic diagram of a source code remote viewing method shown in an exemplary embodiment of the present disclosure;
FIG. 7 is a schematic diagram of a source code remote viewing device shown in an exemplary embodiment of the present disclosure;
Fig. 8 is a schematic diagram of an electronic device shown in an exemplary embodiment of the present disclosure.
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
The terminology used in the present disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. As used in this disclosure and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used in this disclosure to describe various information, these information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present disclosure. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "in response to a determination" depending on the context.
After modifying the code and deploying the new code corresponding to the service to the on-line device, the developer sometimes needs to confirm whether the service currently running on the device has used the corresponding correct code.
But the service that is deployed is completed using compiled bytecode, whose corresponding source code is not viewable. In the conventional scheme, source codes are also commonly packaged in a packaging deployment, and when the source code of a certain service needs to be confirmed, the corresponding package is decompressed by using an online device and the source code is checked.
The traditional scheme increases the operation cost of packing and occupies more memory resources of on-line equipment. The whole source code checking process is also complex, a developer needs to decompress the storage path of the project package in the online equipment, the project package needs to be decompressed to a certain folder during checking, and then the project package is checked according to the name of the project package after entering the folder, so that the operation is complex and the time is long.
To solve this problem, the present disclosure provides a source code remote viewing method, and a source code remote viewing apparatus applying the source code remote viewing method. The method is mainly aimed at programs written by Java (an object-oriented programming language) language. Embodiments of the present disclosure are described in further detail below with reference to the drawings attached hereto.
Firstly, a method for remotely checking source codes provided by the present disclosure is described, and the method needs to configure an agent program in a target device operated by a target process, referring to fig. 1, and includes the following steps S101 to S103:
In step S101, after a communication channel is established between the agent program and the target process, a designated port of the target device is started;
Wherein both the agent and the target process are configured and run on the target device, and a communication channel is established between the agent and the target process.
In an embodiment of the present disclosure, the agent may be a Java agent, and the communication channel between the agent and the target process may be a communication channel established between the Java agent and the target process through an Attach function of the JVM.
Specifically, the process of starting the Java agent program is: the Java agent program is started by an attach method of a virtual machine class. One category is in the tools. Jar toolkit provided by the SUM function, known as the VirtualMachine. The Java agent program can be started by an attach method of a virtual machine class, and the Java agent program can be attached to a designated JVM (Java Virtual Machine ) process.
The JVM process is referred to as the target process in the embodiments of the present disclosure. After the Java agent program is written, a jar file is formed. And loading the jar file by using a loadAgent method of an attach function package, so that the Java agent program can attach to the target process based on the attach method.
After the Java agent program is attached to the target process based on the attach method, a communication channel is established between the Java agent program and the target process. The Java agent program can communicate with the target process based on the communication channel, and can acquire/modify various data in the target process.
In step S102, receiving, through the designated port, a target class in a target process selected by a user through a remote device, and acquiring, through the communication channel, a bytecode corresponding to the target class;
In an embodiment of the present disclosure, the receiving, through the designated port, the target class in the target process selected by the user may be one of the following manners, but is not limited to the following manners;
a) And receiving an input command of a user through a command routine, and determining a target class in a target process based on the input command.
Specifically, the logic in the agent is preconfigured, which may be pre-written with user command receiving logic that may receive a target class of a user in a target process selected by the remote device through a designated port. One embodiment is to launch a command line program that provides the user with an input interface for the target class by invoking the command line program. Illustrating: the user may specify the target class by entering a command line (device IP port number class identification) in the command line program.
In an embodiment of the present disclosure, when step S102 is performed, the following manner may be adopted:
(1-1) the remote device starts a command procedure and receives a source code viewing instruction input by a user, wherein the input source code viewing instruction comprises a class identifier of a target class, an IP address of the target device and a port number of an HTTP port;
(1-2) establishing communication with the target device according to the IP address of the target device and the port number of the HTTP port, and notifying the agent in the target device of the class identification of the target class;
(1-3) the agent obtaining the bytecode of the target class of the target process through a communication channel pre-established with the target process.
B) And receiving an input command of a user through the WEB page, and determining a target class in a target process based on the input command.
In one embodiment of the present disclosure, the designated port for agent initiation may be an HTTP port, which may typically be an 80 port of a computer.
When the started designated port is an HTTP port, the remote device can establish HTTP communication with the target device through the port, namely, aiming at the target process, the remote device can input information of a target class needing to check the source code through a WEB page, notify an agent program of the target device through the HTTP port, and communicate with the remote device through the HTTP port after the agent program obtains the source code of the target class, and the source code is displayed on the WEB page of the remote device through the HTTP port.
In an embodiment of the present disclosure, when performing step S102, the following manner may also be adopted:
(2-1) the remote device starts a WEB page and receives a source code viewing instruction input by a user based on an input box of the WEB page, wherein the input source code viewing instruction comprises a class identifier of a target class, an IP address of the target device and a port number of an HTTP port;
(2-2) establishing communication with the target device according to the IP address of the target device and the port number of the HTTP port, and notifying the agent in the target device of the class identification of the target class;
(2-3) the agent obtaining the bytecode of the target class of the target process through a communication channel pre-established with the target process.
In step S103, a decompilation tool pre-configured in a target device is called to perform a decompilation operation on the bytecode, so as to obtain a source code corresponding to the bytecode;
It is known that the high-level language source program generates an executable file after compiling, and decompilation is the inverse process of compiling. In the Java environment, compilation is the conversion of source code into bytecodes, and back-translation is the conversion of bytecodes into source code that can be read by a developer. The code written by a developer when writing Java programs is the source code, the source code can be read only when reading, and the byte code is a binary file formed by a sequence of op code/data pairs and is difficult to read and understand.
In the agent program, the calling logic of the decompilation tool is pre-configured, after receiving the target class information sent by the remote device through the designated port, the agent program obtains the byte code of the target class in the target process, and calls the decompilation tool to decompil the byte code, wherein the decompilation tool can be a decompilation component Procyon and the like.
In step S104, the source code is sent to a remote device for presentation through the specified port.
Logic in the agent is preconfigured, which may be pre-written with user command receiving logic that may receive a target class of a user in a target process selected by the remote device through a designated port. In addition to starting the command line program, another implementation method is to start a WEB page, provide an input interface of a target class for a user by calling the WEB page, and display returned source codes by using the WEB page. The method has the advantages that the source code is displayed by using the WEB page, the reading is more convenient, the display format of the source code can be adjusted based on the parameter adjustment function of the WEB page,
For a more specific relationship among the remote device, the target device, the agent, and the target process, referring to fig. 2, a WEB page is taken as an example for the target device to start, which is described as follows:
Target device: the target device is a device where the target process is running, and the target device may be an online device running an online item or a test device running an item in a test. The agent corresponding to the target process is also configured on the target device, and a communication channel is established between the agent and the target process.
Remote device: the remote device is a device used by the user when viewing the source code, and belongs to a different device from the target device, and in general, the remote device may be a general computer device.
Namely, the specific way of determining the target class in the target process selected by the user is as follows: the class identifier and the method identifier input by the user are received through a command line program or a WEB page, and the class identifier and the method identifier can be a class identifier name and a method name or a class ID and a method ID. And searching a corresponding target method in the target process according to the input data.
The method comprises the steps that a target class input by a user at a remote device is received through a designated port, and the user only needs to input target equipment for checking a source code in the remote device, and the source code of the target class can be obtained through the designated port and the target class. The user does not need to go to the machine room to operate the target equipment, the source code is not required to be packaged and placed at the corresponding position of the execution service in the target equipment, and the checking efficiency is high.
FIG. 3 is a flowchart of another source code remote viewing method that may be used on a platform capable of executing the source code remote viewing method and that is based on the method of FIG. 1, as shown in FIG. 3, may include the following steps S301-S303:
in step S301, after a communication channel is established between the Java agent program and the target process, a designated port of the target device is started;
in step S302, determining a class that has been loaded in the target process;
In step S303, the loaded class is displayed on the WEB page of the remote device through the designated port based on the predetermined display policy, so that the user selects the target class to be viewed therein.
After agent attch is brought to the target process, the loaded class of the target process can be viewed using the Instrumentation function. Based on this, the embodiment may obtain the loaded classes, and display the loaded classes through a predetermined display policy, so as to facilitate the user to view and select, where the predetermined display policy may at least include: the loaded classes of the specified type are exposed, or the loaded classes are exposed in a specified order.
The Java Instrumentation function may go through the agent attch to the specified process and obtain information of all loaded classes of the specified process, including class names, class bytecodes, and so forth. When the user operates the remote device and inputs a class that needs to view the source code, all classes that the target process has loaded may be acquired in advance through the Instrumentation function. Specifically, there is Instrumentation inst instance in the java.lang.instrument package of JDK. The Instrumentation inst instance is automatically imported by the JVM at program runtime. By way of example, various interfaces provided by Instrumentation may be invoked. In one embodiment of the present disclosure, the loaded class in the returned target process may be obtained by calling the inst.getallloadclass () interface provided by Instrumentation.
The user can input the IP address of the target device and the process identification of the target process on the WEB page of the remote device, and the agent program displays the loaded class of the target process on the WEB page of the remote device through the Http port after acquiring the input information of the user based on the Http port. Further, the display order of the classes can be set on the WEB page based on a preset display strategy, or only certain types of classes can be displayed, or the WEB page can be preset to have a class screening function, and the like.
The agent is configured on a target device on which the target process is running. Specifically, the agent program may be pre-configured, and the configured agent program includes startup logic of a designated port and call logic of a decompilation tool. After the configuration is completed, the agent program is packaged into a new JAR (Java Archive file) package, and then the JAR package of the agent program is put under the LIB (library file) directory of the target process, so that the agent program can be configured in the target device.
Therefore, the embodiment of the disclosure provides a remote source code viewing method, which can be used by putting a new JAR (Java Archive) package, namely the JAR package of the agent program, under the LIB (library file) directory of the target program without any adaptive change to the existing system, and is convenient to implement.
Referring to fig. 4, a more specific remote view method of source code provided for the present disclosure includes the following steps S401 to S405:
In step S401, a pre-written Java agent program is acquired, and a communication channel is established between the Java agent program and a target process by using an Attach function provided by a Java virtual machine;
In step S402, in response to the execution result of the Java agent program, the HTTP port of the target device is started;
in step S403, a viewing instruction of a target class input by a user on a WEB page is received through an HTTP port, where the viewing instruction of the target class includes at least a class identifier of the target class, an IP address of the target device, and a port number of the HTTP port.
In step S404, a decompilation tool pre-configured in a target device is called to perform a decompilation operation on the bytecode, so as to obtain a source code corresponding to the bytecode;
In particular, the decompilation tool may be any tool having bytecode decompilation functionality, e.g., the decompilation tool may be decompilation component Procyon, and the disclosure is not limited to the particular decompilation tool used.
In step S405, the source code is transmitted to a WEB page of a remote device through an HTTP port, and the source code is displayed through the WEB page.
In the method provided by the embodiment of the disclosure, an agent program comprising port starting logic and decompilation tool calling logic is pre-written, and a communication channel is established between the agent program and a target process, so that class information of the target process is obtained through the communication channel. And receiving the target class of the target process selected by the remote equipment user through a designated port started by the agent program, calling a decompilation tool to acquire the source code of the target class, and finally transmitting the source code to the remote equipment through the designated port so as to facilitate remote viewing. The scheme can support the user to select the target class in the remote equipment, and automatically return the corresponding source code to the remote equipment for viewing, so that the operation is simple and convenient, and the time consumption is short.
Taking a decompilation tool as an example Procyon, a specific description is given of the overall structure and interaction of the solution in practical application, referring to fig. 5 and fig. 6, it can be seen that a target process runs on a target device, and a Java agent program includes an Instrumentation function and Procyon component calling logic. Firstly, an agent program attch is sent to a designated target process based on an Instrumentation function to establish an agent, then an HTTP port is started, class information of source codes to be checked, which is sent by a remote device WEB page through the HTTP port, is received, byte codes of the classes are obtained, a decompilation tool Procyon is called to decompil the byte codes of the classes, and finally the source codes obtained after decompilation are displayed through the WEB page.
Corresponding to the above method embodiment, the embodiment of the present disclosure further provides a target source code remote viewing device, as shown in fig. 7, where the device may include: a port initiation module 710, an information reception module 720, a decompilation module 730, and an information transmission module 740.
The port starting module 710 is configured to start a designated port of the target device after the communication channel is established between the control agent and the target process;
The information receiving module 720 is configured to receive a target class in a target process selected by a user through the remote device through the designated port, and acquire a byte code corresponding to the target class through the communication channel;
the decompilation module 730 is configured to invoke a decompilation tool configured in advance in the target device to decompil the bytecode, so as to obtain a source code corresponding to the bytecode;
and the information sending module 740 is configured to send the source code to a remote device for presentation through the designated port.
Optionally, the agent is a Java agent, and the port start module is configured to, when a communication channel is established between the agent and the target process:
And establishing a communication channel between the Java agent program and the target process by utilizing the Attach function provided by the Java virtual machine.
Optionally, the designated port of the target device is an HTTP port of the target device, and the information receiving module, when receiving, through the designated port, a target class in a target process selected by a user through a remote device, is configured to:
Receiving a viewing instruction of a target class input by a user on a WEB page through an HTTP port, wherein the viewing instruction of the target class at least comprises a class identifier of the target class, an IP address of target equipment and a port number of the HTTP port.
Optionally, the designated port of the target device is an HTTP port of the target device, and when the source code is sent to the remote device through the designated port to be displayed, the information sending module is configured to:
and transmitting the source code to a WEB page of the remote equipment through an HTTP port, and displaying the source code through the WEB page.
Optionally, the agent program is a Java agent program, and the apparatus further includes a class information presentation module configured to:
Determining the loaded class in the target process;
And displaying the loaded class on a WEB page of the remote equipment through a designated port based on a preset display strategy so as to enable a user to select a target class to be viewed, wherein the preset display strategy at least comprises the following steps: the loaded classes of the specified type are exposed, or the loaded classes are exposed in a specified order.
The embodiment of the disclosure also provides an electronic device, which at least includes a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein the processor implements the foregoing source code remote viewing method when executing the program, and the method configures an agent program in a target device operated by a target process, and the method includes:
after a communication channel is established between the agent program and the target process, a designated port of the target device is started;
receiving a target class in a target process selected by a user through remote equipment through the designated port, and acquiring a byte code corresponding to the target class through the communication channel;
Invoking a decompilation tool pre-configured in target equipment to decompilate the byte code so as to acquire a source code corresponding to the byte code;
and sending the source code to remote equipment for display through the designated port.
Fig. 8 shows a schematic block diagram of a master-side based electronic device according to an exemplary embodiment of the present disclosure. Referring to fig. 8, at a hardware level, the electronic device includes a processor 802, an internal bus 804, a network interface 806, a memory 804, and a nonvolatile memory 810, and may include hardware required by other services. The processor 802 reads the corresponding computer program from the nonvolatile memory 810 into the memory 802 and then runs, forming a means for executing the source code remote viewing method on a logical level. Of course, other implementations, such as logic devices or combinations of hardware and software, are not excluded from the disclosure, that is, the execution subject of the following process flows is not limited to each logic unit, but may be hardware or logic devices.
The disclosed embodiments also provide a computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the foregoing source code remote viewing method, the method configuring a proxy program in a target device operated by a target process, the method comprising:
after a communication channel is established between the agent program and the target process, a designated port of the target device is started;
receiving a target class in a target process selected by a user through remote equipment through the designated port, and acquiring a byte code corresponding to the target class through the communication channel;
Invoking a decompilation tool pre-configured in target equipment to decompilate the byte code so as to acquire a source code corresponding to the byte code;
and sending the source code to remote equipment for display through the designated port.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
For the device embodiments, reference is made to the description of the method embodiments for the relevant points, since they essentially correspond to the method embodiments. The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the objectives of the disclosed solution. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. A typical implementation device is a computer, which may be in the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or a combination of any of these devices.
The foregoing is merely a specific implementation of the embodiments of this disclosure, and it should be noted that, for a person skilled in the art, several improvements and modifications may be made without departing from the principles of the embodiments of this disclosure, which should also be considered as the protection scope of the embodiments of this disclosure.

Claims (12)

1. A source code remote viewing method, wherein an agent is configured in a target device operated by a target process, the agent comprising port initiation logic and decompilation tool call logic, the method comprising:
after a communication channel is established between the agent program and the target process, a designated port of the target device is started through the port starting logic;
receiving a target class in a target process selected by a user through remote equipment through the designated port, and acquiring a byte code corresponding to the target class through the communication channel;
performing decompilation operation on the byte code by using a decompilation tool which is configured in advance in the target equipment through the decompilation tool bar by using logic to acquire a source code corresponding to the byte code;
and sending the source code to remote equipment for display through the designated port.
2. The method of claim 1, wherein the agent is a Java agent, the establishing a communication channel between the agent and the target process comprises:
And establishing a communication channel between the Java agent program and the target process by utilizing the Attach function provided by the Java virtual machine.
3. The method of claim 1, wherein the designated port of the target device is an HTTP port of the target device, the receiving, through the designated port, a target class in a target process selected by a user through a remote device, comprising:
Receiving a viewing instruction of a target class input by a user on a WEB page through an HTTP port, wherein the viewing instruction of the target class at least comprises a class identifier of the target class, an IP address of target equipment and a port number of the HTTP port.
4. The method of claim 1, wherein the designated port of the target device is an HTTP port of the target device, and wherein the sending the source code to the remote device for presentation via the designated port comprises:
and transmitting the source code to a WEB page of the remote equipment through an HTTP port, and displaying the source code through the WEB page.
5. The method of claim 1, wherein after the designated port of the target device is started, further comprising:
Determining the loaded class in the target process;
Based on a preset showing policy, showing the loaded class on a WEB page of the remote device through a designated port so as to enable a user to select a target class to be checked, wherein the preset showing policy at least comprises: the loaded classes of the specified type are exposed, or the loaded classes are exposed in a specified order.
6. A source code remote viewing apparatus, wherein an agent is configured in a target device on which a target process is running, the agent comprising port launch logic and decompilation tool call logic, the apparatus comprising:
The port starting module is configured to start a designated port of the target device through the port starting logic after a communication channel is established between the control agent program and the target process;
The information receiving module is configured to receive a target class in a target process selected by a user through the remote equipment through the designated port, and acquire byte codes corresponding to the target class through the communication channel;
the decompilation module is configured to call a logic call target device to perform decompilation operation on the byte codes through a decompilation tool call logic so as to obtain source codes corresponding to the byte codes;
And the information sending module is configured to send the source code to a remote device for display through the designated port.
7. The apparatus of claim 6, wherein the agent is a Java agent, and the port initiation module, when establishing a communication channel between the agent and the target process, is configured to:
And establishing a communication channel between the Java agent program and the target process by utilizing the Attach function provided by the Java virtual machine.
8. The apparatus of claim 6, wherein the designated port of the target device is an HTTP port of the target device, and wherein the information receiving module, when receiving, through the designated port, a target class in a target process selected by a user through a remote device, is configured to:
Receiving a viewing instruction of a target class input by a user on a WEB page through an HTTP port, wherein the viewing instruction of the target class at least comprises a class identifier of the target class, an IP address of target equipment and a port number of the HTTP port.
9. The apparatus of claim 6, wherein the designated port of the target device is an HTTP port of the target device, and wherein the information sending module, when sending the source code to a remote device for presentation via the designated port, is configured to:
and transmitting the source code to a WEB page of the remote equipment through an HTTP port, and displaying the source code through the WEB page.
10. The apparatus of claim 6, wherein the apparatus further comprises a class information presentation module configured to:
Determining the loaded class in the target process;
Based on a preset showing policy, showing the loaded class on a WEB page of the remote device through a designated port so as to enable a user to select a target class to be checked, wherein the preset showing policy at least comprises: the loaded classes of the specified type are exposed, or the loaded classes are exposed in a specified order.
11. An electronic device, comprising: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the method of any one of claims 1 to 5.
12. A storage medium, characterized in that instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the method of any one of claims 1 to 5.
CN202010469941.5A 2020-05-28 2020-05-28 Remote source code checking method and device Active CN111625378B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010469941.5A CN111625378B (en) 2020-05-28 2020-05-28 Remote source code checking method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010469941.5A CN111625378B (en) 2020-05-28 2020-05-28 Remote source code checking method and device

Publications (2)

Publication Number Publication Date
CN111625378A CN111625378A (en) 2020-09-04
CN111625378B true CN111625378B (en) 2024-07-23

Family

ID=72272909

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010469941.5A Active CN111625378B (en) 2020-05-28 2020-05-28 Remote source code checking method and device

Country Status (1)

Country Link
CN (1) CN111625378B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112256448B (en) * 2020-09-30 2024-07-30 北京达佳互联信息技术有限公司 Remote control method, device, electronic equipment, system and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102195970A (en) * 2010-03-10 2011-09-21 微软公司 Client session based debugging
CN104871172A (en) * 2012-10-12 2015-08-26 思杰系统有限公司 Orchestration framework for connected devices

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7275241B2 (en) * 2003-11-21 2007-09-25 International Business Machines Corporation Dynamic instrumentation for a mixed mode virtual machine
CN111159658B (en) * 2019-12-16 2022-04-01 广州三七互娱科技有限公司 Byte code processing method, system, device, computer equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102195970A (en) * 2010-03-10 2011-09-21 微软公司 Client session based debugging
CN104871172A (en) * 2012-10-12 2015-08-26 思杰系统有限公司 Orchestration framework for connected devices

Also Published As

Publication number Publication date
CN111625378A (en) 2020-09-04

Similar Documents

Publication Publication Date Title
US7287190B2 (en) Simultaneous execution of test suites on different platforms
CN108121594B (en) Process management method and device
CN111897623B (en) Cluster management method, device, equipment and storage medium
US7155639B2 (en) Compliance testing communication protocols implemented on resource-constrained computing devices
CN111782338A (en) Data processing method and system based on intelligent contract of block chain
CN107766101A (en) App starts processing method, device and the equipment of event
CN108628626B (en) Development environment building method, code updating method and device
CN113157274B (en) Software development method and device based on micro front end, electronic equipment and storage medium
CN111651169B (en) Block chain intelligent contract operation method and system based on web container
CN110083366B (en) Application running environment generation method and device, computing equipment and storage medium
CN104423961A (en) Method and system for generating testing script
CN110502251B (en) Application installation method and device
CN107391219A (en) Function Compilation Method and device
CN111625225A (en) Program specified data output method and device
CN112486579A (en) Self-service terminal device drive calling standardization method and related device
CN111625378B (en) Remote source code checking method and device
CN108319548A (en) A kind of program code adjustment method and device
CN117194252A (en) Automatic test method and device and electronic equipment
CN109062714A (en) The method, apparatus and electronic equipment of long-range control Android device
CN114721659B (en) Function service processing method and device and electronic equipment
CN115237481A (en) Method, device and equipment for driving external equipment and storage medium
CN114254220A (en) Web page view processing method, device and electronic device
CN119441008A (en) User interface debugging method, device, system and readable storage medium
CN118519619A (en) Application method and device of front-end scaffold
US8305910B2 (en) Method and apparatus for configuring, and compiling code for, a communications test set-up

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