Skyward boardcore
Loading...
Searching...
No Matches
StackLogger.h
Go to the documentation of this file.
1
/* Copyright (c) 2019 Skyward Experimental Rocketry
2
* Author: Luca Erbetta
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to deal
6
* in the Software without restriction, including without limitation the rights
7
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
* copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
* THE SOFTWARE.
21
*/
22
23
#pragma once
24
25
#include <
ActiveObject.h
>
26
#include <
Singleton.h
>
27
#include <
logger/Logger.h
>
28
#include <
utils/KernelTime.h
>
29
30
#include <map>
31
32
#include "
StackData.h
"
33
34
using
miosix::FastMutex;
35
using
miosix::Lock;
36
37
namespace
Boardcore
38
{
39
45
class
StackLogger
:
public
Singleton
<StackLogger>
46
{
47
friend
class
Singleton
<
StackLogger
>;
48
49
public
:
55
void
updateStack
(uint8_t threadId)
56
{
57
StackData
d;
58
d.
timestamp
=
Kernel::getOldTick
();
59
d.
threadId
= threadId;
60
d.
minimumStack
= miosix::MemoryProfiling::getAbsoluteFreeStack();
61
62
{
63
Lock<FastMutex> l(mutex);
64
stacks[threadId] = d;
65
}
66
}
67
72
void
log
()
73
{
74
{
75
Lock<FastMutex> l(mutex);
76
for
(
auto
it = stacks.begin(); it != stacks.end(); it++)
77
Logger::getInstance
().log(it->second);
78
}
79
}
80
81
private
:
82
StackLogger
() {}
83
~StackLogger() {}
84
85
FastMutex mutex;
86
std::map<uint8_t, StackData> stacks;
87
};
88
89
}
// namespace Boardcore
ActiveObject.h
KernelTime.h
Logger.h
Singleton.h
StackData.h
Boardcore::Singleton
Definition
Singleton.h:47
Boardcore::Singleton< Logger >::getInstance
static Logger & getInstance()
Definition
Singleton.h:52
Boardcore::StackLogger
Definition
StackLogger.h:46
Boardcore::StackLogger::log
void log()
Definition
StackLogger.h:72
Boardcore::StackLogger::updateStack
void updateStack(uint8_t threadId)
Definition
StackLogger.h:55
Boardcore::Kernel::getOldTick
long long getOldTick()
Get the current time in milliseconds.
Definition
KernelTime.h:43
Boardcore
This file includes all the types the logdecoder script will decode.
Definition
ActiveObject.h:31
Boardcore::StackData
Definition
StackData.h:52
Boardcore::StackData::threadId
uint8_t threadId
Definition
StackData.h:54
Boardcore::StackData::timestamp
long long timestamp
Definition
StackData.h:53
Boardcore::StackData::minimumStack
unsigned int minimumStack
Definition
StackData.h:55
src
shared
diagnostic
StackLogger.h
Generated by
1.10.0