Exemple #1
0
    def classpaths(self):
        """Retrieve the classpath and bootclasspath of the target VM. If the
        classpath is not defined, returns an empty list. If the bootclasspath
        is not defined returns an empty list.
        """
        response = self.send_command("VM::ClassPaths")
        (base_dir, count, off) = parser.unpack(response, "si", add_offset=True)
        classpaths = []

        while len(classpaths) < count:
            path = parser.unpack(response[off:], "s", add_offset=True)
            off += path.pop()
            path = path.pop()
            classpaths.append(path)

        # Get the count of boot class paths
        count = parser.unpack_int(response[off:])
        off += 4

        bootclasspaths = []

        while len(bootclasspaths) < count:
            path = parser.unpack(response[off:], "s", add_offset=True)
            off += path.pop()
            path = path.pop()
            bootclasspaths.append(path)

        return (classpaths, bootclasspaths)
Exemple #2
0
    def classpaths(self):
        """Retrieve the classpath and bootclasspath of the target VM. If the
        classpath is not defined, returns an empty list. If the bootclasspath
        is not defined returns an empty list.
        """
        response = self.send_command("VM::ClassPaths")
        (base_dir, count, off) = parser.unpack(response, "si", add_offset=True)
        classpaths = []

        while len(classpaths) < count:
            path = parser.unpack(response[off:], "s", add_offset=True)
            off += path.pop()
            path = path.pop()
            classpaths.append(path)

        # Get the count of boot class paths
        count = parser.unpack_int(response[off:])
        off += 4

        bootclasspaths = []

        while len(bootclasspaths) < count:
            path = parser.unpack(response[off:], "s", add_offset=True)
            off += path.pop()
            path = path.pop()
            bootclasspaths.append(path)

        return (classpaths, bootclasspaths)
Exemple #3
0
 def capabilities_old(self):
     """Retrieve this VM's capabilities. The capabilities are returned as
     booleans, each indicating the presence or absence of a capability. The
     commands associated with each capability will return the
     NOT_IMPLEMENTED error if the cabability is not available.
     """
     response = self.send_command("VM::Capabilities")
     unpacked = parser.unpack(response, "?" * 7)
     return tuple(unpacked)
Exemple #4
0
 def capabilities_old(self):
     """Retrieve this VM's capabilities. The capabilities are returned as
     booleans, each indicating the presence or absence of a capability. The
     commands associated with each capability will return the
     NOT_IMPLEMENTED error if the cabability is not available.
     """
     response = self.send_command("VM::Capabilities")
     unpacked = parser.unpack(response, "?" * 7)
     return tuple(unpacked)
Exemple #5
0
    def get_threadgroups(self):
        """Return a list of thread groups."""
        data = self.send_command("VM::TopLevelThreadGroups")
        count = parser.unpack_int(data)
        offset = 4
        groups = []

        while len(groups) < count:
            group_data = parser.unpack(data[offset:], "o", add_offset=True)
            offset += group_data.pop()
            group_id = group_data.pop()
            groups.append(group_id)

        return groups
Exemple #6
0
    def get_threadgroups(self):
        """Return a list of thread groups."""
        data = self.send_command("VM::TopLevelThreadGroups")
        count = parser.unpack_int(data)
        offset = 4
        groups = []

        while len(groups) < count:
            group_data = parser.unpack(data[offset:], "o", add_offset=True)
            offset += group_data.pop()
            group_id = group_data.pop()
            groups.append(group_id)

        return groups
Exemple #7
0
    def get_threads(self):
        """Return a list of threads."""
        data = self.send_command("VM::AllThreads")
        count = parser.unpack_int(data)
        offset = 4
        threads = []

        while len(threads) < count:
            thread_data = parser.unpack(data[offset:], "o", add_offset=True)
            offset += thread_data.pop()
            thread_id = thread_data.pop()
            threads.append(thread_id)

        return threads
Exemple #8
0
    def get_threads(self):
        """Return a list of threads."""
        data = self.send_command("VM::AllThreads")
        count = parser.unpack_int(data)
        offset = 4
        threads = []

        while len(threads) < count:
            thread_data = parser.unpack(data[offset:], "o", add_offset=True)
            offset += thread_data.pop()
            thread_id = thread_data.pop()
            threads.append(thread_id)

        return threads
Exemple #9
0
    def get_classes(self):
        """Returns the list of all the classes currently loaded."""
        format = "brsi"
        data = self.send_command("VM::AllClasses")
        count = parser.unpack_int(data)
        classes = []
        offset = 4

        while len(classes) < count:
            class_data = parser.unpack(data[offset:], format, add_offset=True)
            offset += class_data.pop()
            (cid, cadd, sig, status) = class_data
            while sig and sig[0] in const.jni_types:
                sig = sig[1:]
            while sig and sig[-1] in (";", ):
                sig = sig[:-1]
            sig = sig.split("$")[0]
            sig = sig.replace("/", ".")
            classes.append(sig)

        return sorted(list(set(classes)))
Exemple #10
0
    def get_classes(self):
        """Returns the list of all the classes currently loaded."""
        format = "brsi"
        data = self.send_command("VM::AllClasses")
        count = parser.unpack_int(data)
        classes = []
        offset = 4

        while len(classes) < count:
            class_data = parser.unpack(data[offset:], format, add_offset=True)
            offset += class_data.pop()
            (cid, cadd, sig, status) = class_data
            while sig and sig[0] in const.jni_types:
                sig = sig[1:]
            while sig and sig[-1] in (";",):
                sig = sig[:-1]
            sig = sig.split("$")[0]
            sig = sig.replace("/", ".")
            classes.append(sig)

        return sorted(list(set(classes)))
Exemple #11
0
 def do_vmversion(self, msg):
     """Returns the VM version number."""
     f = "siiss"
     data = parser.unpack(self.send_command("VM::Version"), f)
     (description, jdwp_major, jdwp_minor, vm_version, vm_name) = data
     print(description)
Exemple #12
0
 def _callback(data):
     f = "siiss"
     data = parser.unpack(data, f)
     (description, jdwp_major, jdwp_minor, vm_version, vm_name) = data
     print(description)
Exemple #13
0
 def get_sizes(self):
     """Load the object sizes in the instance."""
     return parser.unpack(self.send_command("VM::IDSizes"), "iiiii")
Exemple #14
0
 def create_string(self, s):
     """Creates a new string object in the target VM and returns its id."""
     packed_s = parser.pack_string(s)
     response = self.send_command("VM::CreateString", data=packed_s)
     unpacked = parser.unpack(response, "o")
     return unpacked.pop()
Exemple #15
0
 def create_string(self, s):
     """Creates a new string object in the target VM and returns its id."""
     packed_s = parser.pack_string(s)
     response = self.send_command("VM::CreateString", data=packed_s)
     unpacked = parser.unpack(response, "o")
     return unpacked.pop()
Exemple #16
0
 def do_vmversion(self, msg):
     """Returns the VM version number."""
     f = "siiss"
     data = parser.unpack(self.send_command("VM::Version"), f)
     (description, jdwp_major, jdwp_minor, vm_version, vm_name) = data
     print(description)
Exemple #17
0
 def _callback(data):
     f = "siiss"
     data = parser.unpack(data, f)
     (description, jdwp_major, jdwp_minor, vm_version, vm_name) = data
     print(description)
Exemple #18
0
 def get_sizes(self):
     """Load the object sizes in the instance."""
     return parser.unpack(self.send_command("VM::IDSizes"), "iiiii")