Hi Andrew,

Andrew Paprocki wrote:
>> Why not use watchpoints (::wp)?
>> max
>>     
>
> Watchpoints assume you know the address you want to watch. I want to 
> dynamically print out any 'common' variable that any of the executing code 
> reads/writes. This requires looking at the current instruction, decoding any 
> memory address it is reading/writing, and looking up the symbol at that 
> address to determine if it is a 'common' linkage symbol.
>
> I guess I'm wondering if mdb_readsym() or mdb_readvar() can be used to read 
> registers, or if mdb is lacking this functionality and needs a mdb_readreg() 
> function added to its API to programmatically get the ::regs values.
>   
I see.  You want to trace data (analogous to the way dtrace can trace 
code), with mdb?
The registers exist as variables in mdb.  You could use:

    mdb_snprintf(buffer, sizeof(buffer), "<%s=K", register_name);
    mdb_eval(buffer);

Where register_name is a string representing the name of the register.  
So, in mdb
you can say, for instance,

   <eax=K

and it will print the current value of the eax register.  If you want 
symbol names,
use "/" instead of "=" in the "<%s=K" format string.
Other than that, I think you would have to abandon the API.  Mdb stores
variables in an nvlist at mdb.m_nv (see mdb_tgt_register_regvars() in 
the mdb
source).  I would give you a link, but opensolaris.org is not currently 
responding.

max


Reply via email to