Skip to content

Commit 22b4437

Browse files
committed
---
yaml --- r: 59861 b: refs/heads/master c: d231c42 h: refs/heads/master i: 59859: 8d96a94 v: v3
1 parent 24d15a4 commit 22b4437

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: ef6b24d1350ad658faee68f7eddd2c05a56900ce
2+
refs/heads/master: d231c427e655b7164571a1a712563ba5fd2e4a3c
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2d28d645422c1617be58c8ca7ad9a457264ca850
55
refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589

trunk/src/libcore/unstable/lang.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ pub mod rustrt {
5151

5252
#[rust_stack]
5353
fn rust_set_task_borrow_list(task: *rust_task, map: *c_void);
54+
55+
fn rust_dbg_breakpoint();
5456
}
5557
}
5658

@@ -88,6 +90,8 @@ fn swap_task_borrow_list(f: &fn(~[BorrowRecord]) -> ~[BorrowRecord]) {
8890
}
8991

9092
pub fn fail_borrowed(box: *mut BoxRepr, file: *c_char, line: size_t) {
93+
debug_ptr("fail_borrowed: ", box);
94+
9195
if !::rt::env::get().debug_borrows {
9296
let msg = "borrowed";
9397
do str::as_buf(msg) |msg_p, _| {
@@ -130,15 +134,15 @@ pub unsafe fn exchange_malloc(td: *c_char, size: uintptr_t) -> *c_char {
130134
static ENABLE_DEBUG_PTR: bool = false;
131135

132136
#[inline]
133-
pub fn debug_ptr<T>(tag: &'static str, p: *T) {
137+
pub fn debug_ptr<T>(tag: &'static str, p: *const T) {
134138
//! A useful debugging function that prints a pointer + tag + newline
135139
//! without allocating memory.
136140
137141
if ENABLE_DEBUG_PTR && ::rt::env::get().debug_mem {
138142
debug_ptr_slow(tag, p);
139143
}
140144

141-
fn debug_ptr_slow<T>(tag: &'static str, p: *T) {
145+
fn debug_ptr_slow<T>(tag: &'static str, p: *const T) {
142146
use io;
143147
let dbg = STDERR_FILENO as io::fd_t;
144148
let letters = ['0', '1', '2', '3', '4', '5', '6', '7', '8',
@@ -209,14 +213,17 @@ fn add_borrow_to_task_list(a: *mut BoxRepr, file: *c_char, line: size_t) {
209213
#[inline(always)]
210214
pub unsafe fn borrow_as_imm(a: *u8, file: *c_char, line: size_t) -> uint {
211215
let a: *mut BoxRepr = transmute(a);
212-
213216
let ref_count = (*a).header.ref_count;
217+
218+
debug_ptr("borrow_as_imm (ptr): ", a);
219+
debug_ptr("borrow_as_imm (ref): ", ref_count as *());
220+
214221
if (ref_count & MUT_BIT) != 0 {
215222
fail_borrowed(a, file, line);
216223
} else {
217224
(*a).header.ref_count |= FROZEN_BIT;
218225
if ::rt::env::get().debug_borrows {
219-
add_borrow_to_list(a, file, line);
226+
add_borrow_to_task_list(a, file, line);
220227
}
221228
}
222229
ref_count
@@ -228,13 +235,16 @@ pub unsafe fn borrow_as_imm(a: *u8, file: *c_char, line: size_t) -> uint {
228235
pub unsafe fn borrow_as_mut(a: *u8, file: *c_char, line: size_t) -> uint {
229236
let a: *mut BoxRepr = transmute(a);
230237

238+
debug_ptr("borrow_as_mut (ptr): ", a);
239+
debug_ptr("borrow_as_mut (line): ", line as *());
240+
231241
let ref_count = (*a).header.ref_count;
232242
if (ref_count & (MUT_BIT|FROZEN_BIT)) != 0 {
233243
fail_borrowed(a, file, line);
234244
} else {
235245
(*a).header.ref_count |= (MUT_BIT|FROZEN_BIT);
236246
if ::rt::env::get().debug_borrows {
237-
add_borrow_to_list(a, file, line);
247+
add_borrow_to_task_list(a, file, line);
238248
}
239249
}
240250
ref_count
@@ -261,6 +271,9 @@ pub unsafe fn return_to_mut(a: *u8, old_ref_count: uint) {
261271
if !a.is_null() {
262272
let a: *mut BoxRepr = transmute(a);
263273

274+
debug_ptr("return_to_mut (ptr): ", a);
275+
debug_ptr("return_to_mut (ref): ", old_ref_count as *());
276+
264277
let ref_count = (*a).header.ref_count & !ALL_BITS;
265278
let old_bits = old_ref_count & ALL_BITS;
266279
(*a).header.ref_count = ref_count | old_bits;

0 commit comments

Comments
 (0)