YARP
Yet Another Robot Platform
SegFault.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #include "SegFault.h"
7 
8 #include <yarp/os/Log.h>
9 #include <yarp/os/LogComponent.h>
10 #include <yarp/os/LogStream.h>
11 #include <yarp/os/Time.h>
12 
13 namespace {
14 YARP_LOG_COMPONENT(SEGFAULT, "yarp.device.test_segfault")
15 }
16 
18 {
19 }
20 
22 {
23 }
24 
26 {
27  if (config.check("delay")) {
28  delay = config.find("delay").asFloat64();
29  }
30 
31  yCInfo(SEGFAULT) << "Starting thread";
32  start();
33  yCInfo(SEGFAULT) << "Thread started";
34 
35  return true;
36 }
37 
39 {
40  return true;
41 }
42 
44 {
45  yCInfo(SEGFAULT) << "Waiting for" << delay << "seconds before crashing";
46  yarp::os::Time::delay(delay);
47  yCWarning(SEGFAULT) << "Crashing";
48  *(int*) 0 = 0;
49 }
bool close() override
Close the DeviceDriver.
Definition: SegFault.cpp:38
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: SegFault.cpp:25
void run() override
Main body of the new thread.
Definition: SegFault.cpp:43
SegFault()
Definition: SegFault.cpp:17
~SegFault() override
Definition: SegFault.cpp:21
A base class for nested structures that can be searched.
Definition: Searchable.h:66
virtual Value & find(const std::string &key) const =0
Gets a value corresponding to a given keyword.
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
bool start()
Start the new thread running.
Definition: Thread.cpp:93
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
Definition: Value.cpp:222
#define yCInfo(component,...)
Definition: LogComponent.h:132
#define yCWarning(component,...)
Definition: LogComponent.h:143
#define YARP_LOG_COMPONENT(name,...)
Definition: LogComponent.h:77
void delay(double seconds)
Wait for a certain number of seconds.
Definition: Time.cpp:111