CN111625378A - Remote source code viewing method and device - Google Patents

Remote source code viewing method and device Download PDF

Info

Publication number
CN111625378A
CN111625378A CN202010469941.5A CN202010469941A CN111625378A CN 111625378 A CN111625378 A CN 111625378A CN 202010469941 A CN202010469941 A CN 202010469941A CN 111625378 A CN111625378 A CN 111625378A
Authority
CN
China
Prior art keywords
target
class
port
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.)
Pending
Application number
CN202010469941.5A
Other languages
Chinese (zh)
Inventor
刘正阳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
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/CN111625378A/en
Publication of CN111625378A publication Critical patent/CN111625378A/en
Pending legal-status Critical Current

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

Abstract

The embodiment of the disclosure provides a source code remote viewing method and device, electronic equipment and a storage medium. The method comprises the steps of writing an agent program containing port starting logic and decompiling tool calling logic in advance, establishing a communication channel between the agent program and a target process, and acquiring 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 the designated port started by the agent program, calling a decompilation tool to obtain a source code of the target class, and finally sending 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 on the remote equipment and automatically return the corresponding source code to the remote equipment for checking, and is simple and convenient to operate and short in time consumption.

Description

Remote source code viewing method and device
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for remotely checking a source code, an electronic device, and a storage medium.
Background
After modifying the code and deploying the new code corresponding to the service to the online device, the developer sometimes needs to confirm whether the currently running service on the device uses the corresponding correct code.
But the deployed service uses compiled bytecode whose corresponding source code is not viewable. In a conventional scheme, source codes are commonly packaged in packaging deployment, and when the source codes of a certain service need to be confirmed, an online device is used for decompressing a corresponding project package and viewing the source codes.
The traditional scheme increases the operation cost of packaging and occupies more memory resources of online equipment. The whole source code checking process is complex, developers need to know storage paths of compressed project packages in online equipment, the project packages need to be decompressed to a certain folder during checking, then the project packages enter the folder to be checked according to names of the project packages, and the operation is complex and consumes long time.
Disclosure of Invention
In view of the above technical problems, an embodiment of the present disclosure provides a source code remote viewing method, and the technical solution is as follows:
according to a first aspect of the embodiments of the present disclosure, there is provided a source code remote viewing method, where the method configures an agent in a target device run by a target process, and the method includes:
after a communication channel is established between the agent program and the target process, starting a designated port of the target equipment;
receiving a target class in a target process selected by a user through remote equipment through the designated port, and acquiring a bytecode corresponding to the target class through the communication channel;
calling a decompilation tool configured in advance in target equipment to perform decompilation operation on the byte codes so as to obtain source codes corresponding to the byte codes;
and sending the source code to a remote device for displaying through the designated port.
Optionally, the agent program is a Java agent program, and the establishing a communication channel between the agent program and the target process includes:
and establishing a communication channel between the Java agent program and the target process by utilizing an 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 receiving, through the designated port, a target class in a target process selected by a user through a 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 step of sending the source code to the remote device through the designated port for presentation includes:
and transmitting the source code to a WEB page of remote equipment through an HTTP port, and displaying the source code through the WEB page.
Optionally, after starting the designated port of the target device, the method further includes:
determining the loaded class in the target process;
displaying the loaded class on a WEB page of the remote equipment through a specified port based on a preset display strategy so that a user selects a target class to be viewed in the WEB page, wherein the preset display strategy at least comprises the following steps: and showing the loaded classes of the specified type or showing the loaded classes according to the specified sequence.
According to a second aspect of the embodiments of the present disclosure, there is provided a source code remote viewing apparatus, where the apparatus configures an agent in a target device on which a target process is executed, the apparatus including:
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 remote equipment through the designated port and acquire a bytecode corresponding to the target class through the communication channel;
the decompiling module is configured to call a decompiling tool configured in advance in the target device to perform decompiling operation on the bytecode so as to obtain a source code corresponding to the bytecode;
and the information sending module is configured to send the source code to a remote device for presentation through the designated port.
Optionally, the agent program is a Java agent program, and the port start module, when establishing a communication channel between the agent program and the target process, is configured to:
and establishing a communication channel between the Java agent program and the target process by utilizing an 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 the target class in the target process selected by the user through the remote device through the designated port, 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 the information sending module, when sending the source code to the remote device through the designated port for presentation, is configured to:
and transmitting the source code to a WEB page of remote equipment through an HTTP port, and displaying the source code through the WEB page.
Optionally, the apparatus further includes a class information presentation module configured to:
determining the loaded class in the target process;
displaying the loaded class on a WEB page of the remote equipment through a specified port based on a preset display strategy so that a user selects a target class to be viewed in the WEB page, wherein the preset display strategy at least comprises the following steps: and showing the loaded classes of the specified type or showing the loaded classes according to the specified sequence.
According to a third aspect of the embodiments of the present disclosure, there is provided an electronic apparatus including: a processor; a memory for storing the processor-executable instructions; wherein the processor is configured to execute the instructions to implement the method of the first aspect.
According to a fourth aspect of embodiments of the present disclosure, there is provided a storage medium having instructions that, when executed by a processor of an electronic device, enable the electronic device to perform the method according to the first aspect.
The embodiment of the disclosure provides a source code remote viewing method and device, electronic equipment and a storage medium. The method comprises the steps of writing an agent program containing port starting logic and decompiling tool calling logic in advance, establishing a communication channel between the agent program and a target process, and acquiring 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 the designated port started by the agent program, calling a decompilation tool to obtain a source code of the target class, and finally sending 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 on the remote equipment and automatically return the corresponding source code to the remote equipment for checking, and is simple and convenient to operate and short in time consumption.
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, any one of the embodiments of the present disclosure need not achieve all of the effects described above.
Drawings
In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, 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 can be obtained by those skilled in the art according to the drawings.
FIG. 1 is a flow chart diagram illustrating a method for remote viewing of source code in accordance with an exemplary embodiment of the present disclosure;
FIG. 2 is a schematic diagram illustrating a connection relationship between a remote device and a target device in accordance with an exemplary embodiment of the present disclosure;
FIG. 3 is another flow chart diagram illustrating a method for remote viewing of source code in accordance with an exemplary embodiment of the present disclosure;
FIG. 4 is another flow chart diagram illustrating a method for remote viewing of source code in accordance with an exemplary embodiment of the present disclosure;
FIG. 5 is another schematic diagram illustrating a connection relationship between a remote device and a target device in accordance with an illustrative embodiment of the present disclosure;
FIG. 6 is an interaction diagram illustrating a method for remote viewing of source code in accordance with 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 the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended 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 and all possible combinations of one or more of the associated listed items.
It is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, such 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 "when … …" 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 online device, the developer sometimes needs to confirm whether the currently running service on the device uses the corresponding correct code.
But the deployed service uses compiled bytecode whose corresponding source code is not viewable. In a conventional scheme, source codes are commonly packaged in packaging deployment, and when the source codes of a certain service need to be confirmed, an online device is used for decompressing a corresponding project package and viewing the source codes.
The traditional scheme increases the operation cost of packaging and occupies more memory resources of online equipment. The whole source code checking process is complex, developers need to know storage paths of compressed project packages in online equipment, the project packages need to be decompressed to a certain folder during checking, then the project packages enter the folder to be checked according to names of the project packages, and the operation is complex and consumes long time.
To solve this problem, the present disclosure provides a source code remote viewing method, and a source code remote viewing apparatus to which the source code remote viewing method is applied. The method mainly aims at a program written by Java (an object-oriented programming language). The embodiments of the present disclosure are described in further detail below with reference to the drawings attached hereto.
First, a remote source code viewing method provided by the present disclosure is explained, where the method needs to configure an agent in a target device run by a target process, and with reference to fig. 1, the method includes the following steps S101 to S103:
in step S101, after a communication channel is established between the agent and the target process, a designated port of the target device is started;
the agent program and the target process are configured and operated on the target equipment, and a communication channel is established between the agent program and the target process.
In an embodiment of the present disclosure, the agent may be a Java agent program, a communication channel between the agent program and the target process, and a communication channel established between the Java agent program and the target process through an Attach function of the JVM.
Specifically, the process of starting the Java agent program is as follows: the Java agent program is launched by the Attach (attach) method of the VirtualMachine class. Jar in the tools provided by SUM functions is a category named VirtualMachine. The Java agent program can be started through an attach method of the VirtualMachine class, and the Java agent program can be attached to a designated JVM (Java Virtual Machine) process.
In the embodiment of the present disclosure, the JVM process is referred to as the target process. After the Java agent program is written, a jar file is formed. And loading the jar file through a loadAgent method of an attribute function package, so that the Java agent program can be attach to the target process based on the attribute method.
After the Java agent program is attech to the target process based on an attech 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 a target class in a target process selected by a user through a remote device through the designated port, and acquiring a bytecode corresponding to the target class through the communication channel;
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, but is not limited to, one of the following manners;
a) and receiving an input command of a user through a command line program, and determining a target class in a target process based on the input command.
In particular, the logic in the agent is pre-configured, which may be pre-written with user command receiving logic that may receive a user's target class in a target process selected by the remote device through a designated port. One embodiment is to start a command line program, and provide an input interface of a target class for a user by calling the command line program. For example, the following steps are carried out: 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 executed, the following manner may be adopted:
(1-1) the remote equipment starts a command line program 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 target equipment and a port number of an HTTP port;
(1-2) establishing communication with the target equipment according to the IP address of the target equipment and the port number of the HTTP port, and informing the class identification of the target class to an agent program in the target equipment;
and (1-3) the agent program acquires the byte codes of the target class of the target process through a communication channel which is pre-established between the agent program and the target process.
b) Receiving an input command of a user through a 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 initiated by the agent may be an HTTP port, and in general, the HTTP port may be an 80 port of the computer.
When the started designated port is the HTTP port, the remote device can establish HTTP communication with the target device through the port, namely, for the target process, the remote device can input information of a target class needing to check the source code through a WEB page and inform an agent program of the target device through the HTTP port, and after the agent program obtains the source code of the target class, the agent program is communicated with the remote device through the HTTP port to display the source code on the WEB page of the remote device through the HTTP port.
In an embodiment of the present disclosure, when step S102 is executed, the following manner may also be adopted:
(2-1) the remote equipment 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 equipment and a port number of an HTTP port;
(2-2) establishing communication with the target equipment according to the IP address of the target equipment and the port number of the HTTP port, and informing the class identification of the target class to an agent program in the target equipment;
and (2-3) the agent program acquires the byte codes of the target class of the target process through a communication channel which is pre-established between the agent program and the target process.
In step S103, a decompilation tool configured in advance in the target device is called to perform decompilation operation on the bytecode, so as to obtain a source code corresponding to the bytecode;
it is known that a high-level language source program generates an executable file through compilation, and decompilation is the reverse process of compilation. In the Java environment, compiling is to convert source code into bytecode, and de-translating is to convert bytecode into source code that can be read by developers. The code written by a developer when writing a Java program is the source code, the source code can only be read when reading, and the byte code is a binary file consisting of a sequence of op code/data pairs and is difficult to read and understand.
In the agent program, a calling logic of a decompilation tool is configured in advance, after target class information sent by remote equipment is received through a designated port, the agent program obtains byte codes of target classes in a target process, and calls the decompilation tool to decompilate the byte codes, 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 through the designated port for presentation.
The logic in the agent is pre-configured and can be pre-written with user command receiving logic that can receive a user's target class in a target process selected by the remote device through a designated port. In addition to starting the command line program, another implementation is to start a WEB page, provide an input interface of a target class for a user by calling the WEB page, and use the WEB page to display a returned source code. Wherein, the advantage of using the WEB page to display the source code is more convenient to read, the display format of the source code can be adjusted based on the parameter adjusting function of the WEB page,
in order to make the relationship between the remote device, the target device, the agent and the target process more clear, referring to fig. 2, the target device starts a WEB page as an example, which is described as follows:
the target device: the target device is a device where the target process runs, and the target device may be an online device running an online item or a test device running an item under test. An 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.
The remote device: the remote device is a device used by a user when viewing source code, and is a different device from the target device.
That is, the specific way of determining the target class in the target process selected by the user is as follows: the class identifier input by a user is 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 target class input by the user on the remote equipment is received through the designated port, and the user only needs to input the target equipment for viewing the source code in the remote equipment, so that the source code of the target class can be obtained by designating the port and the target class. The user does not need to go to a computer room to operate the target equipment, and the source code does not need to be packaged and placed at the corresponding position of the target equipment for executing the service, so that the checking efficiency is high.
Fig. 3 is a flowchart illustrating another source code remote viewing method according to an exemplary embodiment, which may be used on a platform capable of executing the source code remote viewing method and is based on the method shown in fig. 1, and as shown in fig. 3, the method may include the following steps S301 to S303:
in step S301, after a communication channel is established between the Java agent program and the target process, starting an assigned port of the target device;
in step S302, the class loaded in the target process is determined;
in step S303, based on a predetermined presentation policy, the loaded class is presented on the WEB page of the remote device through the designated port, so that the user selects a target class to be viewed therein.
After attch of the agent to the target process, the Instrumentation function may be used to view the loaded classes of the target process. On this basis, the present embodiment may obtain the loaded classes, and present the loaded classes through a predetermined presentation policy, so as to be convenient for the user to view and select, where the predetermined presentation policy may include at least: and showing the loaded classes of the specified type or showing the loaded classes according to the specified sequence.
The Instrumentation function of Java may attach to a specified process through an agent attch and obtain information of all loaded classes of the specified process, including the name of the class, the bytecode of the class, and the like. When a user operates a remote device and inputs a class needing to view a source code, all classes which are loaded by a target process can be acquired in advance through an Instrumentation function. Specifically, an Instrumentation inst instance exists in the java. The Instrumentation inst instance is automatically imported by the JVM at program runtime. Through this example, various interfaces provided by Instrumentation can be invoked. In an embodiment of the present disclosure, the returned loaded class in the target process may be obtained by calling the inst.getallloadedclasses () 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 classes may be set on the WEB page based on a predetermined display policy, or only certain types of classes may be displayed, or the WEB page may be preset to have a class screening function, and so on.
The agent is configured on a target device on which the target process is running. Specifically, the agent program may be configured in advance, and the configured agent program includes the start-up logic of the designated port and the call logic of the decompilation tool. After the configuration is completed, the agent program is packaged into a new JAR (Java Archive) package, and then the JAR package of the agent program is placed under an 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 does not need any adaptive change to the existing system, and can be used only by placing a new JAR (Java Archive) package, i.e., a JAR package of an agent program, into an LIB (library file) directory of a target program, so that the implementation is convenient.
Referring to fig. 4, a more specific remote viewing method for source code provided by the present disclosure includes the following steps S401 to S405:
in step S401, a pre-programmed Java agent program is obtained, and a communication channel is established between the Java agent program and the target process by using the Attach function provided by the Java virtual machine;
in step S402, in response to the execution result of the Java agent program, starting an HTTP port of the target device;
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 at least includes 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 configured in advance in the target device is called to perform 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 a decompilation component Procyon, and the present disclosure does not limit the specific 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 including port starting logic and decompiling tool calling logic is written in advance, and a communication channel is established between the agent program and a 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 the designated port started by the agent program, calling a decompilation tool to obtain a source code of the target class, and finally sending 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 on the remote equipment and automatically return the corresponding source code to the remote equipment for checking, and is simple and convenient to operate and short in time consumption.
Taking a decompilation tool as an example of Procyon, the overall structure and interaction of the present disclosure in practical applications are specifically described, as shown in fig. 5 and 6, it can be seen that a target process runs on a target device, and a Java agent program includes an Instrumentation function and a Procyon component calling logic. Firstly, attch of an agent program to a specified target process based on an Instrumentation function to establish an agent and then start an HTTP port, receive class information of a source code needing to be checked and sent by a WEB page of remote equipment through the HTTP port, acquire byte codes of the class and call a decompiling tool Procyon to decompile the byte codes of the class, and finally, display the source code acquired after decompiling through the WEB page.
Corresponding to the foregoing method embodiment, an embodiment of the present disclosure further provides a target source code remote viewing apparatus, and referring to fig. 7, the apparatus may include: a port starting module 710, an information receiving module 720, a decompilation module 730 and an information sending module 740.
A port starting module 710 configured to start a designated port of a target device after a communication channel is established between the control agent and the target process;
the information receiving module 720 is configured to receive, through the designated port, a target class in a target process selected by a user through a remote device, and obtain a bytecode corresponding to the target class through the communication channel;
a decompilation module 730, configured to invoke a decompilation tool configured in advance in the target device to perform decompilation operation on 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 program is a Java agent program, and the port start module, when establishing a communication channel between the agent program and the target process, is configured to:
and establishing a communication channel between the Java agent program and the target process by utilizing an 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 the target class in the target process selected by the user through the remote device through the designated port, 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 the information sending module, when sending the source code to the remote device through the designated port for presentation, is configured to:
and transmitting the source code to a WEB page of 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;
based on a preset display strategy, displaying the loaded class on a WEB page of the remote equipment through a specified port 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: and showing the loaded classes of the specified type or showing the loaded classes according to the specified sequence.
The disclosed embodiment 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, the method configures an agent program in a target device run by a target process, and the method includes:
after a communication channel is established between the agent program and the target process, starting a designated port of the target equipment;
receiving a target class in a target process selected by a user through remote equipment through the designated port, and acquiring a bytecode corresponding to the target class through the communication channel;
calling a decompilation tool configured in advance in target equipment to perform decompilation operation on the byte codes so as to obtain source codes corresponding to the byte codes;
and sending the source code to a remote device for displaying through the designated port.
Fig. 8 shows a schematic block diagram of a master-based-side electronic device according to an exemplary embodiment of the present disclosure. Referring to fig. 8, at the hardware level, the electronic device includes a processor 802, an internal bus 804, a network interface 806, a memory 804, and a non-volatile memory 810, but may also include hardware required for other services. The processor 802 reads the corresponding computer program from the non-volatile memory 810 into the memory 802 and runs it, forming a means for performing the source code remote viewing method at a logical level. Of course, besides the software implementation, the present disclosure does not exclude other implementations, such as logic devices or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or logic devices.
The embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the foregoing source code remote viewing method, where the method configures an agent program in a target device on which a target process runs, and the method includes:
after a communication channel is established between the agent program and the target process, starting a designated port of the target equipment;
receiving a target class in a target process selected by a user through remote equipment through the designated port, and acquiring a bytecode corresponding to the target class through the communication channel;
calling a decompilation tool configured in advance in target equipment to perform decompilation operation on the byte codes so as to obtain source codes corresponding to the byte codes;
and sending the source code to a remote device for displaying 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 computer storage media 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 that can be used to store information that can be accessed by a computing device. As defined herein, a computer readable medium does not include a transitory computer readable medium such as a modulated data signal and a carrier wave.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the disclosed solution. One of ordinary skill in the art can understand and implement it without inventive effort.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
The foregoing is merely a detailed description of the embodiments of the disclosure, and it should be noted that modifications and decorations can be made by those skilled in the art without departing from the principle of the embodiments of the disclosure, and these modifications and decorations should also be regarded as the scope of protection of the embodiments of the disclosure.

