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