Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Classes | Functions
python.sheap Namespace Reference

Classes

class  SHeap
 

Functions

def sheap_read_word (inf, addr)
 
def sheap_looks_free (inf, addr)
 
def sheap_scan_2 (inf, addr)
 
def sheap_scan_1 (addr1, addr2, forced)
 
def sheap_scan (addr1, addr2, forced)
 
def sheap (arg, forced)
 

Function Documentation

◆ sheap()

def python.sheap.sheap (   arg,
  forced 
)

Definition at line 66 of file sheap.py.

66 def sheap (arg, forced):
67  args = arg.split()
68  if not args:
69  raise gdb.GdbError ('Missing start address')
70  start_arg = gdb.parse_and_eval (args[0])
71  end_arg = gdb.parse_and_eval (args[1]) if len(args) > 1 else start_arg + 1024
72  return sheap_scan (start_arg, end_arg, forced)
73 
74 

◆ sheap_looks_free()

def python.sheap.sheap_looks_free (   inf,
  addr 
)

Definition at line 14 of file sheap.py.

14 def sheap_looks_free (inf, addr):
15  head = sheap_read_word (inf, addr+8)
16  if head > 128*1024*1024 or head < 8: return False
17  #print (hex(addr), hex(head))
18  head = head & ~1
19  if head & 2: return False
20  foot = sheap_read_word (inf, addr+head)
21  if head != foot: return False
22  nexthead = sheap_read_word (inf, addr+head+8)
23  if nexthead & 1: return False
24  #print ('found', hex(addr), hex(head), hex(foot), hex(nexthead))
25  return True
26 

◆ sheap_read_word()

def python.sheap.sheap_read_word (   inf,
  addr 
)

Definition at line 10 of file sheap.py.

10 def sheap_read_word (inf, addr):
11  mv = inf.read_memory (addr, 8)
12  return mv.cast('L')[0]
13 

◆ sheap_scan()

def python.sheap.sheap_scan (   addr1,
  addr2,
  forced 
)

Definition at line 57 of file sheap.py.

57 def sheap_scan (addr1, addr2, forced):
58  addr1 -= 8
59  while addr1 < addr2:
60  addr1 = sheap_scan_1 (addr1, addr2, forced)
61  forced = False
62  gdb.flush()
63  return
64 
65 

◆ sheap_scan_1()

def python.sheap.sheap_scan_1 (   addr1,
  addr2,
  forced 
)

Definition at line 46 of file sheap.py.

46 def sheap_scan_1 (addr1, addr2, forced):
47  inf = gdb.selected_inferior()
48  addr1 = (addr1 + 7) & ~7 # Align
49  if not forced:
50  while addr1 < addr2 and not sheap_looks_free (inf, addr1):
51  addr1 += 8
52  while addr1 < addr2:
53  addr1, ok = sheap_scan_2 (inf, addr1)
54  if not ok: break
55  return addr1
56 

◆ sheap_scan_2()

def python.sheap.sheap_scan_2 (   inf,
  addr 
)

Definition at line 27 of file sheap.py.

27 def sheap_scan_2 (inf, addr):
28  head = sheap_read_word (inf, addr+8)
29  if head > 128*1024*1024 or head < 8:
30  return addr+8, False
31  head = head & ~1
32  if head & 2:
33  return addr+8, False
34  nexthead = sheap_read_word (inf, addr+head+8)
35  if nexthead & 1:
36  type = ' USED '
37  else:
38  if not sheap_looks_free (inf, addr):
39  return addr+8, False
40  type = ' FREE '
41  #print('sheap_scan_2' ,hex(addr), hex(head), hex(nexthead), type)
42  s = f'{int(addr):016x}:{type}{int(head):08x}\n'
43  gdb.write (s)
44  return addr+head, True
45 
python.sheap.sheap_scan
def sheap_scan(addr1, addr2, forced)
Definition: sheap.py:57
python.sheap.sheap_read_word
def sheap_read_word(inf, addr)
Definition: sheap.py:10
python.sheap.sheap
def sheap(arg, forced)
Definition: sheap.py:66
python.sheap.sheap_scan_1
def sheap_scan_1(addr1, addr2, forced)
Definition: sheap.py:46
python.sheap.sheap_looks_free
def sheap_looks_free(inf, addr)
Definition: sheap.py:14
python.sheap.sheap_scan_2
def sheap_scan_2(inf, addr)
Definition: sheap.py:27