Claims (10)

1. A method for remotely viewing source code, wherein an agent is configured in a target device on which a target process is running, the method comprising:
after a communication channel is established between the agent program and the target process, starting a designated port of the target equipment;
receiving a target class in a target process selected by a user through remote equipment through the designated port, and acquiring a bytecode corresponding to the target class through the communication channel;
calling a decompilation tool configured in advance in target equipment to perform decompilation operation on the byte codes so as to obtain source codes corresponding to the byte codes;
and sending the source code to a remote device for displaying through the designated port.
2. The method of claim 1, wherein the agent is a Java agent program, and wherein 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 an 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, and wherein receiving the target class in the target process selected by the user through the remote device through the designated port comprises:
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 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 remote equipment through an HTTP port, and displaying the source code through the WEB page.
5. The method of claim 1, wherein after initiating the designated port of the target device, further comprising:
determining the loaded class in the target process;
displaying the loaded class on a WEB page of the remote equipment through a specified port based on a preset display strategy so that a user selects a target class to be viewed in the WEB page, wherein the preset display strategy at least comprises the following steps: and showing the loaded classes of the specified type or showing the loaded classes according to the specified sequence.
6. An apparatus for remotely viewing source code, wherein an agent is configured 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 remote equipment through the designated port and acquire a bytecode corresponding to the target class through the communication channel;
the decompiling module is configured to call a decompiling tool configured in advance in the target device to perform decompiling operation on the bytecode so as to obtain a source code corresponding to the bytecode;
and the information sending module is configured to send the source code to a remote device for presentation through the designated port.
7. The apparatus of claim 6, wherein the agent is a Java agent program, and wherein the port initiation module, when establishing the 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 an 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 the target class in the target process selected by the user through the remote device through the designated port, 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. 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.
10. A storage medium, wherein instructions in the storage medium, when executed by a processor of an electronic device, enable the electronic device to perform the method of any of claims 1-5.
CN202010469941.5A 2020-05-28 2020-05-28 Remote source code viewing method and device Pending CN111625378A (en)

