Add .gitignore file
[s390-tools.git] / vmconvert / convert.cpp
blob9c59af5efc52aad2d5f7b3626e838ca4b591cf9c
1 /*
2 * convert.cpp
3 * dump convert program required by both vmconvert and vmur
5 * Copyright IBM Corp. 2004, 2008.
7 * Author(s): Michael Holzheu
8 */
10 #include "vm_dump.h"
11 #include "lkcd_dump.h"
13 int
14 vm_convert(const char* inputFileName, const char* outputFileName,
15 const char* progName)
17 /* Do the conversion */
18 try {
19 switch(VMDump::getDumpType(inputFileName)){
20 case Dump::DT_VM64_BIG:
22 VMDump64Big* vmdump;
23 LKCDDump64* lkcddump;
25 vmdump = new VMDump64Big(inputFileName);
26 vmdump->printInfo();
27 lkcddump = new LKCDDump64(vmdump,
28 vmdump->getRegisterContent());
29 lkcddump->writeDump(outputFileName);
30 delete vmdump;
31 delete lkcddump;
32 break;
34 case Dump::DT_VM64:
36 VMDump64* vmdump;
37 LKCDDump64* lkcddump;
39 vmdump = new VMDump64(inputFileName);
40 vmdump->printInfo();
41 lkcddump = new LKCDDump64(vmdump,
42 vmdump->getRegisterContent());
43 lkcddump->writeDump(outputFileName);
44 delete vmdump;
45 delete lkcddump;
46 break;
48 case Dump::DT_VM32:
50 VMDump32* vmdump;
51 LKCDDump32* lkcddump;
53 vmdump = new VMDump32(inputFileName);
54 vmdump->printInfo();
55 lkcddump = new LKCDDump32(vmdump,
56 vmdump->getRegisterContent());
57 lkcddump->writeDump(outputFileName);
58 delete vmdump;
59 delete lkcddump;
60 break;
62 default:
63 throw DumpException("This is not a vmdump");
65 } catch (DumpException ex) {
66 printf("%s: %s\n", progName, ex.what());
67 fflush(stdout);
68 return 1;
70 return 0;