gem5
v21.2.1.0
Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
v
w
x
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
o
p
q
r
s
t
v
x
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
g
h
i
l
m
n
o
p
r
s
t
u
w
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Related Functions
:
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Functions
a
b
c
d
e
f
g
h
i
l
m
n
o
p
s
t
v
Variables
a
b
c
d
e
f
g
h
i
m
n
o
p
r
s
t
v
w
Typedefs
a
b
c
d
h
i
l
m
r
s
t
u
w
Enumerations
b
h
i
o
p
Enumerator
h
i
o
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
arch
generic
linux
threadinfo.hh
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2004 The Regents of The University of Michigan
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions are
7
* met: redistributions of source code must retain the above copyright
8
* notice, this list of conditions and the following disclaimer;
9
* redistributions in binary form must reproduce the above copyright
10
* notice, this list of conditions and the following disclaimer in the
11
* documentation and/or other materials provided with the distribution;
12
* neither the name of the copyright holders nor the names of its
13
* contributors may be used to endorse or promote products derived from
14
* this software without specific prior written permission.
15
*
16
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
*/
28
29
#ifndef __ARCH_GENERIC_LINUX_THREADINFO_HH__
30
#define __ARCH_GENERIC_LINUX_THREADINFO_HH__
31
32
#include "
cpu/thread_context.hh
"
33
#include "
mem/translating_port_proxy.hh
"
34
#include "
sim/system.hh
"
35
36
namespace
gem5
37
{
38
39
GEM5_DEPRECATED_NAMESPACE
(
Linux
, linux);
40
namespace
linux
41
{
42
43
class
ThreadInfo
44
{
45
private
:
46
ThreadContext
*
tc
;
47
System
*
sys
;
48
49
ByteOrder
byteOrder
;
50
51
template
<
typename
T>
52
bool
53
get_data
(
const
char
*symbol, T &
data
)
54
{
55
auto
&symtab =
sys
->
workload
->
symtab
(
tc
);
56
auto
it = symtab.
find
(symbol);
57
if
(it == symtab.end()) {
58
warn_once
(
"Unable to find kernel symbol %s\n"
, symbol);
59
warn_once
(
"Kernel not compiled with task_struct info; can't get "
60
"currently executing task/process/thread name/ids!\n"
);
61
return
false
;
62
}
63
64
data
=
TranslatingPortProxy
(
tc
).
read
<T>(it->address,
byteOrder
);
65
66
return
true
;
67
}
68
69
public
:
70
ThreadInfo
(
ThreadContext
*_tc)
71
:
tc
(_tc),
sys
(
tc
->getSystemPtr()),
72
byteOrder
(
tc
->getSystemPtr()->getGuestByteOrder())
73
{
74
75
}
76
~ThreadInfo
()
77
{}
78
79
virtual
Addr
80
curThreadInfo
()
81
{
82
panic
(
"curThreadInfo() not implemented."
);
83
}
84
85
Addr
86
curTaskInfo
(
Addr
thread_info
= 0)
87
{
88
// Note that in Linux 4.10 the thread_info struct will no longer have a
89
// pointer to the task_struct for arm64. See:
90
// https://patchwork.kernel.org/patch/9333699/
91
int32_t
offset
= 0;
92
if
(!
get_data
(
"thread_info_task"
,
offset
))
93
return
0;
94
95
if
(!
thread_info
)
96
thread_info
=
curThreadInfo
();
97
98
return
TranslatingPortProxy
(
tc
).
read
<
Addr
>(
thread_info
+
offset
);
99
}
100
101
int32_t
102
curTaskPIDFromTaskStruct
(
Addr
task_struct)
103
{
104
int32_t
offset
= 0;
105
if
(!
get_data
(
"task_struct_pid"
,
offset
))
106
return
-1;
107
108
return
TranslatingPortProxy
(
tc
).
read
<int32_t>(task_struct +
offset
);
109
}
110
111
int32_t
112
curTaskPID
(
Addr
thread_info
= 0)
113
{
114
return
curTaskPIDFromTaskStruct
(
curTaskInfo
(
thread_info
));
115
}
116
117
int32_t
118
curTaskTGIDFromTaskStruct
(
Addr
task_struct)
119
{
120
int32_t
offset
= 0;
121
if
(!
get_data
(
"task_struct_tgid"
,
offset
))
122
return
-1;
123
124
return
TranslatingPortProxy
(
tc
).
read
<int32_t>(task_struct +
offset
);
125
}
126
127
int32_t
128
curTaskTGID
(
Addr
thread_info
= 0)
129
{
130
return
curTaskTGIDFromTaskStruct
(
curTaskInfo
(
thread_info
));
131
}
132
133
int64_t
134
curTaskStartFromTaskStruct
(
Addr
task_struct)
135
{
136
int32_t
offset
= 0;
137
if
(!
get_data
(
"task_struct_start_time"
,
offset
))
138
return
-1;
139
140
// start_time is actually of type timespec, but if we just
141
// grab the first long, we'll get the seconds out of it
142
return
TranslatingPortProxy
(
tc
).
read
<int64_t>(task_struct +
offset
);
143
}
144
145
int64_t
146
curTaskStart
(
Addr
thread_info
= 0)
147
{
148
return
curTaskStartFromTaskStruct
(
curTaskInfo
(
thread_info
));
149
}
150
151
std::string
152
curTaskNameFromTaskStruct
(
Addr
task_struct)
153
{
154
int32_t
offset
= 0;
155
int32_t size = 0;
156
157
if
(!
get_data
(
"task_struct_comm"
,
offset
))
158
return
"FailureIn_curTaskName"
;
159
160
if
(!
get_data
(
"task_struct_comm_size"
, size))
161
return
"FailureIn_curTaskName"
;
162
163
char
buffer[size + 1];
164
TranslatingPortProxy
(
tc
).
readString
(
165
buffer, task_struct +
offset
, size);
166
167
return
buffer;
168
}
169
170
std::string
171
curTaskName
(
Addr
thread_info
= 0)
172
{
173
return
curTaskNameFromTaskStruct
(
curTaskInfo
(
thread_info
));
174
}
175
176
int32_t
177
curTaskMmFromTaskStruct
(
Addr
task_struct)
178
{
179
int32_t
offset
;
180
if
(!
get_data
(
"task_struct_mm"
,
offset
))
181
return
-1;
182
183
return
TranslatingPortProxy
(
tc
).
read
<int32_t>(task_struct +
offset
);
184
}
185
186
int32_t
187
curTaskMm
(
Addr
thread_info
= 0)
188
{
189
return
curTaskMmFromTaskStruct
(
curTaskInfo
(
thread_info
));
190
}
191
};
192
193
}
// namespace linux
194
}
// namespace gem5
195
196
#endif // __ARCH_GENERIC_LINUX_THREADINFO_HH__
gem5::linux::ThreadInfo::curTaskMmFromTaskStruct
int32_t curTaskMmFromTaskStruct(Addr task_struct)
Definition:
threadinfo.hh:177
gem5::linux::ThreadInfo::curTaskPID
int32_t curTaskPID(Addr thread_info=0)
Definition:
threadinfo.hh:112
gem5::linux::ThreadInfo
Definition:
threadinfo.hh:43
system.hh
data
const char data[]
Definition:
circlebuf.test.cc:48
gem5::PortProxy::readString
void readString(std::string &str, Addr addr) const
Same as tryReadString, but insists on success.
Definition:
port_proxy.hh:260
gem5::linux::ThreadInfo::~ThreadInfo
~ThreadInfo()
Definition:
threadinfo.hh:76
warn_once
#define warn_once(...)
Definition:
logging.hh:250
gem5::linux::ThreadInfo::ThreadInfo
ThreadInfo(ThreadContext *_tc)
Definition:
threadinfo.hh:70
gem5::linux::ThreadInfo::curTaskMm
int32_t curTaskMm(Addr thread_info=0)
Definition:
threadinfo.hh:187
translating_port_proxy.hh
gem5::linux::thread_info
Definition:
thread_info.hh:40
gem5::System::workload
Workload * workload
OS kernel.
Definition:
system.hh:330
gem5::linux::ThreadInfo::curTaskPIDFromTaskStruct
int32_t curTaskPIDFromTaskStruct(Addr task_struct)
Definition:
threadinfo.hh:102
gem5::linux::ThreadInfo::get_data
bool get_data(const char *symbol, T &data)
Definition:
threadinfo.hh:53
gem5::linux::ThreadInfo::sys
System * sys
Definition:
threadinfo.hh:47
gem5::TranslatingPortProxy
This proxy attempts to translate virtual addresses using the TLBs.
Definition:
translating_port_proxy.hh:60
gem5::linux::ThreadInfo::curTaskInfo
Addr curTaskInfo(Addr thread_info=0)
Definition:
threadinfo.hh:86
gem5::System
Definition:
system.hh:75
gem5::ThreadContext
ThreadContext is the external interface to all thread state for anything outside of the CPU.
Definition:
thread_context.hh:94
gem5::PortProxy::read
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
Definition:
port_proxy.hh:287
gem5::linux::ThreadInfo::curTaskStart
int64_t curTaskStart(Addr thread_info=0)
Definition:
threadinfo.hh:146
gem5::ArmISA::offset
Bitfield< 23, 0 > offset
Definition:
types.hh:144
gem5::linux::ThreadInfo::curTaskNameFromTaskStruct
std::string curTaskNameFromTaskStruct(Addr task_struct)
Definition:
threadinfo.hh:152
gem5::linux::ThreadInfo::curTaskTGID
int32_t curTaskTGID(Addr thread_info=0)
Definition:
threadinfo.hh:128
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition:
types.hh:147
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
gem5::linux::ThreadInfo::tc
ThreadContext * tc
Definition:
threadinfo.hh:46
gem5::Workload::symtab
virtual const loader::SymbolTable & symtab(ThreadContext *tc)=0
gem5::linux::ThreadInfo::curTaskName
std::string curTaskName(Addr thread_info=0)
Definition:
threadinfo.hh:171
gem5::loader::SymbolTable::find
const_iterator find(Addr address) const
Search for a symbol by its address.
Definition:
symtab.hh:322
gem5::linux::ThreadInfo::curThreadInfo
virtual Addr curThreadInfo()
Definition:
threadinfo.hh:80
gem5::linux::ThreadInfo::curTaskTGIDFromTaskStruct
int32_t curTaskTGIDFromTaskStruct(Addr task_struct)
Definition:
threadinfo.hh:118
gem5::linux::ThreadInfo::byteOrder
ByteOrder byteOrder
Definition:
threadinfo.hh:49
gem5::linux::ThreadInfo::curTaskStartFromTaskStruct
int64_t curTaskStartFromTaskStruct(Addr task_struct)
Definition:
threadinfo.hh:134
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition:
tlb.cc:60
thread_context.hh
gem5::loader::Linux
@ Linux
Definition:
object_file.hh:73
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition:
logging.hh:178
Generated on Tue Feb 8 2022 11:46:59 for gem5 by
doxygen
1.8.17