~bkerensa/ubuntu/raring/valgrind/merge-from-deb

« back to all changes in this revision

Viewing changes to coregrind/m_debuginfo/priv_storage.h

  • Committer: Benjamin Kerensa
  • Date: 2012-11-21 23:57:58 UTC
  • mfrom: (1.1.16)
  • Revision ID: bkerensa@ubuntu.com-20121121235758-bd1rv5uc5vzov2p6
Merge from debian unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
   This file is part of Valgrind, a dynamic binary instrumentation
10
10
   framework.
11
11
 
12
 
   Copyright (C) 2000-2011 Julian Seward 
 
12
   Copyright (C) 2000-2012 Julian Seward 
13
13
      jseward@acm.org
14
14
 
15
15
   This program is free software; you can redistribute it and/or
257
257
      Int   fp_off;
258
258
   }
259
259
   DiCfSI;
 
260
#elif defined(VGA_mips32)
 
261
typedef
 
262
   struct {
 
263
      Addr  base;
 
264
      UInt  len;
 
265
      UChar cfa_how; /* a CFIC_ value */
 
266
      UChar ra_how;  /* a CFIR_ value */
 
267
      UChar sp_how;  /* a CFIR_ value */
 
268
      UChar fp_how;  /* a CFIR_ value */
 
269
      Int   cfa_off;
 
270
      Int   ra_off;
 
271
      Int   sp_off;
 
272
      Int   fp_off;
 
273
   }
 
274
   DiCfSI;
260
275
#else
261
276
#  error "Unknown arch"
262
277
#endif
288
303
      Creg_ARM_R12,
289
304
      Creg_ARM_R15,
290
305
      Creg_ARM_R14,
291
 
      Creg_S390_R14
 
306
      Creg_S390_R14,
 
307
      Creg_MIPS_RA
292
308
   }
293
309
   CfiReg;
294
310
 
405
421
   true.  The initial state is one in which we have no observations,
406
422
   so have_rx_map and have_rw_map are both false.
407
423
 
408
 
   This is all rather ad-hoc; for example it has no way to record more
409
 
   than one rw or rx mapping for a given object, not because such
410
 
   events have never been observed, but because we've never needed to
411
 
   note more than the first one of any such in order when to decide to
412
 
   read debug info.  It may be that in future we need to track more
413
 
   state in order to make the decision, so this struct would then get
414
 
   expanded.
 
424
   This all started as a rather ad-hoc solution, but was further
 
425
   expanded to handle weird object layouts, e.g. more than one rw
 
426
   or rx mapping for one binary.
415
427
 
416
428
   The normal sequence of events is one of
417
429
 
428
440
   where the upgrade is done by a call to vm_protect.  Hence we
429
441
   need to also track this possibility.
430
442
*/
 
443
 
 
444
struct _DebugInfoMapping
 
445
{
 
446
   Addr  avma; /* these fields record the file offset, length */
 
447
   SizeT size; /* and map address of each mapping             */
 
448
   OffT  foff;
 
449
   Bool  rx, rw, ro;  /* memory access flags for this mapping */
 
450
};
 
451
 
431
452
struct _DebugInfoFSM
432
453
{
433
 
   /* --- all targets --- */
434
 
   UChar* filename; /* in mallocville (VG_AR_DINFO) */
435
 
 
 
454
   UChar*  filename;  /* in mallocville (VG_AR_DINFO)               */
 
455
   XArray* maps;      /* XArray of _DebugInfoMapping structs        */
436
456
   Bool  have_rx_map; /* did we see a r?x mapping yet for the file? */
437
457
   Bool  have_rw_map; /* did we see a rw? mapping yet for the file? */
438
 
 
439
 
   Addr  rx_map_avma; /* these fields record the file offset, length */
440
 
   SizeT rx_map_size; /* and map address of the r?x mapping we believe */
441
 
   OffT  rx_map_foff; /* is the .text segment mapping */
442
 
 
443
 
   Addr  rw_map_avma; /* ditto, for the rw? mapping we believe is the */
444
 
   SizeT rw_map_size; /* .data segment mapping */
445
 
   OffT  rw_map_foff;
446
 
 
447
 
   /* --- OSX 10.7, 32-bit only --- */
448
458
   Bool  have_ro_map; /* did we see a r-- mapping yet for the file? */
449
 
 
450
 
   Addr  ro_map_avma; /* file offset, length, avma for said mapping */
451
 
   SizeT ro_map_size;
452
 
   OffT  ro_map_foff;
453
459
};
454
460
 
