Happy New Year all!

As part of my PhD research I am developing an interactive SQL relational
interface to Valgrind tools so that tool end users can execute SQL queries
against tool's data structures [1]. The query library currently supports 
Memcheck,
Cachegrind, and Callgrind.
FYI, below follows a brief description of this work and then two questions.
Thanks for your time.

In brief, a provided relational specification
of data structures [2] serves as input for generating 
a relational interface for the data structures. The complete query library is 
then
compiled and linked to the Valgrind tool. At runtime, once the tool has finished
performing its instrumentation and before exiting, the query library hooks
to selected data structures of the tool, like Memcheck's MC_(malloc_list) 
for instance, and initiates an HTTP-based interface where users can enter SQL
queries. Queries are executed against the data structures through their
relational representation. For instance, below there is an example of a standard
relational view definition as an alias for a query that locates part defined 
bytes
in MC_(malloc_list)'s elements; MemProfileVT is part of MC_(malloc_list)'s 
relational
representation.

CREATE VIEW LocatePDBMemProfileQ AS
        SELECT sizeB, allocKind
        FROM MemProfileVT
        JOIN VAbitTags
        ON base=vabits_id
        WHERE VAtag_1B = 'partdefined'
        OR VAtag_2B = 'partdefined'
        OR VAtag_3B = 'partdefined'
        OR VAtag_4B = 'partdefined';

[1] https://github.com/mfragkoulis/PiCO_QL/tree/master/src/Valgrind-mod
[2] 
https://github.com/mfragkoulis/PiCO_QL/blob/master/src/Valgrind-mod/memcheck_dsl.sql

I have two questions:

1. As I am currently at the point where I am evaluating the usefulness of such 
an
interface, I was wondering whether you can think of specific use cases
from your experience with Valgrind?

2. For the query shown above, I am getting a couple of unintuitive results when
instrumenting egrep with Memcheck on Linux Debian - kernel 2.6.32.
While a specific byte's VAbits shows that it is part defined, yet the 
respective Vbits is
V_BITS8_UNDEFINED. Am I doing sth wrong? Below is the code used to retrieve
this information (please bear with me :-) ). It follows closely Memcheck's code 
so it should look
familiar.

static short getVAbits(Addr base) {
  UChar vabits = -1;
  if (inPrim(base)) {
    UWord pm_off = base >> 16;
    UWord sm_off = SM_OFF(base);
#if VG_DEBUG_MEMORY >= 1
    tl_assert(pm_off < N_PRIMARY_MAP);
#endif
    SecMap *sm = primary_map[ pm_off ];
    vabits = sm->vabits8[ sm_off ];
  } else {
    AuxMapEnt  key;
    AuxMapEnt* res;
    Word       i;
    tl_assert(base > MAX_PRIMARY_ADDRESS);
    base &= ~(Addr)0xFFFF;
    for (i = 0; i < N_AUXMAP_L1; i++) {
      if (aux_primary_L1_map[i].base == base) {
        break;
      }
    }
    if (i < N_AUXMAP_L1) {
      res = aux_primary_L1_map[i].ent;
    } else {
      key.base = base;
      key.sm   = 0;
      res = VG_(OSetGen_Lookup)(aux_primary_L2_map, &key);
    }
    if ((res) && (res->sm) && (res->sm != 
&distinguished_sec_map[SM_DIST_NOACCESS])) {
      UWord sm_off = SM_OFF(base);
      vabits = res->sm->vabits8[ sm_off ];
    }
  }
  return vabits;
};

static short extract_vabits2(Addr base, UChar vabits8) {
   UInt shift = (base & 3) << 1;          // shift by 0, 2, 4, or 6
   vabits8 >>= shift;                     // shift the two bits to the bottom
   return 0x3 & vabits8;                  // mask out the rest
};

static short getVAbits2(Addr base, int indexB) {    // indexB possible values 
[0-3]
  UChar vabits8 = getVAbits(base);
  return extract_vabits2(base + indexB, vabits8);
};

static UWord getVbits8(Addr base, int indexB) {
  UChar vabits2 = getVAbits2(base, indexB);
  if (vabits2 == VA_BITS2_PARTDEFINED) {
    Addr aAligned = VG_ROUNDDN(base, BYTES_PER_SEC_VBIT_NODE);
    Int amod     = base % BYTES_PER_SEC_VBIT_NODE;
    SecVBitNode* n = VG_(OSetGen_Lookup)(sec_vbit_table, &aAligned);
    UChar vbits8;
    tl_assert2(n, "get_sec_vbits8: no node for address %p (%p)\n", aAligned, 
base);
    /* Shouldn't be fully defined or fully undefined -- those cases shouldn't
     * make it to the secondary V bits table.
     */
    vbits8 = n->vbits8[amod];
    tl_assert(V_BITS8_DEFINED != vbits8 && V_BITS8_UNDEFINED != vbits8);
    return vbits8;
  }
  return -1;
};

Best regards,
Marios Fragkoulis
PhD researcher
Department of Management Science and Technology
Athens University of Economics and Business
http://istlab.dmst.aueb.gr/content/members/m_mfrag.html
https://github.com/mfragkoulis
------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to