2 Aesalon, a tool to visualize a program's behaviour at run-time.
3 Copyright (C) 2010, Aesalon Development Team.
5 Aesalon is distributed under the terms of the GNU GPLv3. For more
6 licensing information, see the file LICENSE included with the distribution.
8 @file monitor/src/Coordinator.cpp
16 #include "Coordinator.h"
17 #include "config/ArgumentParser.h"
18 #include "config/Parser.h"
19 #include "common/Config.h"
20 #include "program/Launcher.h"
21 #include "module/Module.h"
22 #include "module/Loader.h"
23 #include "config/ConcreteVault.h"
24 #include "common/PathSanitizer.h"
25 #include "program/Conductor.h"
26 #include "analyzer/ExecutableAnalyzer.h"
30 Coordinator
*Coordinator::m_instance
= NULL
;
32 Coordinator::Coordinator(char **argv
) : m_argv(argv
) {
36 Coordinator::~Coordinator() {
40 void Coordinator::run() {
43 if(m_vault
->get("::list-attributes") == "true") {
44 std::cout
<< "Listing all configuration keys and values." << std::endl
;
45 std::cout
<< "Please note that many of these are auto-generated." << std::endl
;
46 std::cout
<< "================" << std::endl
;
47 std::vector
<Config::Vault::KeyPair
> list
;
48 m_vault
->match("*", list
);
49 for(std::vector
<Config::Vault::KeyPair
>::iterator i
= list
.begin(); i
!= list
.end(); ++i
) {
50 if(i
->first
[0] == ':' && i
->first
[1] == ':') continue;
52 std::cout
<< " * \"" << i
->first
<< "\" ==> \"" << i
->second
<< "\"\n";
55 else if(m_argv
[m_argcOffset
] == NULL
|| m_vault
->get("::help") == "true") {
60 Module::Loader moduleLoader
;
61 moduleLoader
.loadModules();
62 Program::SharedMemory sharedMemory
;
63 Program::Conductor
conductor(&sharedMemory
);
65 Program::Launcher
launcher(&m_argv
[m_argcOffset
]);
66 launcher
.forkTarget();
68 conductor
.run(moduleLoader
.moduleList());
72 void Coordinator::parseConfigs() {
73 Config::Parser parser
;
75 Config::ConcreteVault
*vault
= new Config::ConcreteVault();
77 parser
.parse(vault
, Common::PathSanitizer::sanitize(AesalonGlobalConfig
));
78 parser
.parse(vault
, Common::PathSanitizer::sanitize(AesalonUserConfig
));
79 parser
.parse(vault
, Common::PathSanitizer::sanitize(AesalonLocalConfig
));
81 Config::ArgumentParser argParser
;
82 m_argcOffset
= argParser
.parse(vault
, m_argv
);
87 void Coordinator::usage(bool displayHelp
) {
88 std::cout
<< "Aesalon version " << AesalonVersion
<< ". Copyright (C) 2010 Aesalon Development Team." << std::endl
;
89 std::cout
<< "Aesalon is released under the GNU General Public License, version 3." << std::endl
;
91 if(!displayHelp
) return;
92 std::cout
<< std::endl
;
93 std::cout
<< "Usage: " << m_argv
[0] << " [options] [--] executable [arguments]" << std::endl
;
94 std::cout
<< "Options:" << std::endl
;
95 std::cout
<< "\t--help\n\t\tDisplays this usage message." << std::endl
;
96 std::cout
<< "\t--version\n\t\tDisplays version information." << std::endl
;
97 std::cout
<< "\t--search <path>\n\t\tSearches <path> for modules." << std::endl
;
98 std::cout
<< "\t--use-module <module>\n\t\tPrepares <module> for loading." << std::endl
;
99 std::cout
<< "\t--set <attribute>[=value]\n\t\tSets a module attribute." << std::endl
;
100 std::cout
<< "\t--list-attributes\n\t\tLists all the available attributes." << std::endl
;
103 } // namespace Monitor