Skip to content

Commit 692aea1

Browse files
committed
Data structure to hold the metrics implemented.Debugging in process
1 parent c1a461e commit 692aea1

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

src/libcore/memory_watcher.rs

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,48 @@ import priv::{chan_from_global_ptr, weaken_task};
55
import comm::{Port, Chan, select2, listen};
66
import task::TaskBuilder;
77
import either::{Left, Right};
8+
import send_map::linear;
89

910
#[abi = "cdecl"]
1011
extern mod rustrt {
1112
fn rust_global_memory_watcher_chan_ptr() -> *libc::uintptr_t;
1213
}
1314

1415
enum Msg {
15-
ReportAllocation(Task,libc::uintptr_t,*libc::c_char)
16+
ReportAllocation(Task, libc::uintptr_t, *libc::c_char, *libc::c_char)
1617
}
1718

19+
type MemoryWatcherKey = (int, libc::uintptr_t, libc::uintptr_t);
20+
1821
fn global_memory_watcher_spawner(msg_po: comm::Port<Msg>)
1922
{
2023
let msg_received = msg_po.recv();
21-
let (task_enum_received,size_allocated,td_value) = match msg_received {
22-
ReportAllocation(t,s,c) => (t,s,c)
24+
let (task_enum_received,size_allocated,td_value,address_allocation) = match msg_received {
25+
ReportAllocation(t,s,c,a) => (t,s,c,a)
2326
};
27+
28+
let mut hm_index:linear::LinearMap<int, @mut linear::LinearMap<libc::uintptr_t, MemoryWatcherKey>> = linear::LinearMap();
29+
30+
loop {
31+
match msg_po.recv() {
32+
ReportAllocation(t, s, c,a) => {
33+
let Metrics_value:MemoryWatcherKey = (*(t), s, (c as libc::uintptr_t));
34+
let test1:int = (*t);
35+
let val1 = hm_index.find(&test1);
36+
match val1 {
37+
Some(T) => {
38+
let hm_task_LinearMap:@mut linear::LinearMap<libc::uintptr_t, MemoryWatcherKey> = T;
39+
hm_task_LinearMap.insert((a as libc::uintptr_t), Metrics_value);
40+
}
41+
None => {
42+
let hm_task:@mut linear::LinearMap<libc::uintptr_t, MemoryWatcherKey> = @mut linear::LinearMap();
43+
hm_task.insert((a as libc::uintptr_t), Metrics_value);
44+
hm_index.insert(*(t), hm_task);
45+
}
46+
}
47+
}
48+
}
49+
}
2450

2551
let remote_task_id = *(task_enum_received);
2652

0 commit comments

Comments
 (0)