CN110908860B - Java thread acquisition method and device, medium and electronic equipment - Google Patents

Java thread acquisition method and device, medium and electronic equipment Download PDF

Info

Publication number
CN110908860B
CN110908860B CN201911031683.6A CN201911031683A CN110908860B CN 110908860 B CN110908860 B CN 110908860B CN 201911031683 A CN201911031683 A CN 201911031683A CN 110908860 B CN110908860 B CN 110908860B
Authority
CN
China
Prior art keywords
thread
linux system
value
value under
language interface
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
CN201911031683.6A
Other languages
Chinese (zh)
Other versions
CN110908860A (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 ByteDance Network Technology Co Ltd
Original Assignee
Beijing ByteDance Network 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 ByteDance Network Technology Co Ltd filed Critical Beijing ByteDance Network Technology Co Ltd
Priority to CN201911031683.6A priority Critical patent/CN110908860B/en
Publication of CN110908860A publication Critical patent/CN110908860A/en
Application granted granted Critical
Publication of CN110908860B publication Critical patent/CN110908860B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3003Monitoring arrangements specially adapted to the computing system or computing system component being monitored
    • G06F11/302Monitoring arrangements specially adapted to the computing system or computing system component being monitored where the computing system component is a software system
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/30Monitoring
    • G06F11/3051Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Abstract

The invention provides a Java thread acquisition method, a Java thread acquisition device, a Java thread acquisition medium and electronic equipment, wherein the Java thread acquisition method comprises the following steps: preprocessing according to a first preset method to obtain any thread object; carrying out operation on any thread object to obtain a corresponding thread value under a linux system; and judging whether the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, and if the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, determining that the current thread object is the solved thread object. According to the method and the device, whether the thread value of the linux system corresponding to any thread object is the same as the thread value of the target linux system is judged, if so, the current thread object is the obtained thread object, so that the java thread object corresponding to the thread value of the linux system can be accurately obtained, and the error detection condition can not exist.

Description

Java thread acquisition method and device, medium and electronic equipment
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a medium, and an electronic device for acquiring a Java thread.
Background
In an android system, we sometimes need to obtain a Thread object of a java corresponding to a Thread value (i.e., tid) in a linux system (for example, after a native crash occurs, the Thread object of the java corresponding to the native crash needs to be obtained according to tid), but no method is disclosed that can obtain the Thread object of the java corresponding to a tid. The prior art generally reads/proc/self/task/[ tid ]/comm files to obtain the Thread name, then enumerates all Thread objects in the java layer, and checks which Thread object name matches the read name.
However, this existing method has great disadvantages:
disadvantage 1: the number of characters stored in the/proc/self/task/[ tid ]/comm file is limited (typically 15 valid characters can be stored at most), if the first half names of two Thread objects are the same, it is easy to debug the Thread object, e.g., the Thread object.
Disadvantage 2: java allows two threads to exist that are identical in name, which makes it easier for existing methods to debug Thread objects, such as Thread objects.
Therefore, in long-term research and development, the inventors have made a great deal of study on a method for acquiring a Java thread, and proposed a method for acquiring a Java thread to solve one of the above-mentioned technical problems.
Disclosure of Invention
The invention aims to provide a Java thread acquisition method, a Java thread acquisition device, a Java thread acquisition medium and electronic equipment, and aims to solve at least one technical problem. The specific scheme is as follows:
according to a specific embodiment of the present invention, in a first aspect, the present invention provides a method for acquiring a Java thread, including:
preprocessing according to a first preset method to obtain any thread object;
carrying out operation on any thread object to obtain a corresponding thread value under a linux system;
and judging whether the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, and if the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, determining that the current thread object is the solved thread object.
According to a second aspect of the present invention, there is provided an apparatus for acquiring a Java thread, including:
the preprocessing unit is used for preprocessing according to a first preset method to obtain any thread object;
the operation unit is used for operating any thread object obtained by the preprocessing unit to obtain a corresponding thread value under the linux system;
and the processing unit is used for judging whether the thread value under the linux system corresponding to any thread object obtained by the operation unit is the same as the thread value under the target linux system, and if the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, the current thread object is the solved thread object.
According to a third aspect of the present invention, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements a method of acquiring a Java thread as defined in any one of the above.
According to a fourth aspect of the present invention, there is provided an electronic device comprising: one or more processors; storage means for storing one or more programs which, when executed by the one or more processors, cause the one or more processors to implement the method of acquiring a Java thread as claimed in any preceding claim.
Compared with the prior art, the scheme provided by the embodiment of the invention has at least the following beneficial effects: the invention provides a Java thread obtaining method, a Java thread obtaining device, a Java thread obtaining medium and a Java thread obtaining electronic device, wherein whether the thread value under a linux system corresponding to any thread object is the same as the thread value under a target linux system is judged, if the thread value under the linux system is the same as the thread value under the target linux system, the current thread object is the obtained thread object, so that the Java thread object corresponding to the thread value under the linux system can be accurately obtained, and error finding can not occur.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention. It is evident that the drawings in the following description are only some embodiments of the present invention and that other drawings may be obtained from these drawings without inventive effort for a person of ordinary skill in the art. In the drawings:
FIG. 1 shows a flowchart of a method of acquiring Java threads according to an embodiment of the present invention;
FIG. 2 illustrates a flow chart of a method of initializing a software development kit according to an embodiment of the invention;
FIG. 3 is a flowchart of a method for acquiring a thread object corresponding to a thread value in a linux system according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a Java thread acquiring device according to an embodiment of the present invention;
fig. 5 shows a schematic diagram of an electronic device connection structure according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in further detail below with reference to the accompanying drawings, and it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this application 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, the "plurality" generally includes at least two.
It should be understood that the term "and/or" as used herein is merely one relationship describing the association of the associated objects, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. In addition, the character "/" herein generally indicates that the front and rear associated objects are an "or" relationship.
It should be understood that although the terms first, second, third, etc. may be used to describe … … in embodiments of the present invention, these … … should not be limited to these terms. These terms are only used to distinguish … …. For example, the first … … may also be referred to as the second … …, and similarly the second … … may also be referred to as the first … …, without departing from the scope of embodiments of the present invention.
The words "if", as used herein, may be interpreted as "at … …" or "at … …" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrase "if determined" or "if detected (stated condition or event)" may be interpreted as "when determined" or "in response to determination" or "when detected (stated condition or event)" or "in response to detection (stated condition or event), depending on the context.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a product or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such product or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a commodity or device comprising such element.
Alternative embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
Example 1
As shown in fig. 1, according to a specific embodiment of the present invention, in a first aspect, the present invention provides a method for acquiring a Java thread, which specifically includes the following method steps:
s102: preprocessing according to a first preset method to obtain any thread object;
the first preset method may be:
the getallStackTraces method for Thread objects is Thread class, and other methods besides the above listed methods may be used, and will not be described in detail herein.
In a specific application scene, all Thread objects are obtained through a getAllStackTrace method of a Thread class.
After S102 is executed and preprocessing is carried out according to a first preset method to obtain any thread object, any thread object is operated to obtain a thread value under a corresponding linux system; judging whether the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, if the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, the current thread object is the solved thread object; otherwise, if the thread value under the linux system corresponding to any thread object is different from the thread value under the target linux system, the corresponding thread object does not exist in the set of thread objects formed by any thread object.
After performing S106, the method further comprises the steps of:
and judging whether the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, and if the thread value under the linux system corresponding to any thread object is different from the thread value under the target linux system, not existence of the corresponding thread object in the set of the thread objects formed by any thread object.
Before executing S102 to perform preprocessing according to the first preset method to obtain any thread object, the method further includes the following steps:
the software development kit is initialized.
FIG. 2 is a flow chart illustrating a method of initializing a software development kit according to an embodiment of the invention; the method for initializing as shown in fig. 2 is an initializing method for a specific application scenario in which a Thread object is a Thread object and a heterogeneous language interface layer is a native layer.
As shown in fig. 2, the process of initializing the software development kit is as follows:
first, a member of a Thread (e.g., thread) that stores pointers to Thread objects of a heterogeneous language interface layer (e.g., the heterogeneous language interface layer is a native layer) (typically a member of the Thread class that is named native peer); then, an offset value of a Thread value in a representation object of a Thread object (for example, the Thread object is a Thread object) in a heterogeneous language interface layer (for example, the heterogeneous language interface layer is a native layer) in the linux system is obtained: firstly, executing an android. Os. Process class myTid method on a current Thread to obtain a Thread value (hereinafter referred to as curTid) under a linux system of the current Thread, obtaining an address (hereinafter referred to as curPtr) of a Thread object used for storing a heterogeneous language interface layer (for example, the heterogeneous language interface layer is a native layer) in the current Thread (for example, the Thread is a Thread) through reflection, then traversing a memory pointed by the curPtr byte by byte backwards until the curTid is stored in the memory, and subtracting the curPtr from the address of the memory where the curTid is located at the moment to obtain an offset value (hereinafter referred to as offset).
Optionally, initializing the software development kit includes the steps of:
step a1, acquiring each member of a thread for storing pointers of heterogeneous language interface layer thread objects;
step a2: acquiring a second offset value of a thread value in a heterogeneous language interface layer in a representation thread object under a linux system, wherein the second offset value is used for identifying an offset byte value;
and a step a3 of obtaining a thread value under a linux system of the current thread according to the second offset value, wherein a pointer used for storing a heterogeneous language interface layer thread object in the thread points to a position of the heterogeneous language interface memory, which is offset from the second offset value.
Optionally, according to the second offset value, the pointer in the thread for storing the heterogeneous language interface layer thread object points to the position of the offset second offset value in the heterogeneous language interface memory, and obtaining the thread value under the linux system of the current thread includes the following steps:
according to the second offset value, traversing the memory pointed by the address used for storing the heterogeneous language interface layer thread object in the current thread by the pointer, traversing and offsetting bytes of the second offset value until the thread value stored in the heterogeneous language interface memory is the thread value under the linux system of the current thread, and obtaining the thread value under the linux system of the current thread.
Optionally, before obtaining the second offset value of the thread value in the representing thread object of the heterogeneous language interface layer under the linux system, the method further includes the following steps:
and obtaining a second offset value of the thread value in the heterogeneous language interface layer in the representing thread object under the linux system.
Optionally, obtaining the second offset value of the thread value in the representing thread object of the heterogeneous language interface layer under the linux system includes the following steps:
step b1: executing a second preset method by the current thread to obtain a thread value under a linux system corresponding to the current thread; the second preset method is an android. Os. Process class myTid method; the second preset method may be other methods besides the above method, and will not be described in detail herein;
in a specific application scene, executing an android. Os. Process class myTid method on a current thread to obtain a thread value (hereinafter referred to as curTid) under a linux system of the current thread;
step b2: obtaining an address for storing the heterogeneous language interface layer thread object in the current thread through a second reflection method;
step b3: traversing the memory pointed by the address for storing the heterogeneous language interface layer thread object by byte until the thread value under the linux system corresponding to the current thread is stored in the heterogeneous language interface memory, subtracting the address for storing the heterogeneous language interface layer thread object in the previous thread from the address of the memory where the thread value is located, and obtaining the value as a second offset value.
S104: carrying out operation on any thread object to obtain a corresponding thread value under a linux system;
optionally, performing an operation on any thread object to obtain a thread value under the corresponding linux system includes the following steps:
step c1, acquiring a first address used for storing a heterogeneous language interface layer thread object in any thread object through a first reflection method;
and step c2, calculating a second address of any thread object, which is used for storing a first offset value corresponding to the offset of the first address of the heterogeneous language interface layer thread object, and taking out a thread value of a corresponding type from the second address, wherein the thread value is used as a thread value under a corresponding linux system.
FIG. 3 is a flowchart of a method for acquiring a thread object corresponding to a thread value in a linux system according to an embodiment of the present invention; the method for acquiring the Thread object corresponding to the Thread value in the linux system shown in fig. 3 is an acquisition method for a specific application scenario in which the Thread object is a Thread object and the heterogeneous language interface layer is a native layer.
Referring to fig. 3, the address (hereinafter referred to as the ptr) of the thread object used to store the heterogeneous language interface layer (for example, the heterogeneous language interface layer is the native layer) is obtained by reflection;
then calculates the address at which the ptr is backward offset (hereinafter, the titdptr, i.e., the titdptr=the ptr+offset); and then the value of the pid_t type is fetched from the address of the TidPtr to obtain the Tid.
S106: and judging whether the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, and if the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, determining that the current thread object is the solved thread object.
After performing S106, the method further comprises the steps of:
and judging whether the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, and if the thread value under the linux system corresponding to any thread object is different from the thread value under the target linux system, not existence of the corresponding thread object in the set of the thread objects formed by any thread object.
The invention provides the Java thread obtaining method, which judges whether the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, if so, the current thread object is the obtained thread object, so that the Java thread object corresponding to the thread value under the linux system can be accurately obtained, and the error finding condition can not exist.
Example 2
The embodiment accepts embodiment 1, is used to implement the method steps described in embodiment 1, and has the same technical effects as embodiment 1 based on the same explanations of the meaning of the names as embodiment 1, and will not be repeated here. Referring to fig. 4, according to a second aspect of the present invention, the present invention provides an apparatus for acquiring a Java thread, which specifically includes a preprocessing unit 402, an operation unit 404, and a processing unit 406, and is specifically as follows:
a preprocessing unit 402, configured to perform preprocessing according to a first preset method to obtain any thread object;
the first preset method may be:
the getallStackTraces method for threads of Thread class can be other methods besides the above listed methods, and will not be described in detail here.
In a specific application scenario, all Thread objects are obtained by a getallStackTracesThe Thread is Thread-like.
An operation unit 404, configured to perform an operation on any thread object obtained by the preprocessing unit 402, to obtain a thread value under a corresponding linux system;
and the processing unit 406 is configured to determine whether the thread value under the linux system corresponding to the any thread object obtained by the operation unit 404 is the same as the thread value under the target linux system, and if the thread value under the linux system corresponding to the any thread object is the same as the thread value under the target linux system, the current thread object is the obtained thread object.
Optionally, the processing unit 406 is further configured to:
if the thread value under the linux system corresponding to any thread object is different from the thread value under the target linux system, the corresponding thread object does not exist in the set of the thread objects formed by any thread object.
Optionally, the operation unit 404 is specifically configured to:
acquiring a first address used for storing a heterogeneous language interface layer thread object in any thread object through a first reflection method;
and calculating a second address of any thread object, which is used for storing a first offset value corresponding to the offset of the first address of the heterogeneous language interface layer thread object, and taking out a thread value of a corresponding type from the second address, wherein the thread value is used as a thread value under a corresponding linux system.
Optionally, the apparatus further includes:
an initializing unit (not shown in fig. 4) for initializing the software development kit.
Optionally, the initializing unit specifically includes an acquiring subunit and a processing subunit;
the acquisition subunit is configured to:
acquiring each member of a thread for storing pointers of heterogeneous language interface layer thread objects; obtaining a second offset value of a thread value in a thread object representing a heterogeneous language interface layer under a linux system, wherein the second offset value is used for identifying an offset byte value;
the processing subunit is configured to:
and according to the second offset value, a pointer used for storing the heterogeneous language interface layer thread object in the thread points to a position of the offset second offset value in the heterogeneous language interface memory, so as to obtain a thread value under the linux system of the current thread.
Optionally, the initializing unit is specifically configured to:
according to the second offset value, traversing the memory pointed by the address used for storing the heterogeneous language interface layer thread object in the current thread by the pointer, traversing and offsetting bytes of the second offset value until the thread value stored in the heterogeneous language interface memory is the thread value under the linux system of the current thread, and obtaining the thread value under the linux system of the current thread.
Optionally, before the obtaining subunit obtains the second offset value of the thread value in the thread object in the heterogeneous language interface layer, the processing subunit is further configured to:
and obtaining a second offset value of the thread value in the heterogeneous language interface layer in the representing thread object under the linux system.
Optionally, the processing subunit is specifically further configured to:
executing a second preset method by the current thread to obtain a thread value under a linux system corresponding to the current thread; the second preset method is an android. Os. Process class myTid method; the second preset method may be other methods besides the above method, and will not be described in detail herein;
in a specific application scene, executing an android. Os. Process class myTid method on a current thread to obtain a thread value (hereinafter referred to as curTid) under a linux system of the current thread;
obtaining an address for storing the heterogeneous language interface layer thread object in the current thread through a second reflection method;
traversing the memory pointed by the address for storing the heterogeneous language interface layer thread object by byte until the thread value under the linux system corresponding to the current thread is stored in the heterogeneous language interface memory, subtracting the address for storing the heterogeneous language interface layer thread object in the previous thread from the address of the memory where the thread value is located, and obtaining the value as a second offset value.
The invention provides the Java thread obtaining device, which judges whether the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system or not through the processing unit, and if the processing unit judges that the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, the current thread object is the obtained thread object, so that the Java thread object corresponding to the thread value under the linux system can be accurately obtained, and the error finding condition can not exist.
Example 3
As shown in fig. 5, this embodiment provides an electronic device, which is used for a Java thread obtaining method, and includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory stores instructions executable by the one processor, the instructions being executable by the at least one processor to enable the at least one processor to: the method has the advantages that the thread object of java corresponding to the thread value under the linux system is accurately obtained, and error detection is avoided.
Example 4
The disclosed embodiments provide a non-volatile computer storage medium storing computer executable instructions that can perform the method of acquiring a Java thread in any of the above-described method embodiments.
Example 5
Referring now to fig. 5, a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure is shown. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and the like, and stationary terminals such as digital TVs, desktop computers, and the like. The electronic device shown in fig. 5 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 5, the electronic device may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 501, which may perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 502 or a program loaded from a storage means 508 into a Random Access Memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
In general, the following devices may be connected to the I/O interface 505: input devices 506 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; an output device 507 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 508 including, for example, magnetic tape, hard disk, etc.; and communication means 509. The communication means 509 may allow the electronic device to communicate with other devices wirelessly or by wire to exchange data. While fig. 5 shows an electronic device having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 509, or from the storage means 508, or from the ROM 502. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 501.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
The computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: the method and the device can accurately acquire the java thread object corresponding to the thread value under the linux system, and can not have the condition of error detection.
Alternatively, the computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to: the method and the device can accurately acquire the java thread object corresponding to the thread value under the linux system, and can not have the condition of error detection.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Wherein the names of the units do not constitute a limitation of the units themselves in some cases.

Claims (10)

1. The Java thread acquisition method is characterized by comprising the following steps of:
preprocessing according to a first preset method to obtain any thread object;
acquiring a first address used for storing a heterogeneous language interface layer thread object in any thread object through a first reflection method;
calculating a second address of any thread object at a first offset value corresponding to a first address offset for storing a heterogeneous language interface layer thread object, extracting a thread value of a corresponding type from the second address, and taking the thread value as a thread value under a corresponding linux system
And judging whether the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, and if the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, determining that the current thread object is the solved thread object.
2. The method according to claim 1, wherein the method further comprises:
if the thread value under the linux system corresponding to any thread object is different from the thread value under the target linux system, the corresponding thread object does not exist in the set of the thread objects formed by any thread object.
3. The method according to claim 1, wherein the method further comprises:
the software development kit is initialized.
4. The method of claim 3, wherein initializing a software development kit comprises:
acquiring each member of a thread for storing pointers of heterogeneous language interface layer thread objects;
acquiring a second offset value of a thread value in a heterogeneous language interface layer in a representation thread object under a linux system, wherein the second offset value is used for identifying an offset byte value;
and according to the second offset value, the pointer used for storing the heterogeneous language interface layer thread object in the thread points to the position of the heterogeneous language interface memory, which is offset by the second offset value, so as to obtain the thread value under the linux system of the current thread.
5. The method of claim 4, wherein the obtaining the thread value under the linux system of the current thread according to the second offset value, wherein the pointer in the thread for storing the heterogeneous language interface layer thread object points to the location in the heterogeneous language interface memory where the second offset value is offset, comprises:
and traversing the memory pointed by the address used for storing the heterogeneous language interface layer thread object in the current thread by the pointer according to the second offset value, traversing and offsetting bytes of the second offset value until the thread value stored in the heterogeneous language interface memory is the thread value under the linux system of the current thread, and obtaining the thread value under the linux system of the current thread.
6. The method of claim 4, wherein prior to the obtaining the second offset value of the thread value under the linux system in the representing thread object of the heterogeneous language interface layer, the method further comprises:
and obtaining the second offset value of the thread value in the representing thread object of the heterogeneous language interface layer under the linux system.
7. The method of claim 6, wherein obtaining the second offset value of the thread value under the linux system in the representing thread object of the heterogeneous language interface layer comprises:
executing a second preset method by the current thread to obtain a thread value under a linux system corresponding to the current thread;
obtaining an address for storing the heterogeneous language interface layer thread object in the current thread through a second reflection method;
traversing the memory pointed by the address for storing the heterogeneous language interface layer thread object by byte until the memory of the heterogeneous language interface stores the thread value under the linux system corresponding to the current thread, subtracting the address for storing the heterogeneous language interface layer thread object in the previous thread from the address of the memory where the thread value is located, and obtaining the value as the second offset value.
8. An acquisition device for a Java thread, comprising:
the preprocessing unit is used for preprocessing according to a first preset method to obtain any thread object;
the operation unit is used for acquiring a first address used for storing the heterogeneous language interface layer thread object in any thread object through a first reflection method, calculating a second address at a first offset value corresponding to the offset of the first address used for storing the heterogeneous language interface layer thread object in any thread object, extracting a thread value of a corresponding type from the second address, and taking the thread value as a thread value under a corresponding linux system;
and the processing unit is used for judging whether the thread value under the linux system corresponding to any thread object obtained by the operation unit is the same as the thread value under the target linux system, and if the thread value under the linux system corresponding to any thread object is the same as the thread value under the target linux system, the current thread object is the solved thread object.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any one of claims 1 to 7.
10. An electronic device, comprising:
one or more processors;
storage means for storing one or more programs which when executed by the one or more processors cause the one or more processors to implement the method of any of claims 1 to 7.
CN201911031683.6A 2019-10-28 2019-10-28 Java thread acquisition method and device, medium and electronic equipment Active CN110908860B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911031683.6A CN110908860B (en) 2019-10-28 2019-10-28 Java thread acquisition method and device, medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911031683.6A CN110908860B (en) 2019-10-28 2019-10-28 Java thread acquisition method and device, medium and electronic equipment

Publications (2)

Publication Number Publication Date
CN110908860A CN110908860A (en) 2020-03-24
CN110908860B true CN110908860B (en) 2023-06-09

Family

ID=69816104

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911031683.6A Active CN110908860B (en) 2019-10-28 2019-10-28 Java thread acquisition method and device, medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN110908860B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111813663B (en) * 2020-06-19 2024-03-22 北京字节跳动网络技术有限公司 Pointer type identification method, device, medium and equipment

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6002872A (en) * 1998-03-31 1999-12-14 International Machines Corporation Method and apparatus for structured profiling of data processing systems and applications
CN108763060A (en) * 2018-04-27 2018-11-06 广州华多网络科技有限公司 Native layers of collapse source tracing method, device, storage medium and terminal in android system

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7610585B2 (en) * 2004-06-03 2009-10-27 Intel Corporation Thread synchronization methods and apparatus for managed run-time environments
US8589895B2 (en) * 2010-01-13 2013-11-19 International Business Machines Corporation Architectural support for automated assertion checking
CN109298901B (en) * 2018-08-29 2022-05-31 百度在线网络技术(北京)有限公司 Method, device and equipment for processing objects in unmanned vehicle, storage medium and vehicle
CN109918145B (en) * 2019-01-10 2022-05-20 北京字节跳动网络技术有限公司 Application cold start acceleration method and device and electronic equipment
CN110377341B (en) * 2019-06-10 2022-05-03 北京字节跳动网络技术有限公司 Method, device, medium and electronic equipment for monitoring no-response exception

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6002872A (en) * 1998-03-31 1999-12-14 International Machines Corporation Method and apparatus for structured profiling of data processing systems and applications
CN108763060A (en) * 2018-04-27 2018-11-06 广州华多网络科技有限公司 Native layers of collapse source tracing method, device, storage medium and terminal in android system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
改进的隐藏进程检测查杀技术;李湘宁;凌捷;;计算机工程与设计(第11期);全文 *

Also Published As

Publication number Publication date
CN110908860A (en) 2020-03-24

Similar Documents

Publication Publication Date Title
CN110489101B (en) Interface simulation method, system, medium and electronic equipment
CN110764941B (en) Method, device, medium and equipment for acquiring call stack frame instruction offset
CN110489179B (en) Method, device, medium and equipment for acquiring call stack frame function signature
CN110489165B (en) Method, device, medium and equipment for acquiring call stack frame instruction offset
CN110471709B (en) Method, device, medium and electronic equipment for accelerating webpage opening speed
CN111813641A (en) Method, device, medium and equipment for collecting crash information
CN111813465B (en) Information acquisition method, device, medium and equipment
CN110908860B (en) Java thread acquisition method and device, medium and electronic equipment
CN110888773B (en) Method, device, medium and electronic equipment for acquiring thread identification
CN110941549A (en) Memory leak detection method, device, medium and electronic equipment
CN110674050A (en) Memory out-of-range detection method and device, electronic equipment and computer storage medium
CN110673908A (en) Interface generation method, device, medium and electronic equipment
CN111258797B (en) Memory leak detection method, device, medium and electronic equipment
CN110727480B (en) Method, device, medium and equipment for acquiring call stack frame instruction offset
CN111290812B (en) Display method, device, terminal and storage medium of application control
CN111124627B (en) Method and device for determining call initiator of application program, terminal and storage medium
CN111381813B (en) Front-end page debugging method and device, computer equipment and storage medium
CN111813663B (en) Pointer type identification method, device, medium and equipment
CN113760631A (en) Page loading duration determination method, device, equipment and storage medium
CN111813664B (en) Crash information collection method, device, medium and equipment
CN113220128B (en) Self-adaptive intelligent interaction method and device and electronic equipment
CN111209058B (en) Method, device, medium and equipment for acquiring process name
CN111241368B (en) Data processing method, device, medium and equipment
CN117271297A (en) Function processing method, device, equipment and storage medium
CN114499948A (en) Linux firewall dynamic policy processing method and device 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
GR01 Patent grant
GR01 Patent grant