CN110908860A - Method, device, medium and electronic equipment for acquiring Java threads - Google Patents

Method, device, medium and electronic equipment for acquiring Java threads Download PDF

Info

Publication number
CN110908860A
CN110908860A CN201911031683.6A CN201911031683A CN110908860A CN 110908860 A CN110908860 A CN 110908860A CN 201911031683 A CN201911031683 A CN 201911031683A CN 110908860 A CN110908860 A CN 110908860A
Authority
CN
China
Prior art keywords
thread
linux system
value under
value
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.)
Granted
Application number
CN201911031683.6A
Other languages
Chinese (zh)
Other versions
CN110908860B (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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computing Systems (AREA)
  • Physics & Mathematics (AREA)
  • Quality & Reliability (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a method, a device, a medium and electronic equipment for acquiring Java threads, wherein the acquisition method comprises the following steps: preprocessing according to a first preset method to obtain any thread object; calculating any thread object to obtain a corresponding thread value under the 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 invention, 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 is judged, 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, 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.

Description

Method, device, medium and electronic equipment for acquiring Java threads
Technical Field
The invention relates to the technical field of computers, in particular to a method, a device, a medium and electronic equipment for acquiring Java threads.
Background
In an android system, sometimes a java Thread object corresponding to a Thread value (i.e. tid) in a linux system needs to be obtained (for example, after a native crash occurs, the java Thread object corresponding to the tid needs to be obtained according to the tid), but no method is disclosed for obtaining the java Thread object corresponding to the tid. The prior art generally reads/proc/self/task/[ tid ]/comm file to obtain the name of Thread, then enumerates all Thread objects in java layer, and checks which Thread object name matches the read name.
However, the existing method has great disadvantages:
disadvantage 1: the number of characters stored in the/proc/self/task/[ tid ]/comm file is limited (usually, 15 valid characters can be stored at most), and if the first half names of two Thread objects are the same, it is easy to find a Thread object, for example, a Thread object.
And (2) disadvantage: java allows two threads with exactly the same name to exist, which makes it easier for existing methods to miss Thread objects, e.g., Thread objects.
Therefore, in long-term research and development, the inventor has conducted a great deal of research on an acquisition method of a Java thread, and has proposed an acquisition method of a Java thread to solve one of the above technical problems.
Disclosure of Invention
The present invention is directed to a method, an apparatus, a medium, and an electronic device for obtaining a Java thread, which are capable of solving at least one of the above-mentioned technical problems. The specific scheme is as follows:
according to a specific implementation manner 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;
calculating any thread object to obtain a corresponding thread value under the 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 obtaining 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 of 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, the present invention provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor implements the method for acquiring a Java thread as described in any of the above.
According to a fourth aspect of the present invention, there is provided an electronic apparatus including: 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 a method of fetching a Java thread as described in any preceding claim.
Compared with the prior art, the scheme of the embodiment of the invention at least has the following beneficial effects: by providing the method, the device, the medium and the electronic equipment for acquiring the Java thread, 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 is judged, 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 acquired thread object, so that the Java thread object corresponding to the thread value under the linux system can be accurately acquired, and the condition of finding mistakes cannot be caused.
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 obvious that the drawings in the following description are only some embodiments of the invention, and that for a person skilled in the art, other drawings can be derived from them without inventive effort. In the drawings:
FIG. 1 is a flow diagram illustrating a method for obtaining a Java thread according to an embodiment of the present invention;
FIG. 2 illustrates a flow diagram of a method of initializing a software development kit in accordance with an embodiment of the present invention;
FIG. 3 is a flowchart illustrating a method for obtaining a thread object corresponding to a thread value in a linux system according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating an apparatus for obtaining Java threads 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 invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present 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 the examples of the present invention 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, and "a plurality" typically includes at least two.
It should be understood that the term "and/or" as used herein is merely one type of association that describes an associated object, meaning that three relationships may exist, e.g., a and/or B may mean: a exists alone, A and B exist simultaneously, and B exists alone. In addition, the character "/" herein generally indicates that the former and latter related objects are in 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 used only to distinguish … …. For example, the first … … can also be referred to as the second … … and similarly the second … … can 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 phrases "if determined" or "if detected (a stated condition or event)" may be interpreted as "when determined" or "in response to a determination" or "when detected (a stated condition or event)" or "in response to a detection (a stated condition or event)", depending on the context.
It is also noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that an article 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 article or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in the article or device in which the element is included.
Alternative embodiments of the present invention are 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:
for the getallstacktracks method in which the Thread object is a Thread class, the method may be other methods besides the methods listed above, and details are not repeated here.
In a specific application scene, all Thread objects are obtained through a Thread-like getAllStackTraces method.
According to the technical scheme of the method for acquiring the Java thread, after the execution of S102 is finished, preprocessing is carried out according to a first preset method, and any thread object is obtained, any thread object is operated, and a corresponding thread value under a linux system is obtained; 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 so, determining that the current thread object is the solved thread object; on the contrary, 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 includes 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, if the thread value under the linux system corresponding to any thread object is different from the thread value under the target linux system, determining that the corresponding thread object does not exist in the set of thread objects formed by any thread object.
Before executing S102 to perform preprocessing according to a 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 diagram illustrating a method for initializing a software development kit according to an embodiment of the present invention; the initialization method shown in fig. 2 is an initialization 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:
firstly, acquiring a member (generally a member named as native Peer in Thread class) of a pointer (used for storing a Thread object of a heterogeneous language interface layer (for example, the heterogeneous language interface layer is a native layer) in a Thread (for example, the Thread is Thread); then, obtaining an offset value of a Thread value under the linux system 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): the method includes the steps of firstly, executing a myTid method of an android.os.process class on a current Thread to obtain a Thread value (hereinafter called currtid) under a linux system of the current Thread, obtaining an address (hereinafter called currptr) 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 Thread) through reflection, and then traversing a memory pointed by the currptr byte by byte until the memory stores the currtid, wherein the address minus the currptr of the memory where the currtid is located is an obtained offset value (hereinafter called offset).
Optionally, initializing the software development kit includes the following steps:
a1, acquiring each member of the pointer used for storing the heterogeneous language interface layer thread object in the thread;
step a 2: acquiring a second offset value of the thread value in the representation thread object of the heterogeneous language interface layer under the linux system, wherein the second offset value is used for identifying the byte value of the offset;
and a3, according to the second deviation value, the pointer used for storing the thread object of the heterogeneous language interface layer in the thread points to the position of the deviation second deviation value in the heterogeneous language interface memory, and the thread value under the linux system of the current thread is obtained.
Optionally, obtaining a thread value under the linux system of the current thread according to the second offset value by pointing the pointer, used for storing the thread object of the heterogeneous language interface layer, in the thread to the position of the second offset value in the heterogeneous language interface memory, according to the second offset value includes the following steps:
according to the second deviation value, the pointer traverses the memory pointed by the address used for storing the thread object of the heterogeneous language interface layer in the current thread, traverses and deviates the byte of the second deviation value until the thread value under the linux system of the current thread is stored in the memory of the heterogeneous language interface, and the thread value under the linux system of the current thread is obtained.
Optionally, before obtaining the second offset value of the thread value in the thread object represented by the heterogeneous language interface layer in the linux system, the method further includes the following steps:
and obtaining a second offset value of the thread value under the linux system in the representation thread object of the heterogeneous language interface layer.
Optionally, obtaining a second offset value of the thread value in the thread object represented by the heterogeneous language interface layer in the linux system includes the following steps:
step b 1: executing a second preset method by the current thread to obtain a thread value under the linux system corresponding to the current thread; wherein the second preset method is a myTid method of the android. The second preset method may be other methods besides the above method, and is not described in detail herein;
in a specific application scene, executing a myTid method of the android.os.process class on a current thread to obtain a thread value (called curTid) under a linux system of the current thread;
step b 2: acquiring an address used for storing a thread object of a heterogeneous language interface layer in a current thread by a second reflection method;
step b 3: traversing the memory used for storing the addresses of the thread objects of the heterogeneous language interface layer byte by byte until the thread value under the linux system corresponding to the current thread is stored in the heterogeneous language interface memory, and subtracting the address used for storing the thread objects of the heterogeneous language interface layer in the previous thread from the address of the memory in which the thread value is stored to obtain a value as a second deviation value.
S104: calculating any thread object to obtain a corresponding thread value under the linux system;
optionally, the 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 the thread object of the heterogeneous language interface layer in any thread object through a first reflection method;
and c2, calculating a second address at a first offset value corresponding to the first address offset used for storing the heterogeneous language interface layer thread object in any thread object, taking out 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.
FIG. 3 is a flowchart illustrating a method for obtaining 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, an address (hereinafter, referred to as the ptr) of a thread object in a thread object, which is used to store a heterogeneous language interface layer (for example, the heterogeneous language interface layer is a native layer), is obtained through reflection;
then calculate the address where the tptr is offset backward by offset (hereinafter referred to as the tidptr, i.e., the tidptr is the piptr + offset); then the value of pid _ t type is taken 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 includes 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, if the thread value under the linux system corresponding to any thread object is different from the thread value under the target linux system, determining that the corresponding thread object does not exist in the set of thread objects formed by any thread object.
The invention provides a method for acquiring Java threads, 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 solved thread object, thus being capable of accurately acquiring the Java thread object corresponding to the thread value under the linux system without error finding.
Example 2
The embodiment is similar to embodiment 1 in the explanation of the method steps for implementing the method steps as described in embodiment 1 based on the same names and meanings, and has the same technical effects as embodiment 1, and thus the description thereof is omitted. Referring to fig. 4, according to a second aspect of the present invention, the present invention provides an apparatus for obtaining a Java thread, which specifically includes a preprocessing unit 402, an arithmetic unit 404, and a processing unit 406, and 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:
for the getallstacktracks method in which the Thread is a Thread, the method may be other methods besides the above listed methods, and details are not repeated here.
In a specific application scenario, all Thread objects are obtained by a getAllStackTraces method aiming at the Thread being of Thread class.
An operation unit 404, configured to perform an operation on any thread object obtained by the preprocessing unit 402 to obtain a corresponding thread value under the linux system;
and the processing unit 406 is configured to determine whether the thread value in the linux system corresponding to any thread object obtained through the operation performed by the operation unit 404 is the same as the thread value in the target linux system, and if the thread value in the linux system corresponding to any thread object is the same as the thread value in 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 thread objects formed by any thread object.
Optionally, the operation unit 404 is specifically configured to:
acquiring a first address used for storing a thread object of a heterogeneous language interface layer in any thread object by a first reflection method;
and calculating a second address at a first offset value corresponding to the first address offset used for storing the heterogeneous language interface layer thread object in any thread object, taking out 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.
Optionally, the apparatus further comprises:
an initialization unit (not shown in fig. 4) for initializing the software development kit.
Optionally, the initialization unit specifically includes an acquisition subunit and a processing subunit;
the acquisition subunit is to:
acquiring each member of a pointer used for storing a thread object of a heterogeneous language interface layer in a thread; acquiring a second offset value of the thread value under the linux system in the thread object represented by the heterogeneous language interface layer, wherein the second offset value is used for identifying the byte value of the offset;
the processing subunit is to:
and according to the second deviation value, the pointer used for storing the thread object of the heterogeneous language interface layer in the thread points to the position of the deviation second deviation value in the heterogeneous language interface memory, and the thread value under the linux system of the current thread is obtained.
Optionally, the initialization unit is specifically configured to:
according to the second deviation value, the pointer traverses the memory pointed by the address used for storing the thread object of the heterogeneous language interface layer in the current thread, traverses and deviates the byte of the second deviation value until the thread value under the linux system of the current thread is stored in the memory of the heterogeneous language interface, and the thread value under the linux system of the current thread is obtained.
Optionally, before the obtaining subunit obtains the second offset value of the thread value in the representation thread object of the heterogeneous language interface layer under the linux system, the processing subunit is further configured to:
and obtaining a second offset value of the thread value under the linux system in the representation thread object of the heterogeneous language interface layer.
Optionally, the processing subunit is further specifically configured to:
executing a second preset method by the current thread to obtain a thread value under the linux system corresponding to the current thread; wherein the second preset method is a myTid method of the android. The second preset method may be other methods besides the above method, and is not described in detail herein;
in a specific application scene, executing a myTid method of the android.os.process class on a current thread to obtain a thread value (called curTid) under a linux system of the current thread;
acquiring an address used for storing a thread object of a heterogeneous language interface layer in a current thread by a second reflection method;
traversing the memory used for storing the addresses of the thread objects of the heterogeneous language interface layer byte by byte until the thread value under the linux system corresponding to the current thread is stored in the heterogeneous language interface memory, and subtracting the address used for storing the thread objects of the heterogeneous language interface layer in the previous thread from the address of the memory in which the thread value is stored to obtain a value as a second deviation value.
According to the Java thread obtaining device, 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 is judged through the processing unit, and if the thread value under the linux system corresponding to any thread object is judged to be the same as the thread value under the target linux system through the processing unit, the current thread object is the solved thread object, so that the Java thread object corresponding to the thread value under the linux system can be accurately obtained, and the situation of error finding is avoided.
Example 3
As shown in fig. 5, this embodiment provides an electronic device, where the electronic device is used for a method for acquiring a Java thread, and the electronic device includes: at least one processor; and a memory communicatively coupled to the at least one processor; wherein the content of the first and second substances,
the memory stores instructions executable by the one processor to cause the at least one processor to: and accurately acquiring the java thread object corresponding to the thread value in the linux system, and avoiding the error finding condition.
Example 4
The embodiment of the present disclosure provides a non-volatile computer storage medium, where computer-executable instructions are stored, and the computer-executable instructions may execute the method for acquiring a Java thread in any method embodiment described above.
Example 5
Referring now to FIG. 5, shown is a schematic diagram of an electronic device suitable for use in implementing embodiments of the present disclosure. The terminal device in the embodiments of the present disclosure may include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (personal digital assistant), a PAD (tablet computer), a PMP (portable multimedia player), a vehicle terminal (e.g., a car navigation terminal), and the like, and a stationary terminal such as a digital TV, a desktop computer, and the like. The electronic device shown in fig. 5 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 5, the electronic device may include a processing means (e.g., central processing unit, graphics processor, etc.) 501 that 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 necessary for the operation of the electronic apparatus are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. An input/output (I/O) interface 505 is also connected to bus 504.
Generally, the following devices may be connected to the I/O interface 505: input devices 506 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 507 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; storage devices 508 including, for example, magnetic tape, hard disk, etc.; and a communication device 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 illustrates an electronic device having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the 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 illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network via the communication means 509, or installed from the storage means 508, or installed from the ROM 502. The computer program performs the above-described functions defined in the methods of the embodiments of the present disclosure when executed by the processing device 501.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination 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 present 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 contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. 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, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the electronic device; or may exist separately without being assembled 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 can accurately acquire the java thread object corresponding to the thread value in the linux system, and the error finding condition can not occur.
Alternatively, the computer readable medium carries one or more programs which, when executed by the electronic device, cause the electronic device to: the method can accurately acquire the java thread object corresponding to the thread value in the linux system, and the error finding condition can not occur.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of 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 type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart 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 described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of an element does not in some cases constitute a limitation on the element itself.

Claims (11)

1. A method for acquiring a Java thread is characterized by comprising the following steps:
preprocessing according to a first preset method to obtain any thread object;
calculating any thread object to obtain a corresponding thread value under the 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 of claim 1, further comprising:
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.
3. The method according to claim 1, wherein the operating any thread object to obtain a corresponding thread value under the linux system comprises:
acquiring a first address used for storing a thread object of a heterogeneous language interface layer in any thread object by a first reflection method;
and calculating a second address at a first offset value corresponding to a first address offset used for storing the heterogeneous language interface layer thread object in any thread object, taking out 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.
4. The method of claim 1, further comprising:
the software development kit is initialized.
5. The method of claim 4, wherein initializing the software development kit comprises:
acquiring each member of a pointer used for storing a thread object of a heterogeneous language interface layer in a thread;
acquiring a second offset value of the thread value in the representation thread object of the heterogeneous language interface layer under the linux system, wherein the second offset value is used for identifying the byte value of the offset;
and according to the second deviation value, the pointer used for storing the thread object of the heterogeneous language interface layer in the thread points to the position deviated from the second deviation value in the heterogeneous language interface memory, and a thread value under the linux system of the current thread is obtained.
6. The method according to claim 5, wherein the obtaining, according to the second offset value, the thread value under the linux system of the current thread by using the pointer in the thread for storing the thread object of the heterogeneous language interface layer to point to a position offset from the second offset value in the heterogeneous language interface memory comprises:
according to the second deviation value, the pointer traverses the memory pointed by the address used for storing the heterogeneous language interface layer thread object in the current thread, traverses and deviates the byte of the second deviation value until the thread value under the linux system of the current thread stored in the heterogeneous language interface memory is reached, and the thread value under the linux system of the current thread is obtained.
7. The method of claim 5, wherein before the obtaining the second offset value of the thread value under the linux system in the representation thread object of the heterogeneous language interface layer, the method further comprises:
and obtaining the second offset value of the thread value under the linux system in the representation thread object of the heterogeneous language interface layer.
8. The method according to claim 7, wherein the obtaining the second offset value of the thread value under the linux system in the representation thread object of the heterogeneous language interface layer comprises:
executing a second preset method by the current thread to obtain a thread value under the linux system corresponding to the current thread;
acquiring an address used for storing a thread object of a heterogeneous language interface layer in a current thread by a second reflection method;
traversing the memory used for storing the addresses of the thread objects of the heterogeneous language interface layer byte by byte until the thread value under the linux system corresponding to the current thread is stored in the heterogeneous language interface memory, and subtracting the address used for storing the thread objects of the heterogeneous language interface layer in the previous thread from the address of the memory where the thread value is located, wherein the obtained value is the second deviation value.
9. An apparatus for obtaining 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 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 of 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.
10. A computer-readable storage medium, on which a computer program is stored, which program, when being executed by a processor, carries out the method according to any one of claims 1 to 8.
11. 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 carry out the method of any one of claims 1 to 8.
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 true CN110908860A (en) 2020-03-24
CN110908860B 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)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111767155A (en) * 2020-08-06 2020-10-13 腾讯科技(深圳)有限公司 Deadlock detection method, device, equipment and computer readable storage medium
CN111813663A (en) * 2020-06-19 2020-10-23 北京字节跳动网络技术有限公司 Pointer type identification method, device, medium and equipment

Citations (7)

* 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
US20050273782A1 (en) * 2004-06-03 2005-12-08 Intel Corporation Thread synchronization methods and apparatus for managed run-time environments
US20110173592A1 (en) * 2010-01-13 2011-07-14 International Business Machines Corporation Architectural Support for Automated Assertion Checking
CN108763060A (en) * 2018-04-27 2018-11-06 广州华多网络科技有限公司 Native layers of collapse source tracing method, device, storage medium and terminal in android system
CN109298901A (en) * 2018-08-29 2019-02-01 百度在线网络技术(北京)有限公司 Object processing method, device, equipment, storage medium and vehicle
CN109918145A (en) * 2019-01-10 2019-06-21 北京字节跳动网络技术有限公司 A kind of accelerated method, the device, electronic equipment of application program cold start-up
CN110377341A (en) * 2019-06-10 2019-10-25 北京字节跳动网络技术有限公司 A kind of method, apparatus, medium and electronic equipment of the monitoring without response abnormality

Patent Citations (7)

* 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
US20050273782A1 (en) * 2004-06-03 2005-12-08 Intel Corporation Thread synchronization methods and apparatus for managed run-time environments
US20110173592A1 (en) * 2010-01-13 2011-07-14 International Business Machines Corporation Architectural Support for Automated Assertion Checking
CN108763060A (en) * 2018-04-27 2018-11-06 广州华多网络科技有限公司 Native layers of collapse source tracing method, device, storage medium and terminal in android system
CN109298901A (en) * 2018-08-29 2019-02-01 百度在线网络技术(北京)有限公司 Object processing method, device, equipment, storage medium and vehicle
CN109918145A (en) * 2019-01-10 2019-06-21 北京字节跳动网络技术有限公司 A kind of accelerated method, the device, electronic equipment of application program cold start-up
CN110377341A (en) * 2019-06-10 2019-10-25 北京字节跳动网络技术有限公司 A kind of method, apparatus, medium and electronic equipment of the monitoring without response abnormality

