Articles Tagged 'Debug'


Bachi beginning of the year: WordPress and WPML get_page_by_path update ()

The year 2012 began with a few hours of deep-debugging because of two (known) bugs quite annoying. , con la globale (e famosa) omonima istanza $wpdb . The first, among other things, rather dated, present in the core of WordPress regarding the method update() class wpdb , with the global (and famous) instance of the same name $wpdb . The defect appears when you try to update a field to NULL . Despite numerous complaints, the WordPress development team does not seem to find a solution to the annoying problem. In fact, to date, the only solution is to write the SQL for your account.

Continued ...

Very short snippet: set the log files on WordPress

si attivano i log a video prodotti da PHP, riempiendo lo schermo di Notice, Warning e quant'altro. By setting the file wp-config.php define the define('WP_DEBUG', true); logs are activated by PHP-screen products, filling the screen, Notice, Warning, and more. If controls for "flying" this can be useful in situations of exercise is highly recommended, for obvious reasons. Luckily, WordPress allows her to "convey" these logs to a file, which by default is placed in /wp-content/debug.log .

Continued ...

Very short trick: log JavaScript objects

If you are to develop in an environment where it is impossible to use the debugging tools like FireBug , such as the Apple iPhone simulator in Xcode, it can become frustrating to find problems, including an incorrect access to all properties of an object. Here is that the use of works alert() is fundamental!

Continued ...

Coding Guidelines

When no longer working alone for all developers comes time to find guidance in the writing of code. Protocols and standards that make it possible to "read" easily and intervene (more easily) in the code of others.
When we are working on a project more programmers, often of different languages, you must find a common form of writing, internal and external documentation standards in the code. In my work I am usually to interact with:

  • Objet-C, C / C + +
  • PHP
  • HTML
  • JavaScript
  • Actionscript
  • CSS

Continued ...

How to set XCode to use the iPhone instead of the simulator

Screencast

Continued ...

Xcode: Debugging tips on Preferences

Using the Xcode Preferences you can set the behavior of the atmosphere during the debugging phase of an iPhone application. The default settings, in fact, are very uncomfortable when you try and try again an application, for example, after launching our application, you must manually open the Console window to see the output of various NSLog() . Xcode also lets the previous sessions in order to force us to clean the window by hand. Fortunately, you can solve the problem by acting on the Preferences:

xcode-preferences

As shown above, simply select an item from the menu on start to decide which debug window to open automatically at startup of our valid if (I & Debugger Console set but you can choose those that best suits you). On the right, then we find Auto Clear Debug Console, so you always start with a clean console.

Continued ...

How to delete NSLog () from source XCode

<a target="_blank" href="http://developer.apple.com/iphone/library/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSLog">NSLog()</a> a useful function during the early stages of a project for testing and debugging an application for Apple iPhone or, more generally, in the XCode environment. Being just a function, just like the other, his presence will be felt even when releasing (release) our executable. potrebbero influire sulle performance della nostra applicazione, soprattutto se abbiamo inserito NSLog() all'interno di loop. It then becomes necessary to remove, in some way, all the rows in NSLog() out of our code, because it is no longer needed, and because calls to NSLog() could affect the performance of our application, especially if we put NSLog() to 'inner loop.

Immediately rule out the solution to the "look" and "cancel" because one day there could be used again. We exclude the solution of the "look" and "comments", uncomfortable for the same reason as before. Fortunately, a clean, simple, and are using the correct compiler conditionals. What we will do in practice, and tell the compiler to exclude - if there is a specific condition - when compiling our source lines that contain NSLog() .

The compiler directives and compiler conditional statements, are a very powerful and widespread. Those coming from the development of the ANSI-C knows very well and will definitely utilizzte in many situations. The peculiarity of these "instructions" lies in the fact, mentioned above, to be seen by the compiler and not executable. This feature makes them useful in many cases and can solve problems otherwise very annoying.

Let's see an example of code that, as predicted, you can "delete" from the compilation of code share, in our case NSLog() :

1
2
3
4
5
6
# Define ACTIVE_NSLOG 1
/ / If the constant is defined ACTIVE_NSLOG fill
/ / The block of code between # ifdef and # endif
# Ifdef ACTIVE_NSLOG
" ... bla bla" ) ; NSLog (@ "... blah blah");
# Endif

). Conditional statements are part of the compiler of the same family as #define , also, in fact, are preceded by a "pound" ( # ). solo se ACTIVE_NSLOG è definito. In the example shown we have defined a constant ACTIVE_NSLOG ; subsequent lines of code tells the compiler to "include" line NSLog() only if ACTIVE_NSLOG is defined. If we took care, during the writing of our code, to place calls to NSLog() within the block #ifdef ... #endif per far sparire, alla prossima compilazione, tutti i nostri NSLog() . #ifdef ... #endif , just delete the definition of the constant ACTIVE_NSLOG to disappear, the next compilation, all our NSLog() .

A best and final

Let us now see how to set the XCode environment to improve even more what we have done here! First of all we choose a constant name that we use in our projects to exclude from the compilation NSLog() . o quello che preferite. You can choose the name that you like, from DEBUG to MIO_DEBUG or whatever you prefer. Open your project, new or old. Enter all the NSLog() within the block (or block):

