Browse Source

Added debugging

tags/v0.9.3
Michael Brown 20 years ago
parent
commit
59a1662978
1 changed files with 11 additions and 0 deletions
  1. 11
    0
      src/core/heap.c

+ 11
- 0
src/core/heap.c View File

76
 	}
76
 	}
77
 
77
 
78
 	ASSERT ( size != 0 );
78
 	ASSERT ( size != 0 );
79
+	DBG ( "HEAP using region [%x,%x)\n", heap_start, heap_end );
79
 	heap_ptr = heap_end;
80
 	heap_ptr = heap_end;
80
 }
81
 }
81
 
82
 
92
 	addr = ( ( ( heap_ptr - size ) & ~( align - 1 ) )
93
 	addr = ( ( ( heap_ptr - size ) & ~( align - 1 ) )
93
 		 - sizeof ( struct heap_block ) );
94
 		 - sizeof ( struct heap_block ) );
94
 	if ( addr < heap_start ) {
95
 	if ( addr < heap_start ) {
96
+		DBG ( "HEAP no space for %x bytes (alignment %d) in [%x,%x)\n",
97
+		      size, align, heap_start, heap_ptr );
95
 		return NULL;
98
 		return NULL;
96
 	}
99
 	}
97
 
100
 
98
 	block = phys_to_virt ( addr );
101
 	block = phys_to_virt ( addr );
99
 	block->size = ( heap_ptr - addr );
102
 	block->size = ( heap_ptr - addr );
103
+	DBG ( "HEAP allocated %x bytes (alignment %d) at %x [%x,%x)\n",
104
+	      size, align, virt_to_phys ( block->data ), addr, heap_ptr );
100
 	heap_ptr = addr;
105
 	heap_ptr = addr;
101
 	return block->data;
106
 	return block->data;
102
 }
107
 }
123
 		( ptr - offsetof ( struct heap_block, data ) );
128
 		( ptr - offsetof ( struct heap_block, data ) );
124
 	heap_ptr += block->size;
129
 	heap_ptr += block->size;
125
 
130
 
131
+	DBG ( "HEAP freed %x [%x,%x)\n", virt_to_phys ( ptr ),
132
+	      virt_to_phys ( block ), heap_ptr );
133
+
126
 	ASSERT ( heap_ptr <= heap_end );
134
 	ASSERT ( heap_ptr <= heap_end );
127
 }
135
 }
128
 
136
 
131
  *
139
  *
132
  */
140
  */
133
 void efree_all ( void ) {
141
 void efree_all ( void ) {
142
+	DBG ( "HEAP discarding allocated blocks in [%x,%x)\n",
143
+	      heap_ptr, heap_end );
144
+
134
 	heap_ptr = heap_end;
145
 	heap_ptr = heap_end;
135
 }
146
 }
136
 
147
 

Loading…
Cancel
Save