Memstat helper

From OC Systems Wiki!
Revision as of 01:28, 9 March 2017 by GVincentCastellano (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
#define FILENAME "memstat_helper.ual"

// When using memstat it can be very helpful to specify in the *.cfg file:
//    RuntimeStartTime <seconds>
// to cause memstat to ignore allocations for some time at startup.
// Unfortuanately, when that time comes the first malloc() calls will cause tracebacks to be obtained
// and will cause debug info for modules to be read-in for the first time (e.g. reading of *.adi files).
// This risks slowdowns of the applications at inconvenient moments (maybe getting missed task heartbeats).
//
// This probe is intended to be used to deal with that.  It causes a handful of callchains to be logged
// at startup, hopefully causing the significant debug info to be read-in at that time.
//
// (It isn't really memstat-specific, but I chose the name as a reminder of when it can be handy.)
//
probe program { 
  on_entry {
    log (ap_GetCurrentTime(), " " FILENAME ": Will log some callchains to force reading some debug/adi-data at startup.");
  }
}
probe thread {
  ap_BooleanT did1 = FALSE;
  ap_BooleanT did2 = FALSE;
  ap_BooleanT did3 = FALSE;
  ap_BooleanT did4 = FALSE;
  ap_BooleanT did5 = FALSE;
  probe "system.tasking_support.ar_termination.body_elab" in "libada_r.a(shr.o)" {
    on_entry if (!did1) {did1=TRUE; log (ap_GetCurrentTime(), " " FILENAME); ap_LogTraceback(99);}
  }
  probe extern:"xmlInitMemory()" in "libxml2.a(libxml2.so.2)"{
    on_entry if (!did2) {did2=TRUE; log (ap_GetCurrentTime(), " " FILENAME); ap_LogTraceback(99);}
  }
  probe extern:"utl.pvn.preset.body_elab" in "libutil_ada.so" {
    on_entry if (!did3) {did3=TRUE; log (ap_GetCurrentTime(), " " FILENAME); ap_LogTraceback(99);}
  }
  probe extern:"fdk_fpe_initialize()" in "libfdk_cpp.so" {
    on_entry if (!did4) {did4=TRUE; log (ap_GetCurrentTime(), " " FILENAME); ap_LogTraceback(99);}
  }

} // thread

#if 0
     ==> extern:"xmlInitMemory()" at line 939 (xmlmemory.c) in "libxml2.a(libxml2.so.2)"
     ==> extern:"xmlInitParser()" at line 14012 (parser.c) in "libxml2.a(libxml2.so.2)"
     ==> extern:"pthread_once()" + 0x0390 in "libpthread.a(shr_xpg5.o)"
     ==> extern:"utl_xml_parsers_create_parser_c()" at line 668 (xml-parsers.c) in "libutil_cpp.so"
     ==> extern:"utl.xml.parsers.initialize[1]" at line 609 (sec.utl.xml.parsers) in "libutil_ada.so"
     ==> extern:"utl.xml.parsers.mp_l0240_parser_t.record_init_subp[1]" + 0x0048 in "libutil_ada.so"
     ==> extern:"utl.pvn.preset.read_preset_data[1b]" at line 271 (sec.utl.pvn.preset) in "libutil_ada.so"
     ==> extern:"utl.pvn.preset.body_elab" at line 383 (sec.utl.pvn.preset) in "libutil_ada.so"
     ==> extern:"adainit()" + 0x0184 in "libutil_ada.so"


   extern:"fdk_fpe_initialize()" in "libfdk_cpp.so"
     ==> extern:"fdk.com.fpe.initialize[1b]" at line 72 (sec.fdk.com.fpe) in "libfdk_ada.so"
     ==> extern:"fdk.com.fpe.body_elab" at line 82 (sec.fdk.com.fpe) in "libfdk_ada.so"
     ==> extern:"adainit()" + 0x0184 in "libfdk_ada.so"
     ==> extern:"libfdk_ada__INIT()" + 0x0008 in "libfdk_ada.so"
     ==> "__modinit.c":"mod_init1()" + 0x0050 in "libc_r.a(shr.o)"

#endif