mirror of
https://gitee.com/openharmony/third_party_spirv-tools
synced 2024-11-27 01:21:25 +00:00
Fix -p on disassembler.
spvTextToBinary fails if printing option is on *and* you send in a non-null pointer-to-spv_text.
This commit is contained in:
parent
1a3990233c
commit
a12c2240bc
@ -114,17 +114,25 @@ int main(int argc, char **argv) {
|
||||
error = spvExtInstTableGet(&extInstTable);
|
||||
spvCheck(error, fprintf(stderr, "error: Internal malfunction.\n"));
|
||||
|
||||
bool option_print = spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_PRINT, options);
|
||||
// If the printing option is turned on, then spvBinaryToText should
|
||||
// do the printing. In particular, colour printing on Windows is
|
||||
// controlled by modifying console objects synchronously while
|
||||
// outputting to the stream rather than by injecting escape codes
|
||||
// into the output stream.
|
||||
// If the printing option is off, then save the text in memory, so
|
||||
// it can be emitted later in this function.
|
||||
const bool printOptionOn =
|
||||
spvIsInBitfield(SPV_BINARY_TO_TEXT_OPTION_PRINT, options);
|
||||
spv_text text;
|
||||
spv_text *textOrNull = printOptionOn ? nullptr : &text;
|
||||
spv_diagnostic diagnostic = nullptr;
|
||||
error = spvBinaryToText(&binary, options, opcodeTable, operandTable,
|
||||
extInstTable,
|
||||
option_print ? NULL : &text,
|
||||
&diagnostic);
|
||||
extInstTable, textOrNull, &diagnostic);
|
||||
spvCheck(error, spvDiagnosticPrint(diagnostic);
|
||||
spvDiagnosticDestroy(diagnostic); return error);
|
||||
|
||||
if (!option_print) {
|
||||
// Output the result.
|
||||
if (!printOptionOn) {
|
||||
if (FILE *fp = fopen(outFile, "w")) {
|
||||
size_t written = fwrite(text->str, sizeof(char), (size_t)text->length, fp);
|
||||
if (text->length != written) {
|
||||
|
Loading…
Reference in New Issue
Block a user