1
2
3
# Ifdef MIO_DEBUG
" ... bla bla" ) ; NSLog (@ "... blah blah");
# Endif

Select the main file of your project, click the right button and choose the Get Info item.

getinfo

This opens the window with information about the project:

userdefine

Select the Build tab, verify that you are in the Debug configuration (this is the gem), go to the User-Defined section and add, via the button at the bottom left, a new field called OTHER_CFLAGS . At this value assegnamoli -DMIO_DEBUG=1 . The syntax is -D{mia define}=1 .

This procedure has two advantages:

  1. We must not put in the code #define MIO_DEBUG 1 , but we do it through the project information. So, when we go to fill out the release version (the one without the NSLog() ) do not have to remember to delete the line #define MIO_DEBUG 1
  2. The constant is defined in relation to the configuration, in our case Debug. So, switching to Release configuration (release) will be absent and the constant rows with NSLog() will not be compiled

Conclusions

The above procedure may be useful in a moltidutine other cases, with NSLog() , have nothing to do. Conditional statements can help the compiler in a wide range of contexts. They are often used by programmers to determine the type of operating system, version, the target, the presence of mathematical processors, while maintaining the same "same" source.

To understand, as an example, we can utilizzre our constant MIO_DEBUG also intervene in other areas of the code:

1
2
3
4
5
6
7
8
9
10
/ / Debug if they win the game
/ / With a score of 100 instead of 10000:)
# Ifdef MIO_DEBUG
score == 100 ) if (score == 100)
# Else
score == 10000 ) if (score == 10000)
# Endif
{
; [HaiVinto self];
}

To finish, here are some examples and variants:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/ / In general there is
# If expression
/ / If statement similar to the traditional, so with a full expression

/ / Check if a constant is defined
# Ifdef constant

/ / Check if it is NOT a constant defined
# Ifndef constant

/ / Else
# Else

/ / Close the block
# Endif
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/ / For example ...
# Define DEBUG 1
5 # define MIA_ALTRA_COSTANTE

...
# If DEBUG
/ / Fill in this
# Else
/ / Otherwise fill this other
# Endif

# If MIA_ALTRA_COSTANTE> 4
"..." ) ; NSLog (@ "...");
# Endif
1
2
3
4
# Ifndef INCLUDE_MIO_FILE
# Define INCLUDE_MIO_FILE
# Include "mio_file.h"
# Endif

Continued ...

Trace Actionscript, Objective-C NSLog ()

, usata per il debug delle applicazioni. Taking up the post from Actionscript to Objective-C (where you compare the code and syntax ActionScript and Objective-C), we have the convenient feature in ActionScript trace ( ) , used for debugging applications. This function outputs a console on the Adobe Flash development environment. It is mainly used for debugging and testing of "movie" / application. In XCode / Objective-C we have: NSLog ( ) . di Actionscript: The syntax of this function is very similar to the trace ( ) in Actionscript:

1
"Sono una linea di debug" ) ; NSLog (@ "I am debugging a line");

In Actionscript we have:

1
"Sono una linea di debug" ) ; trace ("I am debugging a line");

Apart from the use of the sign (@), as you can see, are identical. The differences (and similarities) start when you want to display values ​​of variables, for example in Actionscript we have:

1
2
3
"Coordinata x:" + x + " coordinata y:" + y ) ; trace ("x-coordinate:" + x + "y coordinate:" + y);
/ / Or
"Coordinate: " , x , y ) ; trace ("Coordinates", x, y);

In Objective-C we have:

1
"Coordinata x:%i coordinata y:%i" , x, y ) ; NSLog (@ "x-coordinate: the y coordinate%% i", x, y);

che opera sull'Apple System Log. Note: NSLog() actually calls the more generic function NSLogv ( ) that operates on the implementa System Log. The functions are in fact identical, changing only the input parameters.

o sprintf ( ) . The developers will find very familiar with the C string formatting, as with printf ( ) or sprintf ( ) . For details, see String Format Specifiers .

Continued ...

FireFox: profile management

Mozilla Firefox allows you to manage multiple profiles , which is useful to those who, like me, develops Web sites and requires a series of extensions dedicated to debugging and analysis of Web pages via the use of profiles you can configure different settings FireFox:

Firefox saves your personal information such as bookmarks, passwords and preferences in a file called profile group located in a different position compared to the Firefox program files.

On Windows Vista ( see here for other operating systems) can access the profile management from the command Esegui using:

1
firefox-ProfileManager

Profile Management

One of the advantages in the use of profiles is that you can have a FireFox to browse without the toolbar and then all the extensions for debugging and FireFox to develop, accompanied by FireBug and all other development tools.

Continued ...

Firebug 1.1 beta

Firebug

On Fireclipse release 1.1 is available beta of Firebug , JavaScript debugger amazing and not only for FireFox . Among the novelties of this beta indicates the support for Firefox 3, the function eval () interface and an external editor.

To follow with interest, then the entire project Fireclipse , an open project dedicated to JavaScript tools!

Continued ...



Stop SOPA