Priority Applications (1)

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

Applications Claiming Priority (1)

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

Publications (1)

Publication Number Publication Date
CN111625378A true CN111625378A (en) 2020-09-04

Family

ID=72272909

Family Applications (1)

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

Country Status (1)

Country Link
CN (1) CN111625378A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112256448A (en) * 2020-09-30 2021-01-22 北京达佳互联信息技术有限公司 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

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

Cited By (1)

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

Similar Documents

Publication Publication Date Title
US20180101394A1 (en) Method and embedded device for loading driver
CN108121594B (en) Process management method and device
CN109933404B (en) Encoding and decoding method and system based on block chain intelligent contract
CN106294113B (en) creation method and device based on programmable test service
CN111897623B (en) Cluster management method, device, equipment and storage medium
CN104731622B (en) The loading method of a kind of application program, device and mobile terminal
CN111506579B (en) Method, program and equipment for generating intelligent contract code
CN104423961A (en) Method and system for generating testing script
CN113885935A (en) Resource packaging method and device, electronic equipment and computer readable storage medium
CN113590491B (en) Test platform and product test method
CN111694733A (en) API (application programming interface) testing method and device for software development kit SDK (software development kit)
CN111625378A (en) Remote source code viewing method and device
CN110083366B (en) Application running environment generation method and device, computing equipment and storage medium
CN111651169B (en) Block chain intelligent contract operation method and system based on web container
CN107133169B (en) Application test packet generation method and generation device
CN109062714A (en) The method, apparatus and electronic equipment of long-range control Android device
CN112486579A (en) Self-service terminal device drive calling standardization method and related device
CN109542775B (en) Test script generation and execution method and device
CN116016227A (en) Micro-service system arrangement visualization method, device and medium based on Docker compound
CN113157274B (en) Software development method and device based on micro front end, electronic equipment and storage medium
CN113010179B (en) Independent application running method based on real-time operating system
CN114358936A (en) Intelligent contract operation method based on micro-service block chain
CN110502251B (en) Application installation method and device
CN114756229A (en) Development page generation method based on micro front end and related device thereof
CN111026502B (en) Business debugging architecture creating method and device, electronic equipment and storage medium

Legal Events

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