Skip to content

Commit 6bddd77

Browse files
committed
---
yaml --- r: 140238 b: refs/heads/try2 c: d231c42 h: refs/heads/master v: v3
1 parent f207feb commit 6bddd77

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: ef6b24d1350ad658faee68f7eddd2c05a56900ce
8+
refs/heads/try2: d231c427e655b7164571a1a712563ba5fd2e4a3c
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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)