VirtualBox

source: vbox/trunk/src/VBox/Frontends/VBoxBugReport/VBoxBugReport.cpp@ 59815

Last change on this file since 59815 was 59815, checked in by vboxsync, 9 years ago

BugReportTool/Win(bugref:8169): fixed warnings

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 20.6 KB
Line 
1/* $Id: VBoxBugReport.cpp 59815 2016-02-25 13:55:42Z vboxsync $ */
2/** @file
3 * VBoxBugReport - VirtualBox command-line diagnostics tool, main file.
4 */
5
6/*
7 * Copyright (C) 2006-2016 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19#include <VBox/com/com.h>
20#include <VBox/com/string.h>
21#include <VBox/com/array.h>
22//#include <VBox/com/Guid.h>
23#include <VBox/com/ErrorInfo.h>
24#include <VBox/com/errorprint.h>
25#include <VBox/com/VirtualBox.h>
26
27#include <VBox/version.h>
28
29#include <iprt/buildconfig.h>
30#include <iprt/env.h>
31#include <iprt/file.h>
32#include <iprt/getopt.h>
33#include <iprt/initterm.h>
34#include <iprt/path.h>
35#include <iprt/process.h>
36#include <iprt/zip.h>
37#include <iprt/cpp/exception.h>
38
39#include <list>
40
41#include "VBoxBugReport.h"
42
43/* Implementation - Base */
44
45#ifndef RT_OS_WINDOWS
46/* @todo Replace with platform-specific implementations. */
47void createBugReportOsSpecific(BugReport* report, const char *pszHome)
48{
49}
50#endif /* !RT_OS_WINDOWS */
51
52
53/* Globals */
54
55static char *g_pszVBoxManage = NULL;
56
57static const RTGETOPTDEF g_aOptions[] =
58{
59 { "-all", 'A', RTGETOPT_REQ_NOTHING },
60 { "--all", 'A', RTGETOPT_REQ_NOTHING },
61 { "-output", 'o', RTGETOPT_REQ_STRING },
62 { "--output", 'o', RTGETOPT_REQ_STRING },
63 { "-text", 't', RTGETOPT_REQ_NOTHING },
64 { "--text", 't', RTGETOPT_REQ_NOTHING }
65};
66
67static const char g_szUsage[] =
68 "Usage: %s [-h|-?|--help] [-A|--all|<vmname>...] [-o <file>|--output=<file>]\n"
69 " Several VM names can be specified at once to be included into single report.\n"
70 " If none is given then no machines will be included. Specifying -A overrides\n"
71 " any VM names provided and included all registered machines.\n"
72 "Options:\n"
73 " -h, -help, --help Print usage information\n"
74 " -A, -all, --all Include all registered machines\n"
75 " -o, -output, --output Specifies the name of the output file\n"
76 " -t, -text, --text Produce a single text file instead of compressed TAR\n"
77 " -V, -version, --version Print version number and exit\n"
78 "\n";
79
80
81/*
82 * This class stores machine-specific file paths that are obtained via
83 * VirtualBox API. In case API is not functioning properly these paths
84 * will be deduced on the best effort basis.
85 */
86class MachineInfo
87{
88public:
89 MachineInfo(const char *name, const char *logFolder, const char *settingsFile);
90 ~MachineInfo();
91 const char *getName() const { return m_name; };
92 const char *getLogPath() const { return m_logpath; };
93 const char *getSettingsFile() const { return m_settings; };
94private:
95 char *m_name;
96 char *m_logpath;
97 char *m_settings;
98};
99
100MachineInfo::MachineInfo(const char *name, const char *logFolder, const char *settingsFile)
101{
102 m_name = RTStrDup(name);
103 m_logpath = RTStrDup(logFolder);
104 m_settings = RTStrDup(settingsFile);
105}
106
107MachineInfo::~MachineInfo()
108{
109 RTStrFree(m_logpath);
110 RTStrFree(m_name);
111 RTStrFree(m_settings);
112 m_logpath = m_name = m_settings = 0;
113}
114
115typedef std::list<MachineInfo*> MachineInfoList;
116
117
118/*
119 * An abstract class serving as the root of the bug report item tree.
120 */
121BugReportItem::BugReportItem(const char *pszTitle)
122{
123 m_pszTitle = RTStrDup(pszTitle);
124}
125
126BugReportItem::~BugReportItem()
127{
128 RTStrFree(m_pszTitle);
129}
130
131const char * BugReportItem::getTitle(void)
132{
133 return m_pszTitle;
134}
135
136
137BugReport::BugReport(const char *pszFileName)
138{
139 m_pszFileName = RTStrDup(pszFileName);
140}
141
142BugReport::~BugReport()
143{
144 for (unsigned i = 0; i < m_Items.size(); ++i)
145 {
146 delete m_Items[i];
147 }
148 RTStrFree(m_pszFileName);
149}
150
151int BugReport::getItemCount(void)
152{
153 return (int)m_Items.size();
154}
155
156void BugReport::addItem(BugReportItem* item)
157{
158 if (item)
159 m_Items.append(item);
160}
161
162void BugReport::process(void)
163{
164 for (unsigned i = 0; i < m_Items.size(); ++i)
165 {
166 BugReportItem *pItem = m_Items[i];
167 RTPrintf("%3u%% - collecting %s...\n", i * 100 / m_Items.size(), pItem->getTitle());
168 processItem(pItem);
169 }
170 RTPrintf("100%% - compressing...\n\n");
171}
172
173
174BugReportStream::BugReportStream(const char *pszTitle) : BugReportItem(pszTitle)
175{
176 handleRtError(RTPathTemp(m_szFileName, RTPATH_MAX),
177 "Failed to obtain path to temporary folder");
178 handleRtError(RTPathAppend(m_szFileName, RTPATH_MAX, "BugRepXXXXX.tmp"),
179 "Failed to append path");
180 handleRtError(RTFileCreateTemp(m_szFileName, 0600),
181 "Failed to create temporary file '%s'", m_szFileName);
182 handleRtError(RTStrmOpen(m_szFileName, "w", &m_Strm),
183 "Failed to open '%s'", m_szFileName);
184}
185
186BugReportStream::~BugReportStream()
187{
188 if (m_Strm)
189 RTStrmClose(m_Strm);
190 RTFileDelete(m_szFileName);
191}
192
193int BugReportStream::printf(const char *pszFmt, ...)
194{
195 va_list va;
196 va_start(va, pszFmt);
197 int cb = RTStrmPrintfV(m_Strm, pszFmt, va);
198 va_end(va);
199 return cb;
200}
201
202int BugReportStream::putStr(const char *pszString)
203{
204 return RTStrmPutStr(m_Strm, pszString);
205}
206
207PRTSTREAM BugReportStream::getStream(void)
208{
209 RTStrmClose(m_Strm);
210 handleRtError(RTStrmOpen(m_szFileName, "r", &m_Strm),
211 "Failed to open '%s'", m_szFileName);
212 return m_Strm;
213}
214
215
216/* Implementation - Generic */
217
218BugReportFile::BugReportFile(const char *pszPath, const char *pszShortName) : BugReportItem(pszShortName)
219{
220 m_Strm = 0;
221 m_pszPath = RTStrDup(pszPath);
222}
223
224BugReportFile::~BugReportFile()
225{
226 if (m_Strm)
227 RTStrmClose(m_Strm);
228 if (m_pszPath)
229 RTStrFree(m_pszPath);
230}
231
232PRTSTREAM BugReportFile::getStream(void)
233{
234 handleRtError(RTStrmOpen(m_pszPath, "rb", &m_Strm),
235 "Failed to open '%s'", m_pszPath);
236 return m_Strm;
237}
238
239
240BugReportCommand::BugReportCommand(const char *pszTitle, const char *pszExec, ...)
241 : BugReportItem(pszTitle), m_Strm(NULL)
242{
243 unsigned cArgs = 0;
244 m_papszArgs[cArgs++] = RTStrDup(pszExec);
245
246 const char *pszArg;
247 va_list va;
248 va_start(va, pszExec);
249 do
250 {
251 if (cArgs >= RT_ELEMENTS(m_papszArgs))
252 throw RTCError(com::Utf8StrFmt("Too many arguments (%u > %u)\n", cArgs+1, RT_ELEMENTS(m_papszArgs)));
253 pszArg = va_arg(va, const char *);
254 m_papszArgs[cArgs++] = pszArg ? RTStrDup(pszArg) : NULL;
255 } while (pszArg);
256 va_end(va);
257}
258
259BugReportCommand::~BugReportCommand()
260{
261 if (m_Strm)
262 RTStrmClose(m_Strm);
263 RTFileDelete(m_szFileName);
264 for (size_t i = 0; i < RT_ELEMENTS(m_papszArgs) && m_papszArgs[i]; ++i)
265 RTStrFree(m_papszArgs[i]);
266}
267
268PRTSTREAM BugReportCommand::getStream(void)
269{
270 handleRtError(RTPathTemp(m_szFileName, RTPATH_MAX),
271 "Failed to obtain path to temporary folder");
272 handleRtError(RTPathAppend(m_szFileName, RTPATH_MAX, "BugRepXXXXX.tmp"),
273 "Failed to append path");
274 handleRtError(RTFileCreateTemp(m_szFileName, 0600),
275 "Failed to create temporary file '%s'", m_szFileName);
276
277 RTHANDLE hStdOutErr;
278 hStdOutErr.enmType = RTHANDLETYPE_FILE;
279 handleRtError(RTFileOpen(&hStdOutErr.u.hFile, m_szFileName,
280 RTFILE_O_WRITE | RTFILE_O_CREATE_REPLACE | RTFILE_O_DENY_WRITE),
281 "Failed to open temporary file '%s'", m_szFileName);
282
283 RTPROCESS hProcess;
284 handleRtError(RTProcCreateEx(m_papszArgs[0], m_papszArgs, RTENV_DEFAULT, 0,
285 NULL, &hStdOutErr, &hStdOutErr,
286 NULL, NULL, &hProcess),
287 "Failed to create process '%s'", m_papszArgs[0]);
288 RTPROCSTATUS status;
289 handleRtError(RTProcWait(hProcess, RTPROCWAIT_FLAGS_BLOCK, &status),
290 "Process wait failed");
291 //if (status.enmReason == RTPROCEXITREASON_NORMAL) {}
292 RTFileClose(hStdOutErr.u.hFile);
293
294 handleRtError(RTStrmOpen(m_szFileName, "r", &m_Strm),
295 "Failed to open '%s'", m_szFileName);
296 return m_Strm;
297}
298
299
300BugReportText::BugReportText(const char *pszFileName) : BugReport(pszFileName)
301{
302 handleRtError(RTStrmOpen(pszFileName, "w", &m_StrmTxt),
303 "Failed to open '%s'", pszFileName);
304}
305
306BugReportText::~BugReportText()
307{
308 if (m_StrmTxt)
309 RTStrmClose(m_StrmTxt);
310}
311
312void BugReportText::processItem(BugReportItem* item)
313{
314 int cb = RTStrmPrintf(m_StrmTxt, "[ %s ] -------------------------------------------\n", item->getTitle());
315 if (!cb)
316 throw RTCError(com::Utf8StrFmt("Write failure (cb=%d)\n", cb));
317
318 PRTSTREAM strmIn = NULL;
319 try
320 {
321 strmIn = item->getStream();
322 }
323 catch (RTCError &e)
324 {
325 strmIn = NULL;
326 RTStrmPutStr(m_StrmTxt, e.what());
327 }
328
329 int rc = VINF_SUCCESS;
330
331 if (strmIn)
332 {
333 char buf[64*1024];
334 size_t cbRead, cbWritten;
335 cbRead = cbWritten = 0;
336 while (RT_SUCCESS(rc = RTStrmReadEx(strmIn, buf, sizeof(buf), &cbRead)) && cbRead)
337 {
338 rc = RTStrmWriteEx(m_StrmTxt, buf, cbRead, &cbWritten);
339 if (RT_FAILURE(rc) || cbRead != cbWritten)
340 throw RTCError(com::Utf8StrFmt("Write failure (rc=%d, cbRead=%lu, cbWritten=%lu)\n",
341 rc, cbRead, cbWritten));
342 }
343 }
344
345 handleRtError(RTStrmPutCh(m_StrmTxt, '\n'), "Write failure");
346}
347
348
349BugReportTarGzip::BugReportTarGzip(const char *pszFileName)
350 : BugReport(pszFileName), m_hTar(NIL_RTTAR), m_hTarFile(NIL_RTTARFILE)
351{
352 VfsIoStreamHandle hVfsOut;
353 handleRtError(RTVfsIoStrmOpenNormal(pszFileName, RTFILE_O_WRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE,
354 hVfsOut.getPtr()),
355 "Failed to create output file '%s'", pszFileName);
356 handleRtError(RTZipGzipCompressIoStream(hVfsOut.get(), 0, 6, m_hVfsGzip.getPtr()),
357 "Failed to create compressed stream for '%s'", pszFileName);
358
359 handleRtError(RTPathTemp(m_szTarName, RTPATH_MAX),
360 "Failed to obtain path to temporary folder");
361 handleRtError(RTPathAppend(m_szTarName, RTPATH_MAX, "BugRepXXXXX.tar"),
362 "Failed to append path");
363 handleRtError(RTFileCreateTemp(m_szTarName, 0600),
364 "Failed to create temporary file '%s'", m_szTarName);
365 handleRtError(RTFileDelete(m_szTarName),
366 "Failed to delete temporary file '%s'", m_szTarName);
367 handleRtError(RTTarOpen(&m_hTar, m_szTarName, RTFILE_O_CREATE | RTFILE_O_WRITE | RTFILE_O_DENY_ALL),
368 "Failed to create TAR file '%s'", m_szTarName);
369
370}
371
372BugReportTarGzip::~BugReportTarGzip()
373{
374 if (m_hTarFile != NIL_RTTARFILE)
375 RTTarFileClose(m_hTarFile);
376 if (m_hTar != NIL_RTTAR)
377 RTTarClose(m_hTar);
378}
379
380void BugReportTarGzip::processItem(BugReportItem* item)
381{
382 handleRtError(RTTarFileOpen(m_hTar, &m_hTarFile, item->getTitle(),
383 RTFILE_O_CREATE | RTFILE_O_WRITE | RTFILE_O_DENY_NONE),
384 "Failed to open '%s' in TAR", item->getTitle());
385
386 PRTSTREAM strmIn = NULL;
387 try
388 {
389 strmIn = item->getStream();
390 }
391 catch (RTCError &e)
392 {
393 strmIn = NULL;
394 handleRtError(RTTarFileWriteAt(m_hTarFile, 0, e.what(), RTStrNLen(e.what(), 1024), NULL),
395 "Failed to write %u bytes to TAR", RTStrNLen(e.what(), 1024));
396 }
397
398 int rc = VINF_SUCCESS;
399
400 if (strmIn)
401 {
402 char buf[64*1024];
403 size_t cbRead = 0;
404 for (uint64_t offset = 0;
405 RT_SUCCESS(rc = RTStrmReadEx(strmIn, buf, sizeof(buf), &cbRead)) && cbRead;
406 offset += cbRead)
407 {
408 handleRtError(RTTarFileWriteAt(m_hTarFile, offset, buf, cbRead, NULL),
409 "Failed to write %u bytes to TAR", cbRead);
410 }
411 }
412
413 if (m_hTarFile)
414 {
415 RTTarFileClose(m_hTarFile);
416 m_hTarFile = NIL_RTTARFILE;
417 }
418}
419
420void BugReportTarGzip::complete(void)
421{
422 if (m_hTarFile != NIL_RTTARFILE)
423 {
424 RTTarFileClose(m_hTarFile);
425 m_hTarFile = NIL_RTTARFILE;
426 }
427 if (m_hTar != NIL_RTTAR)
428 {
429 RTTarClose(m_hTar);
430 m_hTar = NIL_RTTAR;
431 }
432
433 VfsIoStreamHandle hVfsIn;
434 handleRtError(RTVfsIoStrmOpenNormal(m_szTarName, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE,
435 hVfsIn.getPtr()),
436 "Failed to open TAR file '%s'", m_szTarName);
437
438 int rc;
439 char buf[_64K];
440 size_t cbRead = 0;
441 while (RT_SUCCESS(rc = RTVfsIoStrmRead(hVfsIn.get(), buf, sizeof(buf), true, &cbRead)) && cbRead)
442 handleRtError(RTVfsIoStrmWrite(m_hVfsGzip.get(), buf, cbRead, true, NULL),
443 "Failed to write into compressed stream");
444 handleRtError(rc, "Failed to read from TAR stream");
445 handleRtError(RTVfsIoStrmFlush(m_hVfsGzip.get()), "Failed to flush output stream");
446 m_hVfsGzip.release();
447}
448
449
450/* Implementation - Main */
451
452void createBugReport(BugReport* report, const char *pszHome, MachineInfoList& machines)
453{
454 report->addItem(new BugReportFile(PathJoin(pszHome, "VBoxSVC.log"), "VBoxSVC.log"));
455 report->addItem(new BugReportFile(PathJoin(pszHome, "VBoxSVC.log.1"), "VBoxSVC.log.1"));
456 report->addItem(new BugReportFile(PathJoin(pszHome, "VirtualBox.xml"), "VirtualBox.xml"));
457 report->addItem(new BugReportCommand("HostUsbDevices", g_pszVBoxManage, "list", "usbhost", NULL));
458 report->addItem(new BugReportCommand("HostUsbFilters", g_pszVBoxManage, "list", "usbfilters", NULL));
459 for (MachineInfoList::iterator it = machines.begin(); it != machines.end(); ++it)
460 {
461 report->addItem(new BugReportFile(PathJoin((*it)->getLogPath(), "VBox.log"),
462 PathJoin((*it)->getName(), "VBox.log")));
463 report->addItem(new BugReportFile((*it)->getSettingsFile(),
464 PathJoin((*it)->getName(), RTPathFilename((*it)->getSettingsFile()))));
465 report->addItem(new BugReportCommand(PathJoin((*it)->getName(), "GuestProperties"),
466 g_pszVBoxManage, "guestproperty", "enumerate",
467 (*it)->getName(), NULL));
468 }
469
470 createBugReportOsSpecific(report, pszHome);
471}
472
473void addMachine(MachineInfoList& list, ComPtr<IMachine> machine)
474{
475 com::Bstr name, logFolder, settingsFile;
476 handleComError(machine->COMGETTER(Name)(name.asOutParam()),
477 "Failed to get VM name");
478 handleComError(machine->COMGETTER(LogFolder)(logFolder.asOutParam()),
479 "Failed to get VM log folder");
480 handleComError(machine->COMGETTER(SettingsFilePath)(settingsFile.asOutParam()),
481 "Failed to get VM settings file path");
482 list.push_back(new MachineInfo(com::Utf8Str(name).c_str(),
483 com::Utf8Str(logFolder).c_str(),
484 com::Utf8Str(settingsFile).c_str()));
485}
486
487
488static void printHeader(void)
489{
490 RTStrmPrintf(g_pStdErr, VBOX_PRODUCT " Bug Report Tool " VBOX_VERSION_STRING "\n"
491 "(C) " VBOX_C_YEAR " " VBOX_VENDOR "\n"
492 "All rights reserved.\n\n");
493}
494
495int main(int argc, char *argv[])
496{
497 /*
498 * Initialize the VBox runtime without loading
499 * the support driver.
500 */
501 RTR3InitExe(argc, &argv, 0);
502
503 bool fAllMachines = false;
504 bool fTextOutput = false;
505 const char *pszOutputFile = NULL;
506 std::list<const char *> nameList;
507 RTGETOPTUNION ValueUnion;
508 RTGETOPTSTATE GetState;
509 int ret = RTGetOptInit(&GetState, argc, argv,
510 g_aOptions, RT_ELEMENTS(g_aOptions),
511 1 /* First */, 0 /*fFlags*/);
512 if (RT_FAILURE(ret))
513 return ret;
514 int ch;
515 while ((ch = RTGetOpt(&GetState, &ValueUnion)))
516 {
517 switch(ch)
518 {
519 case 'h':
520 printHeader();
521 RTStrmPrintf(g_pStdErr, g_szUsage, argv[0]);
522 return 0;
523 case 'A':
524 fAllMachines = true;
525 break;
526 case 'o':
527 pszOutputFile = ValueUnion.psz;
528 break;
529 case 't':
530 fTextOutput = true;
531 break;
532 case 'V':
533 RTPrintf("%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr());
534 return 0;
535 case VINF_GETOPT_NOT_OPTION:
536 nameList.push_back(ValueUnion.psz);
537 break;
538 default:
539 return RTGetOptPrintError(ch, &ValueUnion);
540 }
541 }
542
543 printHeader();
544
545 HRESULT hr = S_OK;
546 char homeDir[RTPATH_MAX];
547 com::GetVBoxUserHomeDirectory(homeDir, sizeof(homeDir));
548
549 try
550 {
551 /* Figure out full path to VBoxManage */
552 char *pszVBoxBin = RTStrDup(argv[0]);
553 if (!pszVBoxBin)
554 throw RTCError("Out of memory\n");
555 RTPathStripFilename(pszVBoxBin);
556 g_pszVBoxManage = RTPathJoinA(pszVBoxBin, VBOXMANAGE);
557 if (!g_pszVBoxManage)
558 throw RTCError("Out of memory\n");
559 RTStrFree(pszVBoxBin);
560
561 handleComError(com::Initialize(), "Failed to initialize COM");
562
563 MachineInfoList list;
564
565 do
566 {
567 ComPtr<IVirtualBox> virtualBox;
568 ComPtr<ISession> session;
569
570 hr = virtualBox.createLocalObject(CLSID_VirtualBox);
571 if (FAILED(hr))
572 RTStrmPrintf(g_pStdErr, "WARNING: Failed to create the VirtualBox object (hr=0x%x)\n", hr);
573 else
574 {
575 hr = session.createInprocObject(CLSID_Session);
576 if (FAILED(hr))
577 RTStrmPrintf(g_pStdErr, "WARNING: Failed to create a session object (hr=0x%x)\n", hr);
578 }
579
580 if (SUCCEEDED(hr))
581 {
582 if (fAllMachines)
583 {
584 com::SafeIfaceArray<IMachine> machines;
585 hr = virtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
586 if (SUCCEEDED(hr))
587 {
588 for (size_t i = 0; i < machines.size(); ++i)
589 {
590 if (machines[i])
591 addMachine(list, machines[i]);
592 }
593 }
594 }
595 else
596 {
597 for ( std::list<const char *>::iterator it = nameList.begin(); it != nameList.end(); ++it)
598 {
599 ComPtr<IMachine> machine;
600 handleComError(virtualBox->FindMachine(com::Bstr(*it).raw(), machine.asOutParam()),
601 "No such machine '%s'", *it);
602 addMachine(list, machine);
603 }
604 }
605 }
606
607 }
608 while(0);
609
610 RTTIMESPEC TimeSpec;
611 RTTIME Time;
612 RTTimeExplode(&Time, RTTimeNow(&TimeSpec));
613 RTCStringFmt strOutFile("%04d-%02d-%02d-%02d-%02d-%02d-bugreport.%s",
614 Time.i32Year, Time.u8Month, Time.u8MonthDay,
615 Time.u8Hour, Time.u8Minute, Time.u8Second,
616 fTextOutput ? "txt" : "tgz");
617 RTCString strFallbackOutFile;
618 if (!pszOutputFile)
619 {
620 RTFILE tmp;
621 pszOutputFile = strOutFile.c_str();
622 int rc = RTFileOpen(&tmp, pszOutputFile, RTFILE_O_WRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE);
623 if (rc == VERR_ACCESS_DENIED)
624 {
625 char szUserHome[RTPATH_MAX];
626 handleRtError(RTPathUserHome(szUserHome, sizeof(szUserHome)), "Failed to obtain home directory");
627 strFallbackOutFile.printf("%s/%s", szUserHome, strOutFile.c_str());
628 pszOutputFile = strFallbackOutFile.c_str();
629 }
630 else if (RT_SUCCESS(rc))
631 {
632 RTFileClose(tmp);
633 RTFileDelete(pszOutputFile);
634 }
635 }
636 BugReport *pReport;
637 if (fTextOutput)
638 pReport = new BugReportText(pszOutputFile);
639 else
640 pReport = new BugReportTarGzip(pszOutputFile);
641 createBugReport(pReport, homeDir, list);
642 pReport->process();
643 pReport->complete();
644 RTPrintf("Report was written to '%s'\n", pszOutputFile);
645 delete pReport;
646 }
647 catch (RTCError &e)
648 {
649 RTStrmPrintf(g_pStdErr, "ERROR: %s\n", e.what());
650 }
651
652 com::Shutdown();
653
654 if (g_pszVBoxManage)
655 RTStrFree(g_pszVBoxManage);
656
657 return SUCCEEDED(hr) ? 0 : 1;
658}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette