2012-03-14 05:52:00 +08:00
|
|
|
"""
|
|
|
|
LLDB AppKit formatters
|
|
|
|
|
2019-01-19 16:50:56 +08:00
|
|
|
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2012-03-14 05:52:00 +08:00
|
|
|
"""
|
2012-09-05 02:47:54 +08:00
|
|
|
# example summary provider for NSData
|
|
|
|
# the real summary is now C++ code built into LLDB
|
2012-02-24 07:10:27 +08:00
|
|
|
import lldb
|
|
|
|
import ctypes
|
2012-04-25 09:39:27 +08:00
|
|
|
import lldb.runtime.objc.objc_runtime
|
|
|
|
import lldb.formatters.metrics
|
|
|
|
import lldb.formatters.Logger
|
2012-02-24 07:10:27 +08:00
|
|
|
|
2019-03-25 23:21:29 +08:00
|
|
|
try:
|
|
|
|
basestring
|
|
|
|
except NameError:
|
|
|
|
basestring = str
|
|
|
|
|
2012-04-25 09:39:27 +08:00
|
|
|
statistics = lldb.formatters.metrics.Metrics()
|
2012-02-24 07:10:27 +08:00
|
|
|
statistics.add_metric('invalid_isa')
|
|
|
|
statistics.add_metric('invalid_pointer')
|
|
|
|
statistics.add_metric('unknown_class')
|
|
|
|
statistics.add_metric('code_notrun')
|
|
|
|
|
|
|
|
# despite the similary to synthetic children providers, these classes are not
|
|
|
|
# trying to provide anything but the length for an NSData, so they need not
|
|
|
|
# obey the interface specification for synthetic children providers
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
|
2012-02-24 07:10:27 +08:00
|
|
|
class NSConcreteData_SummaryProvider:
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-24 07:10:27 +08:00
|
|
|
def adjust_for_architecture(self):
|
2012-03-06 03:56:33 +08:00
|
|
|
pass
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-03-06 03:56:33 +08:00
|
|
|
def __init__(self, valobj, params):
|
2012-04-25 09:39:27 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "NSConcreteData_SummaryProvider __init__"
|
2012-02-24 07:10:27 +08:00
|
|
|
self.valobj = valobj
|
2012-03-06 03:56:33 +08:00
|
|
|
self.sys_params = params
|
|
|
|
if not(self.sys_params.types_cache.NSUInteger):
|
|
|
|
if self.sys_params.is_64_bit:
|
|
|
|
self.sys_params.types_cache.NSUInteger = self.valobj.GetType(
|
|
|
|
).GetBasicType(lldb.eBasicTypeUnsignedLong)
|
|
|
|
else:
|
|
|
|
self.sys_params.types_cache.NSUInteger = self.valobj.GetType(
|
|
|
|
).GetBasicType(lldb.eBasicTypeUnsignedInt)
|
2012-02-24 07:10:27 +08:00
|
|
|
self.update()
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-24 07:10:27 +08:00
|
|
|
def update(self):
|
|
|
|
self.adjust_for_architecture()
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-24 07:10:27 +08:00
|
|
|
# one pointer is the ISA
|
|
|
|
# then there are 32 bit worth of flags and other data
|
|
|
|
# however, on 64bit systems these are padded to be a full
|
|
|
|
# machine word long, which means we actually have two pointers
|
|
|
|
# worth of data to skip
|
|
|
|
def offset(self):
|
2012-03-06 03:56:33 +08:00
|
|
|
return 2 * self.sys_params.pointer_size
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-24 07:10:27 +08:00
|
|
|
def length(self):
|
2012-04-25 09:39:27 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "NSConcreteData_SummaryProvider length"
|
2012-02-24 07:10:27 +08:00
|
|
|
size = self.valobj.CreateChildAtOffset(
|
2012-03-06 03:56:33 +08:00
|
|
|
"count", self.offset(), self.sys_params.types_cache.NSUInteger)
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> str(size)
|
|
|
|
logger >> str(size.GetValueAsUnsigned(0))
|
2012-02-24 07:10:27 +08:00
|
|
|
return size.GetValueAsUnsigned(0)
|
|
|
|
|
|
|
|
|
|
|
|
class NSDataUnknown_SummaryProvider:
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-24 07:10:27 +08:00
|
|
|
def adjust_for_architecture(self):
|
2012-03-06 03:56:33 +08:00
|
|
|
pass
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-03-06 03:56:33 +08:00
|
|
|
def __init__(self, valobj, params):
|
2012-04-25 09:39:27 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "NSDataUnknown_SummaryProvider __init__"
|
2012-02-24 07:10:27 +08:00
|
|
|
self.valobj = valobj
|
2012-03-06 03:56:33 +08:00
|
|
|
self.sys_params = params
|
|
|
|
self.update()
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-24 07:10:27 +08:00
|
|
|
def update(self):
|
|
|
|
self.adjust_for_architecture()
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-24 07:10:27 +08:00
|
|
|
def length(self):
|
2012-04-25 09:39:27 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "NSDataUnknown_SummaryProvider length"
|
2012-02-24 07:10:27 +08:00
|
|
|
stream = lldb.SBStream()
|
|
|
|
self.valobj.GetExpressionPath(stream)
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> stream.GetData()
|
2012-02-24 07:10:27 +08:00
|
|
|
num_children_vo = self.valobj.CreateValueFromExpression(
|
|
|
|
"count", "(int)[" + stream.GetData() + " length]")
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "still in after expression: " + str(num_children_vo)
|
2012-03-14 05:52:00 +08:00
|
|
|
if num_children_vo.IsValid():
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "wow - expr output is valid: " + \
|
|
|
|
str(num_children_vo.GetValueAsUnsigned())
|
2012-03-14 05:52:00 +08:00
|
|
|
return num_children_vo.GetValueAsUnsigned(0)
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "invalid expr output - too bad"
|
2012-03-14 05:52:00 +08:00
|
|
|
return '<variable is not NSData>'
|
2012-02-24 07:10:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
def GetSummary_Impl(valobj):
|
|
|
|
global statistics
|
2012-04-25 09:39:27 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "NSData GetSummary_Impl"
|
2012-04-26 01:53:41 +08:00
|
|
|
class_data, wrapper = lldb.runtime.objc.objc_runtime.Utilities.prepare_class_detection(
|
|
|
|
valobj, statistics)
|
2012-03-14 05:52:00 +08:00
|
|
|
if wrapper:
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "got a wrapper summary - using it"
|
2012-03-14 05:52:00 +08:00
|
|
|
return wrapper
|
2016-09-07 04:57:50 +08:00
|
|
|
|
2012-02-24 07:10:27 +08:00
|
|
|
name_string = class_data.class_name()
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "class name: " + name_string
|
2012-02-24 07:10:27 +08:00
|
|
|
if name_string == 'NSConcreteData' or \
|
|
|
|
name_string == 'NSConcreteMutableData' or \
|
|
|
|
name_string == '__NSCFData':
|
2012-03-06 03:56:33 +08:00
|
|
|
wrapper = NSConcreteData_SummaryProvider(valobj, class_data.sys_params)
|
2012-02-24 07:10:27 +08:00
|
|
|
statistics.metric_hit('code_notrun', valobj)
|
|
|
|
else:
|
2012-03-06 03:56:33 +08:00
|
|
|
wrapper = NSDataUnknown_SummaryProvider(valobj, class_data.sys_params)
|
2012-03-30 08:51:12 +08:00
|
|
|
statistics.metric_hit(
|
|
|
|
'unknown_class',
|
|
|
|
valobj.GetName() +
|
|
|
|
" seen as " +
|
|
|
|
name_string)
|
2012-02-24 07:10:27 +08:00
|
|
|
return wrapper
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
|
2012-02-24 07:10:27 +08:00
|
|
|
def NSData_SummaryProvider(valobj, dict):
|
2012-04-25 09:39:27 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "NSData_SummaryProvider"
|
2012-02-24 07:10:27 +08:00
|
|
|
provider = GetSummary_Impl(valobj)
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "found a summary provider, it is: " + str(provider)
|
2012-02-24 07:10:27 +08:00
|
|
|
if provider is not None:
|
2012-03-14 05:52:00 +08:00
|
|
|
try:
|
|
|
|
summary = provider.length()
|
|
|
|
except:
|
|
|
|
summary = None
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "got a summary: it is " + str(summary)
|
2012-03-14 05:52:00 +08:00
|
|
|
if summary is None:
|
|
|
|
summary = '<variable is not NSData>'
|
|
|
|
elif isinstance(summary, basestring):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
if summary == 1:
|
|
|
|
summary = '1 byte'
|
|
|
|
else:
|
|
|
|
summary = str(summary) + ' bytes'
|
|
|
|
return summary
|
|
|
|
return 'Summary Unavailable'
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
|
2012-03-13 08:25:59 +08:00
|
|
|
def NSData_SummaryProvider2(valobj, dict):
|
2012-04-25 09:39:27 +08:00
|
|
|
logger = lldb.formatters.Logger.Logger()
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "NSData_SummaryProvider2"
|
2012-03-13 08:25:59 +08:00
|
|
|
provider = GetSummary_Impl(valobj)
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "found a summary provider, it is: " + str(provider)
|
2012-03-13 08:25:59 +08:00
|
|
|
if provider is not None:
|
2012-04-26 01:53:41 +08:00
|
|
|
if isinstance(
|
|
|
|
provider,
|
|
|
|
lldb.runtime.objc.objc_runtime.SpecialSituation_Description):
|
2012-03-14 05:52:00 +08:00
|
|
|
return provider.message()
|
|
|
|
try:
|
|
|
|
summary = provider.length()
|
|
|
|
except:
|
|
|
|
summary = None
|
Part 1 of a series of fixes meant to improve reliability and increase ease of bug fixing for data formatter issues.
We are introducing a new Logger class on the Python side. This has the same purpose, but is unrelated, to the C++ logging facility
The Pythonic logging can be enabled by using the following scripting commands:
(lldb) script Logger._lldb_formatters_debug_level = {0,1,2,...}
0 = no logging
1 = do log
2 = flush after logging each line - slower but safer
3 or more = each time a Logger is constructed, log the function that has created it
more log levels may be added, each one being more log-active than the previous
by default, the log output will come out on your screen, to direct it to a file:
(lldb) script Logger._lldb_formatters_debug_filename = 'filename'
that will make the output go to the file - set to None to disable the file output and get screen logging back
Logging has been enabled for the C++ STL formatters and for Cocoa class NSData - more logging will follow
synthetic children providers for classes list and map (both libstdcpp and libcxx) now have internal capping for safety reasons
this will fix crashers where a malformed list or map would not ever meet our termination conditions
to set the cap to a different value:
(lldb) script {gnu_libstdcpp|libcxx}.{map|list}_capping_size = new_cap (by default, it is 255)
you can optionally disable the loop detection algorithm for lists
(lldb) script {gnu_libstdcpp|libcxx}.list_uses_loop_detector = False
llvm-svn: 153676
2012-03-30 03:29:45 +08:00
|
|
|
logger >> "got a summary: it is " + str(summary)
|
2012-03-14 05:52:00 +08:00
|
|
|
if summary is None:
|
|
|
|
summary = '<variable is not CFData>'
|
|
|
|
elif isinstance(summary, basestring):
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
if summary == 1:
|
|
|
|
summary = '@"1 byte"'
|
|
|
|
else:
|
|
|
|
summary = '@"' + str(summary) + ' bytes"'
|
|
|
|
return summary
|
|
|
|
return 'Summary Unavailable'
|
2016-09-07 04:57:50 +08:00
|
|
|
|
|
|
|
|
2012-02-24 07:10:27 +08:00
|
|
|
def __lldb_init_module(debugger, dict):
|
2012-03-13 08:25:59 +08:00
|
|
|
debugger.HandleCommand(
|
|
|
|
"type summary add -F NSData.NSData_SummaryProvider NSData")
|
|
|
|
debugger.HandleCommand(
|
|
|
|
"type summary add -F NSData.NSData_SummaryProvider2 CFDataRef CFMutableDataRef")
|