Debugging and Local Variable

Hi All
In MS visual studio i can select a local variable (Promise I will go and wash my mouth out now) and add it to a watch therefore i can see what the value of the variable as I go through the code line for line
how can I view local variable in xcode ?
Regards
Tony

To do something similar in Xcode, select the variable and either choose Run > Variables View > View Variables as Expression or choose Run > Variables View > View Variable in Window. Both options place the local variable in a separate window for you to view.
There's not much difference between the two options if you're viewing one variable, but there is a difference if you're viewing multiple variables. If you view the variable as an expression, Xcode places all the variables you want to view in one Expressions window. If you view the variable in a window, Xcode creates a new window when you choose Run > Variables View > View Variable in Window.

Similar Messages

  • How to change value of instance variable and local variable at run time?

    As we can change value at run time using debug mode of Eclipse. I want to do this by using a standalone prgram from where I can change the value of a variable at runtime.
    Suppose I have a class, say employee like -
    class employee {
    public String name;
    employee(String name){
    this.name = name;
    public int showSalary(){
    int salary = 10000;
    return salary;
    public String showName()
    return name;
    i want to change the value of instance variable "name" and local variable "salary" from a stand alone program?
    My standalone program will not use employee class; i mean not creating any instance or extending it. This is being used by any other calss in project.
    Can someone tell me how to change these value?
    Please help
    Regards,
    Sujeet Sharma

    This is the tutorial You should interest in. According to 'name' field of the class, it's value can be change with reflection. I'm not sure if local variable ('salary') can be changed - rather not.

  • Global and Local Variable

    Hi Gurus, I was unable to see where I can define local and global variables? I see that help.sap.com documentation but where do I create. All variables that I create, are global because, they are visible to all and they all can use it? Any help would be greatly appreciated.

    As far as I know, Variables are re-usable objects that are not dependent upon InfoProvider. When I look at this link
    http://help.sap.com/saphelp_nw04/helpdata/en/5c/8db07d555411d189660000e829fbbd/frameset.htm
    it talks about Global and Local variable? Is this different than what we use in Query Designer?

  • When debugging package, local variables always listed as 'null'

    When I'm debugging a package procedure, if I try to inspect any local variables by hovering the mouse cursor over them, the floating text that appears always says they're set to null - even though I know (because the procedure works as expected) that there must be a value there. Also, local variables don't appear in the 'Data' debug tab; and if I drag the local variables into the 'Watch' tab, their value is listed as null.
    Using v1.1.2.25 against a 9.2.0.6 db - anyone have any ideas..?
    Cheers,
    James

    Local variables should be used whenever you need a value only in a single method and don't need to remember it's value between two invocations of that method.
    A perfect example would be the counter in a for-loop.

  • Default initialisation of member variables and local variables

    I don't understand why member variables are initialized with default values by Java.
    Objects are initialized with "null" and primitives with "0", except boolean, which is initialized with "false".
    If these variables are used locally they are not initialized. The compiler requires them to be initialized by the programer, for example "String s = null".
    Why? What is the use of that difference?
    And why are arrays always initialized with default values, no matter if they are member variables or local variables? For example String[] s = new String[10]; s[0] to s[9] are initialized with "null", no matter if "s" is a local or member variable.
    Can someone please explain that strange difference, why it is used? To me it has no sense.

    Most of the time I have to initialize a local variable
    with "String s = null" in order to use it because
    otherwise the compile would complain. This is a cheap
    little trick, but I think everyone uses it.
    I wouldn't agree with "most of the time". The only cases where it is almost necessary to do that is when the variable should be initialized in a loop or a try-catch statement, and that doesn't happen too often.
    If local variables were initiliazed automatically without a warning it would be a Bad Thing: the compiler could tell when there is a possibility that a variable hasn't been assigned to and prevent manymanymany NullPointerExceptions on run time.
    And you didn't answer me why this principle is not
    used with arrays if it is so useful as you think.
    Possibly it is much more difficult to analyse the situation in the case of arrays; what if values are assigned to the elements in an order that depends on run time properties such as values returned from a random number generator.
    The more special rules one has to remember, the more
    likely one makes errors.I agree, but what is the rule to remember in this case?

  • Final attributes and local variables - performance ??

    Hi all,
    I and a colleague have done some performance testing regarding the use of final attributes and final local variables, e.g.
    with final:
    public class MyClass {
      private final int i;
      public final void myMethod() {
        final int j = 5;
        // do something with i and j
    }vs. non-final:
    public class MyClass {
      private int i;
      public final void myMethod() {
        int j = 5;
        // do something with i and j
    }I couldn't find any speed differences in a small test program, but my colleague did so in his application. Who is right ??
    Still, I will have do some formal testing next week and I will post the results.
    I'd prefer the version using final anyway because I find it better readable, but the issue I am having is whether I'll spend 2-3 days going through the program making everything final or not.

    I made some tests with final arguments to a method: I could not find any difference between final and non-final arguments. code is posted below
    import java.io.*;
    import java.net.*;
    import java.rmi.*;
    import java.util.*;
    import javax.ejb.*;
    import javax.naming.*;
    import javax.rmi.PortableRemoteObject;
    import junit.framework.*;
    import junit.extensions.*;
    public final class FinalVariablesTest extends TestCase /* from junit */ {
         * Constructors
        public FinalVariablesTest(String name) {
            super(name);
         * helper methods/classes
        protected void setUp() throws Exception {
            super.setUp();
        protected void tearDown() throws Exception {
            super.tearDown();
         * Test Suite
        public static void main(String[] args) {
         junit.textui.TestRunner.run(suite());
        public static Test suite() {
            return new TestSuite(FinalVariablesTest.class);
         * Test Cases
        /** tests the effect of passing an (final or non-final) int parameter
         to a method which uses the variable in a for loop.
         <p>
         Linux System:
         cat /proc/cpuinfo
         processor       : 0
         vendor_id       : GenuineIntel
         cpu family      : 6
         model           : 8
         model name      : Pentium III (Coppermine)
         stepping        : 1
         cpu MHz         : 501.146
         cache size      : 256 KB
         fdiv_bug        : no
         hlt_bug         : no
         sep_bug         : no
         f00f_bug        : no
         coma_bug        : no
         fpu             : yes
         fpu_exception   : yes
         cpuid level     : 2
         wp              : yes
         flags           : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr xmm
         bogomips        : 999.42
         </pre>
         <p>
         Results:
         <pre>
         java version "1.4.0"
         Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
         Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
         final     non-final
         498     500
         491     494
         491     493
         491     494
         534     494
         492     494
         491     494
         492     493
         491     494
         495     494
         4966     4944 (Totals)
         </pre>
        public final void testIntParametersToForLoop() {
         final int RUNS = 10;
         final int INNER = 1000000;
         final int OUTER = 10;
         System.out.println("-----------------------");
         System.out.println("testIntParametersToForLoop");
         for(int i=0; i<RUNS; i++) {
             outerFinalIntParametersToForLoop(INNER, OUTER);
             outerNonFinalIntParametersToForLoop(INNER, OUTER);
        private final void outerFinalIntParametersToForLoop(final int INNER,
                                       final int OUTER) {
         // with final var in for loop
         long start0 = System.currentTimeMillis();
         for(int i=0; i<OUTER; i++) {
             innerFinalIntParametersToForLoop(INNER * i);
         long end0 = System.currentTimeMillis();
         System.out.println("      final:       " +
                      ( end0 - start0 ) + " milliseconds");
        private final void outerNonFinalIntParametersToForLoop(final int INNER,
                                          final int OUTER) {
         // with non-final var in for loop
         long start1 = System.currentTimeMillis();
         for(int i=0; i<OUTER; i++) {
             innerNonFinalIntParametersToForLoop(INNER * i);
         long end1 = System.currentTimeMillis();
         System.out.println("  non final: " +
                      ( end1 - start1 ) + "       milliseconds");
        private final void innerFinalIntParametersToForLoop(final int INNER) {
         for(int i=0; i<INNER; i++) {
             int testVar = i * INNER;
        private final void innerNonFinalIntParametersToForLoop(int loops) {
         for(int i=0; i<loops; i++) {
             int testVar = i * loops;

  • Debug - tracking local variables

    Hi,
    I don't find the possibiliy to see the values of local variables of my procedures.
    Can you tell me how?
    Thanks
    Silke

    If you have error in your code and didn't compile, it will add breakpoint in that line of your last compiled version.
    If it is not that, try cleaning your project in Project -> Clean

  • Reading digital line and local variable

    I am using digital lines in my program to start and stop "Flat Sequence Structures"
    like time measurement ( 4 sequence, start and stop time with "Tick Count" )
    Is it good behaviour if i use once "Read from Digital Line.vi" and other starts and stops etc. with Local variables?
    Or can i just use "Read from Digital Line.vi" many times in my VI? (same line)

    Most experienced LV programmers try to avoid both sequence structures and local (and global) variables. The state machine architecture is often preferred. Look at the examples with LV and search for "State machine" on this site.
    I would probably use one read line or read port VI in a loop and pass the data to other, independent loops for processing (the timing) via queues.
    Lynn

  • Scope of globle and locale variable of a Package

    I have query about scope of variable declared in spec and body of a package. like
    create or replace package pk_test as
    v_var varchar2(50);
    procedure pk_p_test;
    end ;
    create or replace package body pk_test as
    v_var varchar2(50) := 'aaa';
    procedure pk_p_test
    is
    --v_var varchar2(50) := 'bbbb' ;
    begin
    null;
    --dbms_output.put_line(pk_p_test.v_var);
    dbms_output.put_line(pk_test.v_var);
    dbms_output.put_line(*v_var*);
    end;
    end;
    declare
    begin
    pk_test.v_var := 'qqqqq';
    --dbms_output.put_line(pk_test.v_var);
    pk_test.pk_p_test() ;
    end ;
    package is allowing to declare variable having same name in spec and body.
    But its not allowing to access. is it bug or .. can we access that variable using some methods

    Ah, I think I can see what you are saying.
    Yes, it can be declared in either place, or even declared in both places, but it shouldn't be declared in both.
    One is a "public" state variable and the other is a "private" state variable, so when it creates the package state, they are both marked differently within the state and therefore unique, hence it compiles.
    The public one can be accessed from outside the package, because it's clear to Oracle which is being referred to...
    SQL> create or replace package pk_test as
      2  v_var varchar2(50);
      3  procedure pk_p_test;
      4  end ;
      5  /
    Package created.
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace package body pk_test as
      2    v_var varchar2(50) := 'aaa';
      3    procedure pk_p_test is
      4    begin
      5      null;
      6    end;
      7* end;
    SQL> /
    Package body created.
    SQL> exec pk_test.v_var := 'aaa';
    PL/SQL procedure successfully completed.
    SQL> set serverout on
    SQL> exec dbms_output.put_line(pk_test.v_var);
    aaa
    PL/SQL procedure successfully completed.However if you try and access the variable from inside the package, the body is able to reference both the public and private variables, so it doesn't know which one to use. Hence the compilation error previously seen.
    It's not a bug, because the packages are being flexible to allow for public and private variables, but what you are experiencing just indicates poor package design and lack of understanding of package state variables.

  • Debug and Inspect variables

    Hi there;
    I really do not know what is happening , searching this group i only see my posts about it;
    When I'm in debug mode, debugger show my variables , as they where another type / value as they are really are;
           public class controlerBean extends ambiente implements Serializable {
           public void onChangeCenario(ValueChangeEvent valueChangeEvent) {
                 Row rLinhaCen = null;
                 Row rLinhaOrc = null;Debugger shows rLinhaCen as it was controlerBean, and inspect it as it is a controller bean ;
    I'm on a windows vista (64) box
    jDev
    ADF Business Components     11.1.1.55.36
    Java(TM) Platform     1.6.0_14
    Oracle IDE     11.1.1.2.36.55.36
    Versioning Support     11.1.1.2.36.55.36
    Will appreciate some help !!
    Thanks
    Edited by: MarcosOrtega on 08/04/2010 07:57

    Thanks Albertpi;
    But I'm afraid that should be some other problem, because this is not the only java source that this estrange behavior appears;
    Any other tips ?

  • Local variable's VariableElement not accessible through treepath

    Hi,
    I'm extending TreePathScanner visitor to localize and handle certain annotations associated with variables of any kind (field, parameters and local variables).
    To do so I overrode the visitVariable method that, as far I understand, should be able to obtain the corresponding javax.lang.model's VariableElement for any variable (whatever its kind) based on the current three path, see code bellow.
    It does work well with fields and parameter, however with local variables Trees.getElement simply returns a null. All the information is in fact in the code tree VariableTree node and I could retrieve what I needed from it but rather refrain from using com.sun. ... API if not really necessary and of course implement the processing twice.
    Perhaps the javax.lang.model.... object tree is not built for elements within a method body? or is this a bug? com.sun.source.util.Trees#getElement javadoc only says that a null is returned if the element is not "available".
    Thanks in advance.
    import javax.lang.model.element.VariableElement;
    import com.sun.source.util.TreePathScanner;
    import com.sun.source.util.Trees;
    import com.sun.source.tree.VariableTree;
    import com.sun.source.util.TreePath;
    public class MyVisitor extends TreePathScanner<Object,Trees> {
         @Override
         public Object visitVariable(VariableTree node, Trees trees) {
              TreePath path = getCurrentPath();
              VariableElement ve = (VariableElement) trees.getElement(path);
              if (ve != null) {
                            // The case for parameters and fields.
                            process(ve);
              else {  // Funnily getElement return null for local variables
                            process(node);
              return super.visitVariable(node, trees);
    }

    I had a similar problem where trees.getElement(TreePath) was returning null. In my case it had to do with the fact that symbol resolution wasn't done yet. I was trying to invoke my TreePathScanner after calling javacTask.parse() but I had to switch to after calling javacTask.analyze() otherwise trees.getElement(TreePath) always returned null. My issues was with a TreePath for a method though.

  • What's the difference between global variables and instance variables?

    hi im just a biginner,
    but what is the difference between these two?
    both i declare them above the constructor right.
    and both can access by any method in the class but my teacher said
    global variables are not permitted in java....
    but i don't know what that means....and i got started to confuse these two types,,
    im confusing.......
    and why my teacher said declaring global variables is not permitted,,,,,,
    why.....

    instance variables are kindof like Global variables. I'm not surprised you are confused.
    The difference is not in how they are declared, but rather in how they are used.
    There are two different "styles" of programming
    - procedural programming.
    - object oriented programming.
    Global variables are a term from Procedural programming.
    In this style of programming, you have only one class, and one "main" procedure. You only create one instance of the class, and then "run" it.
    There is one thread of control, which goes through various methods/procedures to accomplish your task.
    In this style of programming instance variables ARE "global" variables. They are accessible to all methods. There is only one instance of the class, and thus only one instance of the variables.
    Global variables are "bad" BECAUSE you can change them in any method you like. Even from places that shouldn't have to. Also if you use the same name as a global variable and a local variable, you can cause great trouble. This can lead to very subtle bugs, as the procedures interact in ways you don't expect.
    The preferred method in procedural programming is to pass the values as parameters to the methods, and only refer to the parameters, and local variables. This means that you can track exactly what your method is doing, and what it affects. It makes it simpler to understand. If you use global variables in your methods, it becomes harder to understand.
    So when are instance variables not global variables?
    When you are actually using the class as an Object, rather than just a program to run. If you are creating multiple instances of an object, all with different values for their instance variables, then they are not global variables. For instance you declare a Person object with an attribute "firstname". Your "main" program then creates many instances of the Person object, each with their own "firstname"
    I guess at the end of all this, it comes down to definitions.
    Certainly you can write procedural code in java. You can treat your instance variables, for all intents and purposes like global variables.
    I can only think to show a sort of example
    public class Test1
       User[] users;
       public void printUsers(){
         // loop through and print all the users
         // uses a global variable
          for(int i=0; i<users.length; i++){
            users.printUser();
    public void printUsers(User[] users){
    // preferred method - pass it the info it needs to do the job
    for(int i=0; i<users.length; i++){
    users[i].printUser();
    public Test1(){
    User u1 = new User("Tom", 20);
    User u2 = new User("Dick", 42);
    User u3 = new User("Harry", 69);
    users = new User[3];
    users[0] = u1;
    users[1] = u2;
    users[2] = u3;
    printUsers();
    printUsers(users);
    public static void main(String[] args)
    new Test1();
    class User{
    String firstName;
    int age;
    public User(String name, int age){
    this.firstName = name;
    this.age = age;
    public void printUser(){
    // here they are used as instance variables and not global variables
    System.out.println(firstName + " Age: " + age);
    Shit thats a lot of typing, and I'm not even sure I've explained it any good.
    Hope you can make some sense out of this drivel.
    Cheers,
    evnafets

  • Sun Sudio C++: Local Variables and Watches Values Not Initialized in Debug

    Hi All,
    I am trying to debug my program (using dbx). I have put break points in various functions. However, I have the following problems:
    - when the program runs to the break points, all arguments have in the functions shown in the callstack have values '???';
    - NOTHING is shown in the 'Local Variables' windows;
    - if I put the local variables in the 'Watches' window, the 'value' simply says <unset value>;
    what am I doing wrong?
    Thanks in advance

    Well, first things that comes to my mind is that your app was not compiled with debug info. Could you please post output of the following three commands here:
    $ dwarfdump -l <your app> | wc -l
    $ dumpstabs -s <your app> | wc -l
    $ file <your app>
    (if the first two would print small number, remove "wc -l" and post real output here, please)

  • Can't see 'Local Variables' while debugging in Sun Studio 11

    I am debugging a C/C++ application built with Sun Studio 11 running on Solaris 10. I load the application as always, set a breakpoint and run. The debugger stops at the assigned breakpoint as expected.
    The issue is that at this point there are no local variables displayed in the local variables pane.
    I have tried restarting SS11, rebuilding, etc...
    This is the first time I have seen this happen.
    Does anyone else have an idea what is wrong?

    Does adding a particular variable to Watch view help? (it can be done by typing "display <variable>" in dbx command line).
    You can also try erasing (or better moving to a temporary location) all Sun Studio settings like this:
    mv -f ~/.sunstudio /tmpand start debugging session again.

  • JDev903 debugger doesn't display local variable when debugging into JDK src

    Hi,
    I found that JDev903 debugger doesn't display local variables in the "smart data" and "data" panels when debugging into the JDK src. For most of the time, it only shows "this" object.
    Is this right? How do I setup JDev903 to display local variables in debugger?
    thanks,
    Richard

    Hi Fred,
    Did you forget to put resultFormat=&quot;e4x&quot;?

Maybe you are looking for