455
461
 
515
521
      we have committed to reading the symbols and debug info (that
516
522
      is, at the point where .have_dinfo is set to True). */
517
523
 
518
 
   /* The file's soname.  FIXME: ensure this is always allocated in
519
 
      VG_AR_DINFO. */
 
524
   /* The file's soname. */
520
525
   UChar* soname;
521
526
 
522
527
   /* Description of some important mapped segments.  The presence or
530
535
 
531
536
      Comment_on_IMPORTANT_CFSI_REPRESENTATIONAL_INVARIANTS: we require that
532
537
 
533
 
      either (rx_map_size == 0 && cfsi == NULL) (the degenerate case)
 
538
      either (size of all rx maps == 0 && cfsi == NULL) (the degenerate case)
534
539
 
535
540
      or the normal case, which is the AND of the following:
536
 
      (0) rx_map_size > 0
537
 
      (1) no two DebugInfos with rx_map_size > 0 
538
 
          have overlapping [rx_map_avma,+rx_map_size)
539
 
      (2) [cfsi_minavma,cfsi_maxavma] does not extend 
540
 
          beyond [rx_map_avma,+rx_map_size); that is, the former is a 
541
 
          subrange or equal to the latter.
 
541
      (0) size of at least one rx mapping > 0
 
542
      (1) no two DebugInfos with some rx mapping of size > 0 
 
543
          have overlapping rx mappings
 
544
      (2) [cfsi_minavma,cfsi_maxavma] does not extend beyond
 
545
          [avma,+size) of one rx mapping; that is, the former
 
546
          is a subrange or equal to the latter.
542
547
      (3) all DiCfSI in the cfsi array all have ranges that fall within
543
 
          [rx_map_avma,+rx_map_size).
 
548
          [avma,+size) of that rx mapping.
544
549
      (4) all DiCfSI in the cfsi array are non-overlapping
545
550
 
546
551
      The cumulative effect of these restrictions is to ensure that
749
754
   UWord     fpo_size;
750
755
   Addr      fpo_minavma;
751
756
   Addr      fpo_maxavma;
 
757
   Addr      fpo_base_avma;
752
758
 
753
759
   /* Expandable arrays of characters -- the string table.  Pointers
754
760
      into this are stable (the arrays are not reallocated). */
793
799
 
794
800
   /* An array of guarded DWARF3 expressions. */
795
801
   XArray* admin_gexprs;
 
802
 
 
803
   /* Cached last rx mapping matched and returned by ML_(find_rx_mapping).
 
804
      This helps performance a lot during ML_(addLineInfo) etc., which can
 
805
      easily be invoked hundreds of thousands of times. */
 
806
   struct _DebugInfoMapping* last_rx_map;
796
807
};
797
808
 
798
809
/* --------------------- functions --------------------- */
861
872
   if not found.  Binary search.  */
862
873
extern Word ML_(search_one_fpotab) ( struct _DebugInfo* di, Addr ptr );
863
874
 
 
875
/* Helper function for the most often needed searching for an rx
 
876
   mapping containing the specified address range.  The range must
 
877
   fall entirely within the mapping to be considered to be within it.
 
878
   Asserts if lo > hi; caller must ensure this doesn't happen. */
 
879
extern struct _DebugInfoMapping* ML_(find_rx_mapping) ( struct _DebugInfo* di,
 
880
                                                        Addr lo, Addr hi );
 
881
 
864
882
/* ------ Misc ------ */
865
883
 
866
884
/* Show a non-fatal debug info reading error.  Use vg_panic if