编程知识 cdmana.com

Lldb: introduction to sbexpression options

A talk LLDB:SBExpressionOptions brief introduction

Preface

The first thing to say is this , This article is just a summary of my experience , There's no guarantee that it's completely right . If there is any mistake or omission, please leave a message for correction .
The reason why I want to write this article , Because of my open source project HMLLDB There's a core function HMLLDBHelpers.evaluateExpressionValue, It uses SBExpressionOptions This option , If you don't explain , It's not easy to explain the related articles to be written in the future .
in addition LLDB Self contained expression command There are some Options and SBExpressionOptions It's a correspondence , Readers can compare it by name .

SBExpressionOptions What is it?

If it works SB API Words , It must be true SBExpressionOptions Have an impression , Whether it's SBTarget still SBFrame There is one. EvaluateExpression Functions are used to execute code expressions ( There is a difference between the two , I'll talk about it later ), And this function parameter supports passing in a SBExpressionOptions object , Just look at the name to see what it's for , Attach an official document describing this kind of :

A container for options to use when evaluating expressions.

SBExpressionOptions Method explanation

Method explain
SetCoerceResultToId After executing the expression , Whether to cast the result to id type
SetFetchDynamicValue You can convert the result to a dynamic type . You can set 3 It's worth , In turn, is eNoDynamicValues(0),eDynamicCanRunTarget(1),eDynamicDontRunTarget(2). If one NSArray * object ,0 Expressed as NSArray * type ,1、2 Is represented as __NSArrayI * type
SetUnwindOnError Whether to backtrack stack information on error
SetIgnoreBreakpoints When you execute an expression , Whether to ignore the hit of breakpoint
SetGenerateDebugInfo The official explanation is to set whether debug information is generated for the expression , It also controls whether to generate SBModule. But I didn't test the difference , I don't know yet
SetTimeoutInMicroSeconds The timeout for executing the expression , In microseconds , Set to 0 Never time out
SetOneThreadTimeoutInMicroSeconds The time-out of executing an expression on a thread , Microsecond , Must be less than GetTimeoutInMicroSeconds Value
SetTryAllThreads If the expression is not completed on a thread , Whether to run all threads
SetStopOthers Whether to stop other threads when the expression is executed
SetTrapExceptions If executing an expression throws an exception , Whether to suspend execution
SetPlaygroundTransformEnabled This function is not available on the official website , There is no source code , The meaning is not clear
SetREPLMode This function is not available on the official website , There is no source code , The meaning is not clear
SetLanguage Set the language of the expression LanguageType, Commonly used eLanguageTypeObjCeLanguageTypeObjC_plus_pluseLanguageTypeSwift. If it is not set, the language type will be inferred according to the context
SetSuppressPersistentResult Set to True, The result of the expression is not persistent . Another thing to note ,LLDB There is no automatic insert for just in time compilation of ARC Released code , In the expression alloc The object of , It doesn't release , So not releasing objects has nothing to do with this configuration
SetPrefix Set the expression prefix .LLDB It is often used in typedef, You can configure it first , You can also configure macro definitions
SetAutoApplyFixIts Set to True, If the expression has a simple spelling error , It will automatically correct
SetRetriesWithFixIts Number of attempts to fix (Xcode 12.5 newly added )
SetTopLevel Ignore context , Resolves an expression to a top-level entity . For example, it can be set to True, Define a... In an expression C An external function or variable of a language .
SetAllowJIT If you can't parse the expression , Whether to compile in real time

SBExpressionOptions The default value of

install HMLLDB, Run any one of them iOS project , Get into LLDB After debugging mode , Can pass plldbClassInfo SBExpressionOptions Command to see its default values

Method The default value is
GetCoerceResultToId False
GetFetchDynamicValue 0, namely eNoDynamicValues
GetUnwindOnError True
GetIgnoreBreakpoints False
GetGenerateDebugInfo False
GetTimeoutInMicroSeconds 500000
GetOneThreadTimeoutInMicroSeconds 0
GetTryAllThreads True
GetStopOthers True
GetTrapExceptions True
GetPlaygroundTransformEnabled False
GetREPLMode False
SetLanguage There is no counterpart Get Method , If it is not set, the language type will be inferred according to the context .
GetSuppressPersistentResult False
GetPrefix None
GetAutoApplyFixIts True
GetRetriesWithFixIts 1
GetTopLevel False
GetAllowJIT True

HMLLDB Project configuration

The relevant configuration is HMLLDBHelpers.py Of documents evaluateExpressionValue You can see in the function .

Method To configure
SetCoerceResultToId False, Because the return is SBValue,SBValue More maneuverability
SetFetchDynamicValue eNoDynamicValues(0), Because the return is SBValue, You can get dynamic type values by itself , This setting ensures maximum operability
SetUnwindOnError True,LLDB Unstable execution , It's better to have stack information debug
SetIgnoreBreakpoints True,HMLLDB All commands do not need to hit breakpoints to break
SetGenerateDebugInfo False, Don't understand , Keep the default
SetTimeoutInMicroSeconds 5000000, namely 5 second
SetOneThreadTimeoutInMicroSeconds 4900000, namely 4.9 second . When SetTryAllThreads and SetStopOthers All set to True when , This method is best set to a value slightly less than GetTimeoutInMicroSeconds
SetTryAllThreads True, Don't understand , Keep the default
SetStopOthers True, Don't understand , Literally , Set to True It can ensure the stability of execution
SetTrapExceptions False,HMLLDB Yes Traceback Mechanism , This configuration doesn't make much sense . If it's mostly runtime error , Set to False It allows the system to automatically capture
SetPlaygroundTransformEnabled False, The meaning is not clear , Keep default
SetREPLMode False, The meaning is not clear , Keep default
SetLanguage eLanguageTypeObjC_plus_plus,OC Than Swift Stable , And HMLLDB The project uses a lot of objc_msgSend function , Therefore, it is not selected Swift. choose OC++ To increase compatibility
SetSuppressPersistentResult True, Expression results don't need to be persistent
SetPrefix The details can be found in HMExpressionPrefix.py file . According to the actual situation of the expression , On demand configuration
SetAutoApplyFixIts True,HMLLDB It's fixed code , This configuration doesn't make much sense , Keep default
SetRetriesWithFixIts 1,HMLLDB It's fixed code , This configuration doesn't make much sense , Keep default
SetTopLevel False, At present, the function does not need to define external functions and external variables , Future period
SetAllowJIT True, Most of the features are necessary .

Related articles

版权声明
本文为[mao2020]所创,转载请带上原文链接,感谢
https://cdmana.com/2021/05/20210521161656525G.html

Scroll to Top