Skip to content

Commit df9ddb1

Browse files
committed
printf the hell out of it, ongoing
1 parent 534baa2 commit df9ddb1

File tree

4 files changed

+31
-7
lines changed

4 files changed

+31
-7
lines changed

src/gas/gas.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ int Gas::usage (bool is_error, std::string const message)
5858

5959
int Gas::run (int argc, char **argv)
6060
{
61+
std::cout << "Gas::run" << std::endl;
6162
determine_program_dir (argc, argv);
63+
std::cout << "Program dir determined" << std::endl;
6264

6365
auto lowercase_string = [](std::string& s) {
6466
std::transform (
@@ -69,12 +71,14 @@ int Gas::run (int argc, char **argv)
6971
);
7072
};
7173

74+
std::cout << "Determining arch name" << std::endl;
7275
std::string arch_name { generic_gas_name };
7376
const char *first_param = argc > 1 ? argv[1] : nullptr;
7477
if (first_param != nullptr && strlen (first_param) > sizeof(Constants::arch_hack_param) && strstr (first_param, Constants::arch_hack_param) == first_param) {
7578
arch_name = first_param + (sizeof(Constants::arch_hack_param) - 1);
7679
lowercase_string (arch_name);
7780
}
81+
std::cout << "arch_name == " << arch_name << std::endl;
7882
_program_name = arch_name;
7983

8084
std::unique_ptr<LlvmMcRunner> mc_runner;
@@ -112,12 +116,16 @@ int Gas::run (int argc, char **argv)
112116
return usage (true /* is_error */, message);
113117
}
114118

119+
std::cout << "About to parse arguments" << std::endl;
115120
auto&& [terminate, is_error] = parse_arguments (argc, argv, mc_runner);
121+
std::cout << "Arguments parsed; terminate == " << terminate << "; is_error == " << is_error << std::endl;
116122
if (terminate || is_error) {
117123
return is_error ? Constants::wrapper_general_error_code : 0;
118124
}
119125

126+
std::cout << "Getting path to llvm_mc" << std::endl;
120127
fs::path llvm_mc = program_dir () / Constants::llvm_mc_name;
128+
std::wcout << "llvm_mc == " << llvm_mc.c_str () << std::endl;
121129

122130
bool multiple_input_files = false;
123131
bool derive_output_file_name = false;
@@ -141,9 +149,11 @@ int Gas::run (int argc, char **argv)
141149
}
142150

143151
for (fs::path const& input : input_files) {
152+
std::wcout << "running llvm-mc for '" << input.c_str () << std::endl;
144153
mc_runner->set_input_file_path (input, derive_output_file_name);
145154
int ret = mc_runner->run (llvm_mc);
146155
if (ret != 0) {
156+
std::cout << " mc_runner failed with " << ret << std::endl;
147157
return ret;
148158
}
149159
}

src/gas/gas.hh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,4 @@ namespace xamarin::android::gas
217217
};
218218
}
219219

220-
extern xamarin::android::gas::Gas app;
221220
#endif // __GAS_HH

src/gas/gas.windows.cc

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
#include <windows.h>
33
#include <shlwapi.h>
44

5-
#include <algorithm>
65
#include <cstring>
76
#include <iostream>
8-
#include <string>
97

10-
#include "constants.hh"
118
#include "exceptions.hh"
129
#include "gas.hh"
1310

@@ -17,11 +14,27 @@ void Gas::get_command_line (int &argc, char **&argv)
1714
{
1815
LPWSTR *argvw = CommandLineToArgvW (GetCommandLineW (), &argc);
1916
argv = new char*[argc + 1];
20-
17+
memset (argv, 0, argc * sizeof(char*));
2118
for (int i = 0; i < argc; i++) {
19+
std::cout << "Argument " << i << std::endl;
2220
int size = WideCharToMultiByte (CP_UTF8, 0, argvw [i], -1, NULL, 0, NULL, NULL);
21+
std::cout << " size: " << size << std::endl;
22+
if (size <= 0) {
23+
// An error, but we ignore it and try to get the other arguments converted.
24+
argv[i] = _strdup ("");
25+
continue;
26+
}
27+
2328
argv [i] = new char [size];
29+
memset (argv [i], 0, size * sizeof(char));
30+
std::cout << " copying" << std::endl;
2431
WideCharToMultiByte (CP_UTF8, 0, argvw [i], -1, argv [i], size, NULL, NULL);
32+
std::cout << " copied" << std::endl;
33+
}
34+
35+
std::cout << "Processed arguments: " << std::endl;
36+
for (int i = 0; i < argc; i++) {
37+
std::cout << " [" << i << "] " << argv[i] << std::endl;
2538
}
2639

2740
argv [argc] = NULL;

src/gas/main.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// SPDX-License-Identifier: MIT
2+
#include <iostream>
23
#include "gas.hh"
34

4-
xamarin::android::gas::Gas app;
5-
65
int main (int argc, char **argv)
76
{
7+
xamarin::android::gas::Gas app;
8+
89
// On windows this obtains the utf8 version of args
910
app.get_command_line (argc, argv);
11+
std::cout << "Command line converted" << std::endl;
1012
// TODO: handle exceptions here (use backward for stacktrace perhaps?)
1113
return app.run (argc, argv);
1214
}

0 commit comments

Comments
 (0)