Non-Patent Citations (4)

* Cited by examiner, † Cited by third party
Title
BINCDS: "Android获取当前进程和线程ID常用方法总结" *
PWL999: "通过线程对象偏移地址获取线程id" *
李湘宁;凌捷;: "改进的隐藏进程检测查杀技术", 计算机工程与设计, no. 11 *
潘茂如;曹天杰;: "基于直接操作内核对象的进程隐藏技术研究", no. 18 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111813663A (en) * 2020-06-19 2020-10-23 北京字节跳动网络技术有限公司 Pointer type identification method, device, medium and equipment
CN111813663B (en) * 2020-06-19 2024-03-22 北京字节跳动网络技术有限公司 Pointer type identification method, device, medium and equipment
CN111767155A (en) * 2020-08-06 2020-10-13 腾讯科技(深圳)有限公司 Deadlock detection method, device, equipment and computer readable storage medium

Also Published As

Publication number Publication date
CN110908860B (en) 2023-06-09

Similar Documents

Publication Publication Date Title
CN110502357B (en) Stack backtracking method, device, medium and 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
US20130007613A1 (en) System to overlay application help on a mobile device
CN110912870B (en) Method, device, medium and electronic equipment for synchronizing data of electronic whiteboard
CN110489165B (en) Method, device, medium and equipment for acquiring call stack frame instruction offset
CN110619085B (en) Information processing method and device
CN110908860A (en) Method, device, medium and electronic equipment for acquiring Java threads
CN111738316B (en) Zero sample learning image classification method and device and electronic equipment
CN110673986A (en) Memory operation abnormity capturing method, device, terminal and storage medium
CN110489041B (en) Method, device, equipment and medium for automatically aligning small program dragging elements
CN110188782B (en) Image similarity determining method and device, electronic equipment and readable storage medium
CN111626990B (en) Target detection frame processing method and device and electronic equipment
CN110487264B (en) Map correction method, map correction device, electronic equipment and storage medium
CN110888773B (en) Method, device, medium and electronic equipment for acquiring thread identification
CN109408387B (en) Page testing method and device
CN110674050A (en) Memory out-of-range detection method and device, electronic equipment and computer storage medium
CN111290812B (en) Display method, device, terminal and storage medium of application control
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
CN110929241A (en) Rapid start method, device, medium and electronic equipment of small program
CN111738311A (en) Multitask-oriented feature extraction method and device and electronic equipment
CN111813663B (en) Pointer type identification method, device, medium and equipment
CN111586261B (en) Target video processing method and device and electronic equipment
CN111813664B (en) Crash information collection method, device, medium and equipment

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