This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

questions about immediate_quit...


I found the following code in dcache_peek_byte():

    immediate_quit++;
    while (done < LINE_SIZE)
      {
        int try = 
        (*dcache->read_memory)
        (db->addr + done,
         db->data + done,
         LINE_SIZE - done);
        if (try == 0)
          return 0; 
        done += try;  
      }
    immediate_quit--;

Even after reading the comment describing immediate_quit in utils.c,
I'm still a bit puzzled.

* In the above code fragment, immediate quit is incremented before the
  read.  But it is only decremented if the read succeeds.  This would 
  appear to be an obvious bug.

* From the aforementioned comment, it seems that the dcache is at too
  high of a level to bother with immediate_quit.  If setting/reset it
  is necessary, it should be done in the target i/o functions.

* Examination of various target bits, reveals that in most cases
  immediate_quit is set and reset there.  However:

  - in some cases, instead of incrementing and decrementing immediate_quit,
    they are set to 1 and 0.

  - in other cases, the value of immediate_quit is saved in old_immediate_quit
    then set to 1, and finally set back to the saved value.

  The first case potentially loses when such calls are nested, as they
  are with the dcache enabled.  The second works fine, but I see a
  value in using only one idiom throughout the gdb sources.

In conclusion, I think the code touching immediate_quit in dcache.c is
unnecessary, and I'll remove it in my next set of commits.

I also think we should remove all assignments of 0/1 to immediate_quit
and replace them with increments/decrements so that it nests properly.
I think this is important even in code paths that will never nest, as
any occurance in the code may be used as a template by a future
contributor.  I prefer good examples without gotchas...

Thoughts?

        --jtc

-- 
J.T. Conklin
RedBack Networks

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]