wasm-micro-runtime/test-tools/aot-analyzer/include/analyzer_error.h
GanJingSaiyan 07eae7c424
Add aot binary analysis tool aot-analyzer (#3379)
Add aot binary analysis tool aot-analyzer, samples:

```bash
# parse example.aot, and print basic information about AoT file
$ ./aot-analyzer -i example.aot

# parse example.aot, and print the size of text section of the AoT file
$ ./aot-analyzer -t example.aot

# compare these two files, and show the difference in function size between them
$ ./aot-analyzer -c example.aot example.wasm
```

Signed-off-by: ganjing <ganjing@xiaomi.com>
2024-05-08 16:31:39 +08:00

52 lines
932 B
C++

/*
* Copyright (C) 2024 Xiaomi Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef ANALYZER_ERROR_H_
#define ANALYZER_ERROR_H_
#include <string>
#include <string_view>
#include <vector>
#include "config.h"
namespace analyzer {
enum class ErrorLevel {
Warning,
Error,
};
static inline const char *
GetErrorLevelName(ErrorLevel error_level)
{
switch (error_level) {
case ErrorLevel::Warning:
return "warning";
case ErrorLevel::Error:
return "error";
}
ANALYZER_UNREACHABLE;
}
class Error
{
public:
Error()
: error_level_(ErrorLevel::Error)
{}
Error(ErrorLevel error_level, std::string_view message)
: error_level_(error_level)
, message_(message)
{}
ErrorLevel error_level_;
std::string message_;
};
using Errors = std::vector<Error>;
} // namespace analyzer
#endif