Is there any way to clear NSLog Output? - iphone

I have been googling from last couple of hours for finding that is there any way to clear NSLog output using code or not?
Like we have clrscr() in c. So if we are trying to print something which we want to focus most and there is lots of log printin there we can put that code there and get keep our desire log on top for easy searching. This can be done by putting breakpoint on my NSLog line and than click on clear console. but question is is there a way to achive this programatically?
I found few question on stack overflow but I din't satisfied with answer like this is saying that I can disable log for release mode etc.
Or I can use DLog, ALog or ULog as requirement but my question is different..
Any one can help me in this?
Thanks in advance :)

You can use a conditional breakpoint to simulate it. Define a function like this in your code:
int clear_console()
{
NSLog(#"\n\n\n\n\n\n\n\n");
}
Then, when you want to clear the console just add a breakpoint before the NSLog with this condition:
Condition: 1 > 0
Action: Debugger Command expr (int) clear_console()
Options: Automatically continue after evaluating Check it to skip the pause.
Tested with Xcode 4.3.2 and lldb.
Previous answer:
AFAIK, no, there isn't.
Just in case you're not doing it yet, you can create custom macros to format the output to highlight what you want.
Define macros like this:
#define CLEAR(...) NSLog(#"\n\n\n\n\n\n") /* enough \n to "clear" the console */
#define WTF(...) CLEAR();NSLog(#"!!!!!!!!!!!!!!");NSLog(__VA_ARGS__)
#define TRACE(__message__) NSLog(#">>>>>>>>>>>>>>> %# <<<<<<<<<<<<<<<<<<<", __message__)
Then:
WTF(#"This should't be here object: %#", theObject);
...
TRACE(#"Start Encoding");
...
It's not what you want but it pretty much solves the problem. You'll end up with your own set of macros with custom prefixes easily scannable in the console output.

Related

How does mock-debugger control which line the debugger steps next?

I'm unable to understand how the mock-debugger extension controls where the next step is.
For example what if I'd like to step 2 lines if I find the word "banana" in my text? Also, I'd like to do something, like "Step In", where I can walk word-by-word - is it possible?
I've seen the this._currentLine = ln; assign, which looks like it controls where the line is, but it's just a simple local variable. How could it ever control anything in the debugger? I can't find any other uses of the _currentLine varbiable where it passes to anything useful API (except for stack tracing, but I don't think it has any relation with the debugger line-control).
The stack trace is the only source for the debugger step visualization. When the debugger gets a notification to pause it requests the current stack trace. The TOS determines where the next execution point will be located. Hence the debug adapter is reponsible to determine this position precisely.

Gate vs toggle clip launch in Max4Live patch

I hope someone is able to help me with this.
Ableton Live when you set a clip's launch mode to gate, it only plays when you hold down the key. I'm using a patch that takes an OSC message to launch the clip, but it will not work as a gate - it needs to have the stop all clips message, and this won't help in my situation.
I need to "call fire" when 1 and "call stop all clips" when 0, but I'm not sure how to do this.
Can anyone help me with which object I should use? I've looked at various gates and swtiches, but I'm missing something.
Thanks.
Create a new object and type "togedge" or "select" (or its shorthand "sel"). Both of them will have 2 outputs: One for 0, one for not 0.
"togedge" will only output if the input changes.
"sel" will always output, and you can enter different numbers to match your input directly (like "sel 34 56").
Btw you can also use "call stop" on the clip_slot object directly instead of "stop_all_clips" on the track object.
After fiddling with the sel object, I discovered this: I needed to change the live.text object used to launch the clip from button to toggle.

Xcode 4, using breakpoints to log or po an object

I'm trying to figure out how to use the log or debug commands in adding actions to a breakpoint. I can't seem to figure it out. For something like this:
double currentZoom = [self getZoomScale];
How do I print out the currentZoom? I tried using log as my action, and then doing
currentZoom: #(double)currentZoom# // this didn't work
currentZoom: #(double)[self getZoomScale]# // also didn't work
Can someone help me out with this and any other info I may need to log information with breakpoints?
And also a simple example for po an object. Does po always po the description (as in you have to have overridden the description method? Thanks.
If you want to print your double with NSLog, add the following line:
NSLog(#"%f", currentZoom);
Now, if you want to use the debugger console...
If you want to print currentZoom in the console, you don't need po. Plain p would be enough.This is, type
p currentZoom
and it's going to show you currentZoom's value. po is for objects. Let's say you wrap currentZoom in an NSNumber.
NSNumber currentZoomNumber = [NSNumber numberWithDouble:currentZoom];
Then, to print the value, you would have to do
po currentZoomNumber
Like i said, po is to print objects, it means print object. So you can use it to print any type of object, from NSStrings and NSNumbers to NSDictionaries and NSManagedObjects.
You can make the breakpoint execute debugger commands.
Open the edit breakpoint pane:
.
Then type a debugger command (selecting "Automatically continue after evaluating" is advised).
To insert some context around the automated debugger commands, you can add another debugger action of type "Log Message". The "Log Message" action is not capable of inspecting variables itself.
NSLog() is probably easier to implement, but requires you to change the code you are debugging.
I do not know how to add actions to a breakpoint. (I am interested in seeing it in any other answers offered)
The gdb syntax for printing objects is
po objectName
The gdb syntax for printing C variables is
print (int) intNum
print (float) floatNum

How to ignore some subroutine calls in NYTProf reporting

I'm trying to profile a Perl script, but CORE::sleep gobble all the space (and time) of my report.
How can i tell NYTProf to ignore sleep calls ?
Assuming we have the following script :
sub BrandNewSubroutine {
sleep 10;
print "Odelay\n";
}
BrandNewSubroutine();
I want to get rid of the following line of the report :
Exclusive Time;Inclusive Time;Subroutine
10.0s;10.0s;main::::CORE:sleepmain::CORE:sleep
(opcode)
Edit: Using DB::disable_profile() and DB::enable_profile() won't do the trick, as it add sleep time to BrandNewSubroutine Inclusive time.
Thanks in advance.
I'd suggest either wrapping the calls to sleep (possibly by use of method mentioned in perlsub) with DB::disable_profile() and DB::enable_profile() calls (RUN-TIME CONTROL OF PROFILING in NYTProf documentation), or post processing the report to remove the offending calls.
CORE::accept is already ignored in the way you'd like CORE::sleep to be, so the mechanism is already in place. See this code in NYTProf.xs:
/* XXX make configurable eg for wait(), and maybe even subs like FCGI::Accept
* so perhaps use $hide_sub_calls->{$package}{$subname} to make it general.
* Then the logic would have to move out of this block.
*/
if (OP_ACCEPT == op_type)
subr_entry->hide_subr_call_time = 1;
So with a little hacking (OP_SLEEP==op_type || OP_ACCEPT == op_type) you'd be able to ignore CORE::sleep in the same way.
I'd accept a patch to enable that as an option.

Suppressing NSLog statements for release? [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Do I need to disable NSLog before release Application?
I wonder if someone could help me setup a number of NSLog statements so they print to console when executing in "Debug Mode" but don't print in "Release Mode". I understand I need to add something like DEBUG = 1 to the debug config in Xcode but I can't find where. Also how do I utilise this in my code?
NSLog(#"Print Always");
if(DEBUG) NSLog(#"Print only in debug");
Is there a simple way of doing this?
EDIT_001:
I tried following this but the keys now seem to be only listed under "All Settings", and are presenting as nice names. The one I should be using is GCC_PREPROCESSOR_DEFINITIONS, so I needed to find "Preprocessor Macros", select edit and add DEBUG=1
When you come to use this its simply a case of adding (see below) or some marco to remove the messy #ifdef / #endif tags.
NSLog(#"You always see me?");
#ifdef DEBUG
NSLog(#"Only in DEBUG");
#endif
This is a popular solution:
http://iphoneincubator.com/blog/debugging/the-evolution-of-a-replacement-for-nslog
See comments about using either -DDEBUG=1 or DEBUG=1.
The best solution is not to use NSLog in the first place but instead rely on the debugger.
You can set breakpoints that execute debugger commands to print out anything and you can set the breakpoints to execute the debugger commands but not to stop execution. In practice this works just like NSLog.
By using the debugger to do the logging, you don't have to worry about removing the log statements.
Please have a look at the answers of How to print out the method name and line number and conditionally disable NSLog?. There are some nice macros in there that can be very useful.
I use this:
-(void)debugWinLog
{
NSUserDefaults * defaultsDebug = [NSUserDefaults standardUserDefaults];
theDebugWin = [defaultsDebug boolForKey:#"logger"];
}
Which is called in the awakeFromNib.
It checks the apps plist file for a 1 or 0 for the BOOL entry "logger"
The normal state if off, but when debugging you can then turn it on or off at will in terminal. with the normal defaults write.
The NSlog statments look like:
if ( theDebugWin) {NSLog (#"%#", windowState );}