[vm] Fix misc printf format bugs.

Bug: https://github.com/dart-lang/sdk/issues/35009
Change-Id: I6b509e1eb8e76e07f60a086c67358d65d2a1fae4
Reviewed-on: https://dart-review.googlesource.com/c/82460
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
Ryan Macnak 2018-11-01 16:37:22 +00:00 committed by commit-bot@chromium.org
parent 97940e77a4
commit a651838652
12 changed files with 24 additions and 20 deletions

View file

@ -198,7 +198,7 @@ void Disassembler::Disassemble(uword start,
}
if (!first) {
f.Print("]\n");
formatter->Print(str);
formatter->Print("%s", str);
}
}
int instruction_length;

View file

@ -33,7 +33,7 @@ class DisassemblyFormatter {
uword pc) = 0;
// Print a formatted message.
virtual void Print(const char* format, ...) = 0;
virtual void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3) = 0;
};
// Basic disassembly formatter that outputs the disassembled instruction

View file

@ -317,7 +317,7 @@ void KernelBytecodeDisassembler::Disassemble(uword start,
}
if (!first) {
f.Print("]\n");
formatter->Print(str);
formatter->Print("%s", str);
}
}
int instruction_length;

View file

@ -146,7 +146,7 @@ RawInstance* ConstantEvaluator::EvaluateExpression(intptr_t offset,
default:
H.ReportError(
script_, TokenPosition::kNoSource,
"Not a constant expression: unexpected kernel tag %s (%" Pd ")",
"Not a constant expression: unexpected kernel tag %s (%d)",
Reader::TagName(tag), tag);
}

View file

@ -154,17 +154,18 @@ class TranslationHelper {
Type& GetCanonicalType(const Class& klass);
void ReportError(const char* format, ...);
void ReportError(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
void ReportError(const Script& script,
const TokenPosition position,
const char* format,
...);
void ReportError(const Error& prev_error, const char* format, ...);
...) PRINTF_ATTRIBUTE(4, 5);
void ReportError(const Error& prev_error, const char* format, ...)
PRINTF_ATTRIBUTE(3, 4);
void ReportError(const Error& prev_error,
const Script& script,
const TokenPosition position,
const char* format,
...);
...) PRINTF_ATTRIBUTE(5, 6);
private:
// This will mangle [name_to_modify] if necessary and make the result a symbol

View file

@ -439,10 +439,10 @@ void Dwarf::WriteInliningNode(InliningNode* node,
Print("Ltemp%" Pd " = .Lfunc%" Pd " - .Ldebug_info\n", temp, function_index);
Print(".4byte Ltemp%" Pd "\n", temp);
// DW_AT_low_pc
Print(FORM_ADDR " .Lcode%" Pd " + %" Pd "\n", root_code_index,
Print(FORM_ADDR " .Lcode%" Pd " + %d\n", root_code_index,
node->start_pc_offset);
// DW_AT_high_pc
Print(FORM_ADDR " .Lcode%" Pd " + %" Pd "\n", root_code_index,
Print(FORM_ADDR " .Lcode%" Pd " + %d\n", root_code_index,
node->end_pc_offset);
// DW_AT_call_file
uleb128(file);
@ -596,7 +596,7 @@ void Dwarf::WriteLines() {
u1(0); // This is an extended opcode
u1(1 + sizeof(void*)); // that is 5 or 9 bytes long
u1(DW_LNE_set_address);
Print(FORM_ADDR " .Lcode%" Pd " + %" Pd "\n", i, current_pc_offset);
Print(FORM_ADDR " .Lcode%" Pd " + %d\n", i, current_pc_offset);
} else {
u1(DW_LNS_advance_pc);
Print(".uleb128 .Lcode%" Pd " - .Lcode%" Pd " + %" Pd "\n", i,

View file

@ -180,12 +180,12 @@ class Dwarf : public ZoneAllocated {
kInlinedFunction,
};
void Print(const char* format, ...);
void Print(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
void sleb128(intptr_t value) { Print(".sleb128 %" Pd "\n", value); }
void uleb128(uintptr_t value) { Print(".uleb128 %" Pd "\n", value); }
void u1(uint8_t value) { Print(".byte %" Pd "\n", value); }
void u2(uint16_t value) { Print(".2byte %" Pd "\n", value); }
void u4(uint32_t value) { Print(".4byte %" Pd "\n", value); }
void u1(uint8_t value) { Print(".byte %d\n", value); }
void u2(uint16_t value) { Print(".2byte %d\n", value); }
void u4(uint32_t value) { Print(".4byte %d\n", value); }
void WriteAbbreviations();
void WriteCompilationUnit();

View file

@ -83,7 +83,8 @@ class JSONStream : ValueObject {
bool parameters_are_dart_objects = false);
void SetupError();
void PrintError(intptr_t code, const char* details_format, ...);
void PrintError(intptr_t code, const char* details_format, ...)
PRINTF_ATTRIBUTE(3, 4);
void PostReply();

View file

@ -22,7 +22,7 @@ class Thread;
#define THR_VPrint(format, args) Log::Current()->VPrint(format, args)
typedef void (*LogPrinter)(const char* str, ...);
typedef void (*LogPrinter)(const char* str, ...) PRINTF_ATTRIBUTE(1, 2);
class Log {
public:

View file

@ -17,6 +17,8 @@
namespace dart {
static const char* test_output_ = NULL;
PRINTF_ATTRIBUTE(1, 2)
static void TestPrinter(const char* format, ...) {
// Measure.
va_list args;

View file

@ -2729,7 +2729,7 @@ static bool CompileExpression(Thread* thread, JSONStream* js) {
js->LookupParam("libraryUri"), js->LookupParam("klass"), is_static);
if (compilation_result.status != Dart_KernelCompilationStatus_Ok) {
js->PrintError(kExpressionCompilationError, compilation_result.error);
js->PrintError(kExpressionCompilationError, "%s", compilation_result.error);
free(compilation_result.error);
return true;
}
@ -3627,7 +3627,7 @@ static bool Resume(Thread* thread, JSONStream* js) {
const char* error = NULL;
if (!isolate->debugger()->SetResumeAction(step, frame_index, &error)) {
js->PrintError(kCannotResume, error);
js->PrintError(kCannotResume, "%s", error);
return true;
}
isolate->SetResumeRequest();

View file

@ -77,7 +77,7 @@ class TimelineAnalysis : public ValueObject {
void DiscoverThreads();
void FinalizeThreads();
void SetError(const char* format, ...);
void SetError(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
Zone* zone_;
Isolate* isolate_;