How to print the JIT compilation messages for all the methods get compiled to native code of a given class - jvm

I know I could use -XX:+UnlockDiagnosticVMOptions along with -XX:CompileCommand=print,*TheGivenClass.TheGivenMethod' to output the log for TheGivenMethod of the class: TheGivenClass when it is compiled into native code by JIT.
But what if I would like JVM to output the messages for any method of TheGivenClass as long as those methods get compiled into native code? thanks for the answer.

If by "JIT compilation messages" you mean the generated assembly code for all methods of the given class, use the following syntax:
-XX:CompileCommand=print,org.pkg.TheGivenClass::*

Related

Soong build Error: this class can only be used as an annotation or as an argument to #UseExperimental

I am Using soong build system with kotlin and want to opt in for experimental APIs to be used in the code
I have added #file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class) in kotling file but upon compiling I get error stated as
error: this class can only be used as an annotation or as an argument to #UseExperim
ental
#file:OptIn(kotlinx.coroutines.ExperimentalCoroutinesApi::class)
Can anyone tell me what additional things I need to do to make it work ?

Compilation fails when importing DTCoreText in ObjC++ file

I've been trying to import DTCoreText.h in a class with both Objective-C and C++ code, but it results in the following cryptic compilation errors:
The code doesn't have syntax errors and works correctly when I use it in classes written exclusively in Objective-C, but if I change their extension to .mm the compilation fails. This indicates that is something related to the C++ compiler, but I'm not sure exactly what.
Does anyone have a clue? Thanks.
This was happening due to the fact that some method signatures had parameters with the name class which is a reserved keyword in C++ and eventually led to the compilation errors I've listed above.
Changing the parameters name fixed it.

How to exclude class from build after developpement in VS 2012 vb.net

I have a Helper class in my project that I use to help me develop the application. How do I NOT include this class in the final build when I take the application in production?
I still want the people who are going to do the maintenance to have access to it though.
So the behavior I'm looking for would be for the program to function normally while I'm developing it in Visual studio with the debug configurations. But if I build it with the release configurations, I would get an error for calls to an unknown member (supposing I didn't remove the calls to the Helper).
Sort of the same kind of behavior we have with tests.
An even better solution would not have me remove the calls to the Helper in the code.
Any way to do that?
Please comment if the question is unclear.
Use the ConditionalAttribute on the methods in the class.
Passing in DEBUG will mean that only when the DEBUG symbol is defined will the class compile.
Applying ConditionalAttribute to a method indicates to compilers that a call to the method should not be compiled into Microsoft intermediate language (MSIL) unless the conditional compilation symbol that is associated with ConditionalAttribute is defined.
<ConditionalAttribute("DEBUG")> _
Sub Method1(x As Integer)
Console.WriteLine("DEBUG is defined")
End Sub

Can I create an Objective-C class at run time from a text file?

I want to create an Objective C class at runtime from a file. So for example I have an objective c application, I want to then point it at a text file (or an .h .m pair, whatever works) and then have the application parse the text file and create the class at runtime (Class no object). Of course I would write the parser and all of that stuff I just want to know if its possible. I read these two articles:
http://www.mikeash.com/pyblog/friday-qa-2010-11-6-creating-classes-at-runtime-in-objective-c.html
http://www.mikeash.com/pyblog/friday-qa-2010-11-19-creating-classes-at-runtime-for-fun-and-profit.html
Which shows how to make an objective C class at runtime, but its being done using C functions which were defined at compile time. If I can find a way to do the same thing using strings to define the functions that would be perfect, because then I don't have to define them at compile time.
That's what called reflective programming. I guess there's no code evaluation support for Obj-C since it's not a scripting language, so the reflection concept for Obj-C is quietly limited. Plus, at run-time the compiler already translate the code into Obj-C clang code and it's a very time-consuming job just to reverse-translate the bytecode and recompile it again
For Obj-C reflection you can refer to these answers
Build a class :
Create objective-c class instance by name?
Implement a method :
Objective-C, how can i hook up a method in another class
Change class for an object :
Objective-C: How to change the class of an object at runtime?
Sure. Totally possible.
I would suggest starting with the Objective-C support in this as it includes a full-on Objective-C parser and code generator.
see my github project cocoa-interprreter it does part of what you want.
it takes a text file and compiles it at runtime .. and then runs the resulting executable using NSTask. It would be quite easy to change it so the binary is loaded into the own process using NSBundle
https://github.com/Daij-Djan/cocoa-interpreter

Is there a way to Track/trace and log all the methods, by Class and Method name, during a debug session?

I am not interested in logging into frameworks or under the covers but only at my source level code upon entry and exit of each method. I would like it to provide Class Name and Method Name and log it to file or at least have it fly by on the screen.
My query is if it is possible with existing Xcode/Debugger/Instruments facilities, can I implement it in an easy way other than an NSLog statement at every method entry and exit, or is there a commercial tool that provides this capability ?
I'm talking source methods here... not execution processes or threads. Thanks.
Dave Dribin covers precisely this in his article Tracing Objective-C messages.
The part you are after is probably this:
If you set the NSObjCMessageLoggingEnabled environment variable to YES, the Objective-C runtime will log all dispatched Objective-C messages to a file named /tmp/msgSends-<pid>.
Xtrace (https://github.com/johnno1962/Xtrace) has many features and works well for tracing Objective-C. One needs source access to their project, like you appear to have, and can emit messages on entry/exit, like you appear to want.
Debug-time configuration - can hard-code or configure tracing while debugging
Uncomplicated integration - one .mm and one .h
NSRegularExpression matching - classes, methods, types
An alternative which you can use with iOS simulator on the Mac (arm/x86_64)
Create a Symbolic Breakpoint
Symbol: objc_msgSend
Action: Debugger Command
Command:
p (void)printf("[%s, %s]\n", (char*)object_getClassName($arg1), $arg2)
*p is an alias for expr --
Check: Automatically continue after evaluating actions