cmProcess.cxx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmProcess.h"
  4. #include "cmCTest.h"
  5. #include "cmCTestRunTest.h"
  6. #include "cmCTestTestHandler.h"
  7. #include "cmsys/Process.h"
  8. #include <algorithm>
  9. #include <fcntl.h>
  10. #include <iostream>
  11. #include <signal.h>
  12. #include <string>
  13. #if !defined(_WIN32)
  14. #include <unistd.h>
  15. #endif
  16. #define CM_PROCESS_BUF_SIZE 65536
  17. #if defined(_WIN32) && !defined(__CYGWIN__)
  18. #include <io.h>
  19. static int cmProcessGetPipes(int* fds)
  20. {
  21. SECURITY_ATTRIBUTES attr;
  22. HANDLE readh, writeh;
  23. attr.nLength = sizeof(attr);
  24. attr.lpSecurityDescriptor = nullptr;
  25. attr.bInheritHandle = FALSE;
  26. if (!CreatePipe(&readh, &writeh, &attr, 0))
  27. return uv_translate_sys_error(GetLastError());
  28. fds[0] = _open_osfhandle((intptr_t)readh, 0);
  29. fds[1] = _open_osfhandle((intptr_t)writeh, 0);
  30. if (fds[0] == -1 || fds[1] == -1) {
  31. CloseHandle(readh);
  32. CloseHandle(writeh);
  33. return uv_translate_sys_error(GetLastError());
  34. }
  35. return 0;
  36. }
  37. #else
  38. #include <errno.h>
  39. static int cmProcessGetPipes(int* fds)
  40. {
  41. if (pipe(fds) == -1) {
  42. return uv_translate_sys_error(errno);
  43. }
  44. if (fcntl(fds[0], F_SETFD, FD_CLOEXEC) == -1 ||
  45. fcntl(fds[1], F_SETFD, FD_CLOEXEC) == -1) {
  46. close(fds[0]);
  47. close(fds[1]);
  48. return uv_translate_sys_error(errno);
  49. }
  50. return 0;
  51. }
  52. #endif
  53. cmProcess::cmProcess(cmCTestRunTest& runner)
  54. : Runner(runner)
  55. , Conv(cmProcessOutput::UTF8, CM_PROCESS_BUF_SIZE)
  56. {
  57. this->Timeout = cmDuration::zero();
  58. this->TotalTime = cmDuration::zero();
  59. this->ExitValue = 0;
  60. this->Id = 0;
  61. this->StartTime = std::chrono::steady_clock::time_point();
  62. }
  63. cmProcess::~cmProcess()
  64. {
  65. }
  66. void cmProcess::SetCommand(const char* command)
  67. {
  68. this->Command = command;
  69. }
  70. void cmProcess::SetCommandArguments(std::vector<std::string> const& args)
  71. {
  72. this->Arguments = args;
  73. }
  74. bool cmProcess::StartProcess(uv_loop_t& loop)
  75. {
  76. this->ProcessState = cmProcess::State::Error;
  77. if (this->Command.empty()) {
  78. return false;
  79. }
  80. this->StartTime = std::chrono::steady_clock::now();
  81. this->ProcessArgs.clear();
  82. // put the command as arg0
  83. this->ProcessArgs.push_back(this->Command.c_str());
  84. // now put the command arguments in
  85. for (std::string const& arg : this->Arguments) {
  86. this->ProcessArgs.push_back(arg.c_str());
  87. }
  88. this->ProcessArgs.push_back(nullptr); // null terminate the list
  89. cm::uv_timer_ptr timer;
  90. int status = timer.init(loop, this);
  91. if (status != 0) {
  92. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  93. "Error initializing timer: " << uv_strerror(status)
  94. << std::endl);
  95. return false;
  96. }
  97. cm::uv_pipe_ptr pipe_writer;
  98. cm::uv_pipe_ptr pipe_reader;
  99. pipe_writer.init(loop, 0);
  100. pipe_reader.init(loop, 0, this);
  101. int fds[2] = { -1, -1 };
  102. status = cmProcessGetPipes(fds);
  103. if (status != 0) {
  104. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  105. "Error initializing pipe: " << uv_strerror(status)
  106. << std::endl);
  107. return false;
  108. }
  109. uv_pipe_open(pipe_reader, fds[0]);
  110. uv_pipe_open(pipe_writer, fds[1]);
  111. uv_stdio_container_t stdio[3];
  112. stdio[0].flags = UV_IGNORE;
  113. stdio[1].flags = UV_INHERIT_STREAM;
  114. stdio[1].data.stream = pipe_writer;
  115. stdio[2] = stdio[1];
  116. uv_process_options_t options = uv_process_options_t();
  117. options.file = this->Command.data();
  118. options.args = const_cast<char**>(this->ProcessArgs.data());
  119. options.stdio_count = 3; // in, out and err
  120. options.exit_cb = &cmProcess::OnExitCB;
  121. options.stdio = stdio;
  122. status =
  123. uv_read_start(pipe_reader, &cmProcess::OnAllocateCB, &cmProcess::OnReadCB);
  124. if (status != 0) {
  125. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  126. "Error starting read events: " << uv_strerror(status)
  127. << std::endl);
  128. return false;
  129. }
  130. status = this->Process.spawn(loop, options, this);
  131. if (status != 0) {
  132. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE, "Process not started\n "
  133. << this->Command << "\n[" << uv_strerror(status) << "]\n");
  134. return false;
  135. }
  136. this->PipeReader = std::move(pipe_reader);
  137. this->Timer = std::move(timer);
  138. this->StartTimer();
  139. this->ProcessState = cmProcess::State::Executing;
  140. return true;
  141. }
  142. void cmProcess::StartTimer()
  143. {
  144. auto properties = this->Runner.GetTestProperties();
  145. auto msec =
  146. std::chrono::duration_cast<std::chrono::milliseconds>(this->Timeout);
  147. if (msec != std::chrono::milliseconds(0) || !properties->ExplicitTimeout) {
  148. this->Timer.start(&cmProcess::OnTimeoutCB,
  149. static_cast<uint64_t>(msec.count()), 0);
  150. }
  151. }
  152. bool cmProcess::Buffer::GetLine(std::string& line)
  153. {
  154. // Scan for the next newline.
  155. for (size_type sz = this->size(); this->Last != sz; ++this->Last) {
  156. if ((*this)[this->Last] == '\n' || (*this)[this->Last] == '\0') {
  157. // Extract the range first..last as a line.
  158. const char* text = &*this->begin() + this->First;
  159. size_type length = this->Last - this->First;
  160. while (length && text[length - 1] == '\r') {
  161. length--;
  162. }
  163. line.assign(text, length);
  164. // Start a new range for the next line.
  165. ++this->Last;
  166. this->First = Last;
  167. // Return the line extracted.
  168. return true;
  169. }
  170. }
  171. // Available data have been exhausted without a newline.
  172. if (this->First != 0) {
  173. // Move the partial line to the beginning of the buffer.
  174. this->erase(this->begin(), this->begin() + this->First);
  175. this->First = 0;
  176. this->Last = this->size();
  177. }
  178. return false;
  179. }
  180. bool cmProcess::Buffer::GetLast(std::string& line)
  181. {
  182. // Return the partial last line, if any.
  183. if (!this->empty()) {
  184. line.assign(&*this->begin(), this->size());
  185. this->First = this->Last = 0;
  186. this->clear();
  187. return true;
  188. }
  189. return false;
  190. }
  191. void cmProcess::OnReadCB(uv_stream_t* stream, ssize_t nread,
  192. const uv_buf_t* buf)
  193. {
  194. auto self = static_cast<cmProcess*>(stream->data);
  195. self->OnRead(nread, buf);
  196. }
  197. void cmProcess::OnRead(ssize_t nread, const uv_buf_t* buf)
  198. {
  199. std::string line;
  200. if (nread > 0) {
  201. std::string strdata;
  202. this->Conv.DecodeText(buf->base, static_cast<size_t>(nread), strdata);
  203. this->Output.insert(this->Output.end(), strdata.begin(), strdata.end());
  204. while (this->Output.GetLine(line)) {
  205. this->Runner.CheckOutput(line);
  206. line.clear();
  207. }
  208. return;
  209. }
  210. if (nread == 0) {
  211. return;
  212. }
  213. // The process will provide no more data.
  214. if (nread != UV_EOF) {
  215. auto error = static_cast<int>(nread);
  216. cmCTestLog(this->Runner.GetCTest(), ERROR_MESSAGE,
  217. "Error reading stream: " << uv_strerror(error) << std::endl);
  218. }
  219. // Look for partial last lines.
  220. if (this->Output.GetLast(line)) {
  221. this->Runner.CheckOutput(line);
  222. }
  223. this->ReadHandleClosed = true;
  224. this->PipeReader.reset();
  225. if (this->ProcessHandleClosed) {
  226. uv_timer_stop(this->Timer);
  227. this->Runner.FinalizeTest();
  228. }
  229. }
  230. void cmProcess::OnAllocateCB(uv_handle_t* handle, size_t suggested_size,
  231. uv_buf_t* buf)
  232. {
  233. auto self = static_cast<cmProcess*>(handle->data);
  234. self->OnAllocate(suggested_size, buf);
  235. }
  236. void cmProcess::OnAllocate(size_t /*suggested_size*/, uv_buf_t* buf)
  237. {
  238. if (this->Buf.size() != CM_PROCESS_BUF_SIZE) {
  239. this->Buf.resize(CM_PROCESS_BUF_SIZE);
  240. }
  241. *buf =
  242. uv_buf_init(this->Buf.data(), static_cast<unsigned int>(this->Buf.size()));
  243. }
  244. void cmProcess::OnTimeoutCB(uv_timer_t* timer)
  245. {
  246. auto self = static_cast<cmProcess*>(timer->data);
  247. self->OnTimeout();
  248. }
  249. void cmProcess::OnTimeout()
  250. {
  251. if (this->ProcessState != cmProcess::State::Executing) {
  252. return;
  253. }
  254. this->ProcessState = cmProcess::State::Expired;
  255. bool const was_still_reading = !this->ReadHandleClosed;
  256. if (!this->ReadHandleClosed) {
  257. this->ReadHandleClosed = true;
  258. this->PipeReader.reset();
  259. }
  260. if (!this->ProcessHandleClosed) {
  261. // Kill the child and let our on-exit handler finish the test.
  262. cmsysProcess_KillPID(static_cast<unsigned long>(this->Process->pid));
  263. } else if (was_still_reading) {
  264. // Our on-exit handler already ran but did not finish the test
  265. // because we were still reading output. We've just dropped
  266. // our read handler, so we need to finish the test now.
  267. this->Runner.FinalizeTest();
  268. }
  269. }
  270. void cmProcess::OnExitCB(uv_process_t* process, int64_t exit_status,
  271. int term_signal)
  272. {
  273. auto self = static_cast<cmProcess*>(process->data);
  274. self->OnExit(exit_status, term_signal);
  275. }
  276. void cmProcess::OnExit(int64_t exit_status, int term_signal)
  277. {
  278. if (this->ProcessState != cmProcess::State::Expired) {
  279. if (
  280. #if defined(_WIN32)
  281. ((DWORD)exit_status & 0xF0000000) == 0xC0000000
  282. #else
  283. term_signal != 0
  284. #endif
  285. ) {
  286. this->ProcessState = cmProcess::State::Exception;
  287. } else {
  288. this->ProcessState = cmProcess::State::Exited;
  289. }
  290. }
  291. // Record exit information.
  292. this->ExitValue = static_cast<int>(exit_status);
  293. this->Signal = term_signal;
  294. this->TotalTime = std::chrono::steady_clock::now() - this->StartTime;
  295. // Because of a processor clock scew the runtime may become slightly
  296. // negative. If someone changed the system clock while the process was
  297. // running this may be even more. Make sure not to report a negative
  298. // duration here.
  299. if (this->TotalTime <= cmDuration::zero()) {
  300. this->TotalTime = cmDuration::zero();
  301. }
  302. this->ProcessHandleClosed = true;
  303. if (this->ReadHandleClosed) {
  304. uv_timer_stop(this->Timer);
  305. this->Runner.FinalizeTest();
  306. }
  307. }
  308. cmProcess::State cmProcess::GetProcessStatus()
  309. {
  310. return this->ProcessState;
  311. }
  312. void cmProcess::ChangeTimeout(cmDuration t)
  313. {
  314. this->Timeout = t;
  315. this->StartTimer();
  316. }
  317. void cmProcess::ResetStartTime()
  318. {
  319. this->StartTime = std::chrono::steady_clock::now();
  320. }
  321. cmProcess::Exception cmProcess::GetExitException()
  322. {
  323. auto exception = Exception::None;
  324. #if defined(_WIN32) && !defined(__CYGWIN__)
  325. auto exit_code = (DWORD) this->ExitValue;
  326. if ((exit_code & 0xF0000000) != 0xC0000000) {
  327. return exception;
  328. }
  329. if (exit_code) {
  330. switch (exit_code) {
  331. case STATUS_DATATYPE_MISALIGNMENT:
  332. case STATUS_ACCESS_VIOLATION:
  333. case STATUS_IN_PAGE_ERROR:
  334. case STATUS_INVALID_HANDLE:
  335. case STATUS_NONCONTINUABLE_EXCEPTION:
  336. case STATUS_INVALID_DISPOSITION:
  337. case STATUS_ARRAY_BOUNDS_EXCEEDED:
  338. case STATUS_STACK_OVERFLOW:
  339. exception = Exception::Fault;
  340. break;
  341. case STATUS_FLOAT_DENORMAL_OPERAND:
  342. case STATUS_FLOAT_DIVIDE_BY_ZERO:
  343. case STATUS_FLOAT_INEXACT_RESULT:
  344. case STATUS_FLOAT_INVALID_OPERATION:
  345. case STATUS_FLOAT_OVERFLOW:
  346. case STATUS_FLOAT_STACK_CHECK:
  347. case STATUS_FLOAT_UNDERFLOW:
  348. #ifdef STATUS_FLOAT_MULTIPLE_FAULTS
  349. case STATUS_FLOAT_MULTIPLE_FAULTS:
  350. #endif
  351. #ifdef STATUS_FLOAT_MULTIPLE_TRAPS
  352. case STATUS_FLOAT_MULTIPLE_TRAPS:
  353. #endif
  354. case STATUS_INTEGER_DIVIDE_BY_ZERO:
  355. case STATUS_INTEGER_OVERFLOW:
  356. exception = Exception::Numerical;
  357. break;
  358. case STATUS_CONTROL_C_EXIT:
  359. exception = Exception::Interrupt;
  360. break;
  361. case STATUS_ILLEGAL_INSTRUCTION:
  362. case STATUS_PRIVILEGED_INSTRUCTION:
  363. exception = Exception::Illegal;
  364. break;
  365. default:
  366. exception = Exception::Other;
  367. }
  368. }
  369. #else
  370. if (this->Signal) {
  371. switch (this->Signal) {
  372. case SIGSEGV:
  373. exception = Exception::Fault;
  374. break;
  375. case SIGFPE:
  376. exception = Exception::Numerical;
  377. break;
  378. case SIGINT:
  379. exception = Exception::Interrupt;
  380. break;
  381. case SIGILL:
  382. exception = Exception::Illegal;
  383. break;
  384. default:
  385. exception = Exception::Other;
  386. }
  387. }
  388. #endif
  389. return exception;
  390. }
  391. std::string cmProcess::GetExitExceptionString()
  392. {
  393. std::string exception_str;
  394. #if defined(_WIN32)
  395. switch (this->ExitValue) {
  396. case STATUS_CONTROL_C_EXIT:
  397. exception_str = "User interrupt";
  398. break;
  399. case STATUS_FLOAT_DENORMAL_OPERAND:
  400. exception_str = "Floating-point exception (denormal operand)";
  401. break;
  402. case STATUS_FLOAT_DIVIDE_BY_ZERO:
  403. exception_str = "Divide-by-zero";
  404. break;
  405. case STATUS_FLOAT_INEXACT_RESULT:
  406. exception_str = "Floating-point exception (inexact result)";
  407. break;
  408. case STATUS_FLOAT_INVALID_OPERATION:
  409. exception_str = "Invalid floating-point operation";
  410. break;
  411. case STATUS_FLOAT_OVERFLOW:
  412. exception_str = "Floating-point overflow";
  413. break;
  414. case STATUS_FLOAT_STACK_CHECK:
  415. exception_str = "Floating-point stack check failed";
  416. break;
  417. case STATUS_FLOAT_UNDERFLOW:
  418. exception_str = "Floating-point underflow";
  419. break;
  420. #ifdef STATUS_FLOAT_MULTIPLE_FAULTS
  421. case STATUS_FLOAT_MULTIPLE_FAULTS:
  422. exception_str = "Floating-point exception (multiple faults)";
  423. break;
  424. #endif
  425. #ifdef STATUS_FLOAT_MULTIPLE_TRAPS
  426. case STATUS_FLOAT_MULTIPLE_TRAPS:
  427. exception_str = "Floating-point exception (multiple traps)";
  428. break;
  429. #endif
  430. case STATUS_INTEGER_DIVIDE_BY_ZERO:
  431. exception_str = "Integer divide-by-zero";
  432. break;
  433. case STATUS_INTEGER_OVERFLOW:
  434. exception_str = "Integer overflow";
  435. break;
  436. case STATUS_DATATYPE_MISALIGNMENT:
  437. exception_str = "Datatype misalignment";
  438. break;
  439. case STATUS_ACCESS_VIOLATION:
  440. exception_str = "Access violation";
  441. break;
  442. case STATUS_IN_PAGE_ERROR:
  443. exception_str = "In-page error";
  444. break;
  445. case STATUS_INVALID_HANDLE:
  446. exception_str = "Invalid handle";
  447. break;
  448. case STATUS_NONCONTINUABLE_EXCEPTION:
  449. exception_str = "Noncontinuable exception";
  450. break;
  451. case STATUS_INVALID_DISPOSITION:
  452. exception_str = "Invalid disposition";
  453. break;
  454. case STATUS_ARRAY_BOUNDS_EXCEEDED:
  455. exception_str = "Array bounds exceeded";
  456. break;
  457. case STATUS_STACK_OVERFLOW:
  458. exception_str = "Stack overflow";
  459. break;
  460. case STATUS_ILLEGAL_INSTRUCTION:
  461. exception_str = "Illegal instruction";
  462. break;
  463. case STATUS_PRIVILEGED_INSTRUCTION:
  464. exception_str = "Privileged instruction";
  465. break;
  466. case STATUS_NO_MEMORY:
  467. default:
  468. char buf[1024];
  469. _snprintf(buf, 1024, "Exit code 0x%x\n", this->ExitValue);
  470. exception_str.assign(buf);
  471. }
  472. #else
  473. switch (this->Signal) {
  474. #ifdef SIGSEGV
  475. case SIGSEGV:
  476. exception_str = "Segmentation fault";
  477. break;
  478. #endif
  479. #ifdef SIGBUS
  480. #if !defined(SIGSEGV) || SIGBUS != SIGSEGV
  481. case SIGBUS:
  482. exception_str = "Bus error";
  483. break;
  484. #endif
  485. #endif
  486. #ifdef SIGFPE
  487. case SIGFPE:
  488. exception_str = "Floating-point exception";
  489. break;
  490. #endif
  491. #ifdef SIGILL
  492. case SIGILL:
  493. exception_str = "Illegal instruction";
  494. break;
  495. #endif
  496. #ifdef SIGINT
  497. case SIGINT:
  498. exception_str = "User interrupt";
  499. break;
  500. #endif
  501. #ifdef SIGABRT
  502. case SIGABRT:
  503. exception_str = "Child aborted";
  504. break;
  505. #endif
  506. #ifdef SIGKILL
  507. case SIGKILL:
  508. exception_str = "Child killed";
  509. break;
  510. #endif
  511. #ifdef SIGTERM
  512. case SIGTERM:
  513. exception_str = "Child terminated";
  514. break;
  515. #endif
  516. #ifdef SIGHUP
  517. case SIGHUP:
  518. exception_str = "SIGHUP";
  519. break;
  520. #endif
  521. #ifdef SIGQUIT
  522. case SIGQUIT:
  523. exception_str = "SIGQUIT";
  524. break;
  525. #endif
  526. #ifdef SIGTRAP
  527. case SIGTRAP:
  528. exception_str = "SIGTRAP";
  529. break;
  530. #endif
  531. #ifdef SIGIOT
  532. #if !defined(SIGABRT) || SIGIOT != SIGABRT
  533. case SIGIOT:
  534. exception_str = "SIGIOT";
  535. break;
  536. #endif
  537. #endif
  538. #ifdef SIGUSR1
  539. case SIGUSR1:
  540. exception_str = "SIGUSR1";
  541. break;
  542. #endif
  543. #ifdef SIGUSR2
  544. case SIGUSR2:
  545. exception_str = "SIGUSR2";
  546. break;
  547. #endif
  548. #ifdef SIGPIPE
  549. case SIGPIPE:
  550. exception_str = "SIGPIPE";
  551. break;
  552. #endif
  553. #ifdef SIGALRM
  554. case SIGALRM:
  555. exception_str = "SIGALRM";
  556. break;
  557. #endif
  558. #ifdef SIGSTKFLT
  559. case SIGSTKFLT:
  560. exception_str = "SIGSTKFLT";
  561. break;
  562. #endif
  563. #ifdef SIGCHLD
  564. case SIGCHLD:
  565. exception_str = "SIGCHLD";
  566. break;
  567. #elif defined(SIGCLD)
  568. case SIGCLD:
  569. exception_str = "SIGCLD";
  570. break;
  571. #endif
  572. #ifdef SIGCONT
  573. case SIGCONT:
  574. exception_str = "SIGCONT";
  575. break;
  576. #endif
  577. #ifdef SIGSTOP
  578. case SIGSTOP:
  579. exception_str = "SIGSTOP";
  580. break;
  581. #endif
  582. #ifdef SIGTSTP
  583. case SIGTSTP:
  584. exception_str = "SIGTSTP";
  585. break;
  586. #endif
  587. #ifdef SIGTTIN
  588. case SIGTTIN:
  589. exception_str = "SIGTTIN";
  590. break;
  591. #endif
  592. #ifdef SIGTTOU
  593. case SIGTTOU:
  594. exception_str = "SIGTTOU";
  595. break;
  596. #endif
  597. #ifdef SIGURG
  598. case SIGURG:
  599. exception_str = "SIGURG";
  600. break;
  601. #endif
  602. #ifdef SIGXCPU
  603. case SIGXCPU:
  604. exception_str = "SIGXCPU";
  605. break;
  606. #endif
  607. #ifdef SIGXFSZ
  608. case SIGXFSZ:
  609. exception_str = "SIGXFSZ";
  610. break;
  611. #endif
  612. #ifdef SIGVTALRM
  613. case SIGVTALRM:
  614. exception_str = "SIGVTALRM";
  615. break;
  616. #endif
  617. #ifdef SIGPROF
  618. case SIGPROF:
  619. exception_str = "SIGPROF";
  620. break;
  621. #endif
  622. #ifdef SIGWINCH
  623. case SIGWINCH:
  624. exception_str = "SIGWINCH";
  625. break;
  626. #endif
  627. #ifdef SIGPOLL
  628. case SIGPOLL:
  629. exception_str = "SIGPOLL";
  630. break;
  631. #endif
  632. #ifdef SIGIO
  633. #if !defined(SIGPOLL) || SIGIO != SIGPOLL
  634. case SIGIO:
  635. exception_str = "SIGIO";
  636. break;
  637. #endif
  638. #endif
  639. #ifdef SIGPWR
  640. case SIGPWR:
  641. exception_str = "SIGPWR";
  642. break;
  643. #endif
  644. #ifdef SIGSYS
  645. case SIGSYS:
  646. exception_str = "SIGSYS";
  647. break;
  648. #endif
  649. #ifdef SIGUNUSED
  650. #if !defined(SIGSYS) || SIGUNUSED != SIGSYS
  651. case SIGUNUSED:
  652. exception_str = "SIGUNUSED";
  653. break;
  654. #endif
  655. #endif
  656. default:
  657. exception_str = "Signal ";
  658. exception_str += std::to_string(this->Signal);
  659. }
  660. #endif
  661. return exception_str;
  662. }