Comments (18)
Reference: when you Quick Look a color in the variables list:
from chisel.
Nice. Can I interest you in trying a pull request 😄
from chisel.
Definitely interested. I’ll put it on my list for my job’s semi-weekly hack days.
from chisel.
Let me know if you have any questions, happy to answer anything.
from chisel.
@kastiglione would it be a faux pas to expr @import CoreFoundation
in my command? I'm trying to have it be able to differentiate between UIColor
, CIColor
, and CGColor
(and maybe NSColor
?)
from chisel.
Specifically:
result = frame.EvaluateExpression('(CFTypeID)CFGetTypeID({color}) == (CFTypeID)CGColorGetTypeID()'.format(color=color))
from chisel.
would it be a faux pas to
expr @import CoreFoundation
in my command?
Nah. In fact I think it would be great to do, UIKit
too. Thinking aloud, I wonder if it could be done on the first time any breakpoint is hit. Then by using Chisel, you get these for free.
from chisel.
Not to give you scope creep, feel free to put it in your command only. Someone can look to make it more general later.
from chisel.
I've seen it advised to always import UIKit on an exception breakpoint. I had put a UIKit import in my ~/.lldbinit
, but it seemed to slow down Xcode every time I started a debugging session. I'll try again some time.
Current question: here's an error I'm getting in lldb:
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'CGColorRef' (aka 'CGColor *')
From a python line like this:
colorToUse = '[UIColor colorWithCGColor:(CGColorRef){}]'.format(color)
Seen anything like this?
from chisel.
Or, to simplify the question, what is the right way to call this in lldb
?
po [UIColor colorWithCGColor:(CGColorRef)[[UIColor redColor] CGColor]]
from chisel.
Cast the color to void *
?
from chisel.
Nope:
(lldb) po [UIColor colorWithCGColor:(void *)[[UIColor redColor] CGColor]]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'void *'
error: 1 errors parsing expression
(assuming that's what you meant?)
from chisel.
Yup, that is what I meant. Hmm. Maybe one of:
po [UIColor colorWithCGColor:(id)[[UIColor redColor] CGColor]]
po [UIColor colorWithCGColor:(CGColor *)[[UIColor redColor] CGColor]]
po [UIColor colorWithCGColor:(CGColor *)(void *)[[UIColor redColor] CGColor]]
from chisel.
Oh, I'm curious why you're going from UIColor
to CGColor
to UIColor
?
from chisel.
Just a simple test case to reproduce what I’m seeing in the script with a CGColor
. I didn’t have a CGColor
handy in an app, so I was making one from a UIColor
in the debugger. If I can make a CGColor
in code and reference it in the script and it works, I guess I will ignore this issue for now as an edge case. I’ll try that, and your suggestions.
from chisel.
None of the suggestions worked, but worse, the actual case I'm trying to use also doesn't work. If I'm on a breakpoint and I have a local variable, cgColor
, of type CGColorRef
:
(lldb) po cgColor
<CGColor 0x7fdfa0546910> [<CGColorSpace 0x7fdfa0643f70> (kCGColorSpaceDeviceRGB)] ( 0 0.478431 1 1 )
(lldb) po [UIColor colorWithCGColor:cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an lvalue of type 'CGColorRef' (aka 'CGColor *')
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(id)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'id'
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(CGColorRef)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'CGColorRef' (aka 'CGColor *')
error: 1 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(CGColor *)cgColor]
error: use of undeclared identifier 'CGColor'
error: expected expression
error: 2 errors parsing expression
(lldb) po [UIColor colorWithCGColor:(struct CGColor *)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'struct CGColor *'
error: 1 errors parsing expression
(lldb) expr @import CoreGraphics
(lldb) po [UIColor colorWithCGColor:(struct CGColor *)cgColor]
error: cannot initialize a parameter of type 'CGColor *' with an rvalue of type 'struct CGColor *'
error: 1 errors parsing expression
So I can't use it in my script because it doesn't even work in the real debugger, at least not with the incantations I'm using.
from chisel.
It looks like this is maybe already done in chisel? Does this code work? https://github.com/facebook/chisel/blob/master/commands/FBAutoLayoutCommands.py#L44
lldb.debugger.HandleCommand('expr (void)[%s setBorderColor:(CGColorRef)[(id)[UIColor %sColor] CGColor]]' % (layer, color))
from chisel.
@kastiglione alright, I got a workaround thanks to @jvisenti: http://stackoverflow.com/a/31810890/255489
I believe it's related to the UIColor going out of scope, and -CGColor
returning an internal pointer:
@property(nonatomic,readonly) CGColorRef CGColor;
- (CGColorRef)CGColor NS_RETURNS_INNER_POINTER CF_RETURNS_NOT_RETAINED;
PR should be in at some point soon-ish
from chisel.
Related Issues (20)
- pviews AttributeError: 'NoneType' object has no attribute 'split' ? HOT 1
- pjson not show Chinese HOT 8
- chisel load failed HOT 8
- install fail HOT 1
- error
- 'pvc' is not a valid command.
- error: (lldb) command script import /usr/local/opt/chisel/libexec/fblldb.py HOT 4
- error: module importing failed: invalid pathname HOT 11
- taplog error in ios14 HOT 5
- bmessage cause a error message
- visualize is not woking on Mac App
- Xcode 12.3 NameError: name 'lldb' is not defined HOT 1
- Not work in xcode 13
- CG_CONTEXT_SHOW_BACKTRACE required?
- [Xcode 13] LLDB RPC server has crashed HOT 1
- Failed applying an ad-hoc signature to xxx HOT 1
- do you want to support python3??
- There is no fbobjclldb.py module which is mentioned in the README.md HOT 1
- it's very slow when using visualize command
- IOS development
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chisel.