Bug 497723 - forgot to restore callgrind output cleanup
[valgrind.git] / none / tests / darwin / bug254164.c
blob9bb49274c030afbab4bb6885f8e462efa7154aa9
1 // Small test program to demonstrate Valgrind bug.
2 // https://bugs.kde.org/show_bug.cgi?id=254164
5 #include <stdio.h>
6 #include <sys/resource.h>
8 #include <unistd.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <sys/types.h>
12 #include <sys/sysctl.h>
13 #include <mach/task.h>
14 #include <mach/mach_init.h>
16 void getres(task_t task, unsigned int *rss, unsigned int *vs)
18 struct task_basic_info t_info;
19 mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT;
21 task_info(task, TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count);
22 *rss = t_info.resident_size;
23 *vs = t_info.virtual_size;
26 /** It appears task_set_info() is a deprecated interface on modern Darwin
27 * Per comments in osfmk/kern/task.c:
29 * This routine was added, pretty much exclusively, for registering the
30 * RPC glue vector for in-kernel short circuited tasks. Rather than
31 * removing it completely, I have only disabled that feature (which was
32 * the only feature at the time).
34 /**
35 void setres(task_t task)
37 struct task_trace_memory_info t_info;
38 mach_msg_type_number_t t_info_count = TASK_TRACE_MEMORY_INFO_COUNT;
40 t_info.user_memory_address = NULL;
41 t_info.buffer_size = 0;
42 t_info.mailbox_array_size = 0;
44 task_set_info(task, TASK_TRACE_MEMORY_INFO, (task_info_t)&t_info, &t_info_count);
48 int main(void)
50 unsigned int rss, vs;
51 task_t task = MACH_PORT_NULL;
53 if (task_for_pid(current_task(), getpid(), &task) != KERN_SUCCESS)
54 abort();
56 getres(task, &rss, &vs);
57 //setres(task);
59 return 0;