Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* Setting a variable is very slow.
@ 2007-04-21 12:43 jagorak
  2007-04-21 12:50 ` Robert Dewar
  2007-04-21 13:41 ` Daniel Jacobowitz
  0 siblings, 2 replies; 4+ messages in thread
From: jagorak @ 2007-04-21 12:43 UTC (permalink / raw)
  To: gdb

Hi,

I  need to set a number of variables to certain values and then make a
call to a procedure which takes those variables as inputs. Then I have
to  set the same set of variables to different values and make another
call the procedure. And so on, and so on... .

For example:

   Run1:
   (gdb) set ({Rec} 0xABCDEF00).a := false
   (gdb) set ({Rec} 0xABCDEF00).b := 55
   (gdb) set x := 7.52
   (gdb) set y := 725
   (gdb) call  myProcedure()    //  The body of this procedure uses the
                                //  vars which have been set above. (e.g.
                                //  those  vars are member variables of a
                                //  class  which  this procedure belongs
                                //  to).

   Run2:
   (gdb) set ({Rec} 0xABCDEF00).a := true
   (gdb) set ({Rec} 0xABCDEF00).b := 56
   (gdb) set x := -7.52
   (gdb) set y := 125
   (gdb) call myProcedure()

...
   Run1252:
   (gdb) set....
etc.

I  need to make hundreds of such assignments & calls. The problem is -
setting  a  single  variable is very slow (in most cases it takes much
more  time  to set a single variable than to call a procedure, even if
the procedure is not very simple).

Any ideas why this is the case?

*More  importantly*:
===> Is there any way to make the assignments work faster? <===

E.g.  by  telling  gdb  to cache the address of a symbol (variable) so
that everytime the symbol is being set gdb does not have to go through
the  symbol  table  to  obtain  the address (in case that would be the
reason why assignments are very slow).


Anyone has any ideas please?

See also my notes below.

Note1:  I'm working with quite big executable (which contains thousands of
other symbols / procedures).

Note2: I  already  tried  running  the  gdb session in the GDB/MI
interface  mode  and setting the variables with appropriate MI command
e.g.
   (gdb)
   -gdb-set x := -7.52
but  it  doesn't seem to make any effect on the speed of the execution
of the assignment command.

Many thanks,
Jan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Setting a variable is very slow.
  2007-04-21 12:43 Setting a variable is very slow jagorak
@ 2007-04-21 12:50 ` Robert Dewar
  2007-04-21 13:41 ` Daniel Jacobowitz
  1 sibling, 0 replies; 4+ messages in thread
From: Robert Dewar @ 2007-04-21 12:50 UTC (permalink / raw)
  To: jagorak; +Cc: gdb

jagorak wrote:

> *More  importantly*:
> ===> Is there any way to make the assignments work faster? <===

First step is you should do some profiling work to see if you can
find out what is taking the time in gdb
> 
> E.g.  by  telling  gdb  to cache the address of a symbol (variable) so
> that everytime the symbol is being set gdb does not have to go through
> the  symbol  table  to  obtain  the address (in case that would be the
> reason why assignments are very slow).

That's a good idea, would be good to work on this improvement
to gdb. By all means investigate!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Setting a variable is very slow.
  2007-04-21 12:43 Setting a variable is very slow jagorak
  2007-04-21 12:50 ` Robert Dewar
@ 2007-04-21 13:41 ` Daniel Jacobowitz
  2007-04-30 20:05   ` Re[2]: " jagorak
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-04-21 13:41 UTC (permalink / raw)
  To: jagorak; +Cc: gdb

On Sat, Apr 21, 2007 at 01:43:25PM +0100, jagorak wrote:
> I  need to make hundreds of such assignments & calls. The problem is -
> setting  a  single  variable is very slow (in most cases it takes much
> more  time  to set a single variable than to call a procedure, even if
> the procedure is not very simple).
> 
> Any ideas why this is the case?

I know of some problems in this area, but it's not clear which one is
your problem here.  Could you try building gdb with
--enable-profiling?  It should generate a gmon.out.  That might not
show the real problem; if you want to just build a debuggable version
and use oprofile, that might work better.  It depends whether GDB is
eating CPU or being wasteful with ptrace operations.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re[2]: Setting a variable is very slow.
  2007-04-21 13:41 ` Daniel Jacobowitz
@ 2007-04-30 20:05   ` jagorak
  0 siblings, 0 replies; 4+ messages in thread
From: jagorak @ 2007-04-30 20:05 UTC (permalink / raw)
  To: Daniel Jacobowitz, Robert Dewar; +Cc: gdb


Thanks for the suggestions.
A  colleague of mine did some testing using the -statistics option and
learned  that  setting variables are slow because of the ada mode (set
lang ada).

Switching  to  the  "c" mode (set lang c) solves the problem.

More info below for those who are interested:
I  had to resort to using mangled names (since in 'c' mode) , but they
did   not   occur  to  be  problematic.

For a sample Ada type, say:

   Package.Data.DataMember

the 'mangled' C names would be:

   package__data.datamember

(all lower-case).

(it will be more dificult if "Data" were to be type name).




Note:  I'm  using  customized  version  of  GDB  (custom target) and I
realized  that  it  may  be  that  the 'plain' GDB works actually fine
(=fast) in that aspect. (Although I don't really know.)

I   was   trying  to  reproduce  the problem on the 'plain' GDB (since
oviously  customized  version  is not of your concern!) to see whether
the  problem  reoccurs.  I  created a very simple program with lots of
symbols in it.  The  target  was  'exec'  -  everything  worked  fine.  (no
significant  delays).  This  is  obviously not entirely representative
'test' since  I  feel  the  target  may  have  impact here (regardless of any
customizations to GDB).

Regards,
Jan
   




DJ> On Sat, Apr 21, 2007 at 01:43:25PM +0100, jagorak wrote:
>> I  need to make hundreds of such assignments & calls. The problem is -
>> setting  a  single  variable is very slow (in most cases it takes much
>> more  time  to set a single variable than to call a procedure, even if
>> the procedure is not very simple).
>> 
>> Any ideas why this is the case?

DJ> I know of some problems in this area, but it's not clear which one is
DJ> your problem here.  Could you try building gdb with
DJ> --enable-profiling?  It should generate a gmon.out.  That might not
DJ> show the real problem; if you want to just build a debuggable version
DJ> and use oprofile, that might work better.  It depends whether GDB is
DJ> eating CPU or being wasteful with ptrace operations.




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-04-30 20:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-21 12:43 Setting a variable is very slow jagorak
2007-04-21 12:50 ` Robert Dewar
2007-04-21 13:41 ` Daniel Jacobowitz
2007-04-30 20:05   ` Re[2]: " jagorak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox