1 | /* |
---|
2 | * sys_trace.c - show kernel active processes and threads |
---|
3 | * |
---|
4 | * Author Alain Greiner (c) (2016,2017) |
---|
5 | * |
---|
6 | * Copyright (c) UPMC Sorbonne Universites |
---|
7 | * |
---|
8 | * This file is part of ALMOS-MKH. |
---|
9 | * |
---|
10 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
11 | * under the terms of the GNU General Public License as published by |
---|
12 | * the Free Software Foundation; version 2.0 of the License. |
---|
13 | * |
---|
14 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | * General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
22 | */ |
---|
23 | |
---|
24 | #include <hal_types.h> |
---|
25 | #include <hal_special.h> |
---|
26 | #include <printk.h> |
---|
27 | #include <thread.h> |
---|
28 | #include <errno.h> |
---|
29 | #include <syscalls.h> |
---|
30 | |
---|
31 | ////////////////////////////////// |
---|
32 | int sys_trace( uint32_t operation, |
---|
33 | pid_t pid, |
---|
34 | uint32_t trdid ) |
---|
35 | { |
---|
36 | // get extended pointer on target thread |
---|
37 | xptr_t thread_xp = thread_get_xptr( pid , trdid ); |
---|
38 | |
---|
39 | if( thread_xp == XPTR_NULL ) |
---|
40 | { |
---|
41 | printk("\n[ERROR] in %s : undefined thread for PID = %x / TRDID = %x\n", |
---|
42 | __FUNCTION__ , pid , trdid ); |
---|
43 | CURRENT_THREAD->errno = EINVAL; |
---|
44 | return -1; |
---|
45 | } |
---|
46 | |
---|
47 | if( operation == TRACE_OFF ) |
---|
48 | { |
---|
49 | // desactivate thread trace TODO |
---|
50 | |
---|
51 | printk("\n[DBG] %s : trace OFF for thread %x in process %x\n", |
---|
52 | __FUNCTION__ , trdid , pid ); |
---|
53 | } |
---|
54 | else if( operation == TRACE_ON ) |
---|
55 | { |
---|
56 | // activate thread trace TODO |
---|
57 | |
---|
58 | printk("\n[DBG] %s : trace ON for thread %x in process %x\n", |
---|
59 | __FUNCTION__ , trdid , pid ); |
---|
60 | } |
---|
61 | else |
---|
62 | { |
---|
63 | printk("\n[ERROR] in %s : undefined operation\n", __FUNCTION__ ); |
---|
64 | CURRENT_THREAD->errno = EINVAL; |
---|
65 | return -1; |
---|
66 | } |
---|
67 | |
---|
68 | hal_fence(); |
---|
69 | |
---|
70 | return 0; |
---|
71 | |
---|
72 | } // end sys_trace() |
---|