summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/base/mutex-inl.h1
-rw-r--r--runtime/dex_instruction.cc10
-rw-r--r--runtime/elf_file.cc22
-rw-r--r--runtime/indirect_reference_table.h6
-rw-r--r--runtime/jdwp/jdwp_event.cc18
-rw-r--r--runtime/jdwp/jdwp_handler.cc21
-rw-r--r--runtime/jdwp/jdwp_main.cc14
-rw-r--r--runtime/jdwp/jdwp_request.cc4
-rw-r--r--runtime/mem_map.cc1
9 files changed, 57 insertions, 40 deletions
diff --git a/runtime/base/mutex-inl.h b/runtime/base/mutex-inl.h
index 30bf6238ca..a7e25cb907 100644
--- a/runtime/base/mutex-inl.h
+++ b/runtime/base/mutex-inl.h
@@ -17,7 +17,6 @@
#ifndef ART_RUNTIME_BASE_MUTEX_INL_H_
#define ART_RUNTIME_BASE_MUTEX_INL_H_
-#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
#include "mutex.h"
diff --git a/runtime/dex_instruction.cc b/runtime/dex_instruction.cc
index 6e8736ade0..8fccd6da3e 100644
--- a/runtime/dex_instruction.cc
+++ b/runtime/dex_instruction.cc
@@ -16,9 +16,12 @@
#include "dex_instruction-inl.h"
+#include <inttypes.h>
+
+#include <iomanip>
+
#include "dex_file-inl.h"
#include "utils.h"
-#include <iomanip>
namespace art {
@@ -403,7 +406,8 @@ std::string Instruction::DumpString(const DexFile* file) const {
os << StringPrintf("%s v%d, #int %+d // 0x%x", opcode, VRegA_21h(), value, value);
} else {
uint64_t value = static_cast<uint64_t>(VRegB_21h()) << 48;
- os << StringPrintf("%s v%d, #long %+lld // 0x%llx", opcode, VRegA_21h(), value, value);
+ os << StringPrintf("%s v%d, #long %+" PRId64 " // 0x%" PRIx64, opcode, VRegA_21h(),
+ value, value);
}
}
break;
@@ -611,7 +615,7 @@ std::string Instruction::DumpString(const DexFile* file) const {
}
break;
}
- case k51l: os << StringPrintf("%s v%d, #%+lld", opcode, VRegA_51l(), VRegB_51l()); break;
+ case k51l: os << StringPrintf("%s v%d, #%+" PRId64, opcode, VRegA_51l(), VRegB_51l()); break;
default: os << " unknown format (" << DumpHex(5) << ")"; break;
}
return os.str();
diff --git a/runtime/elf_file.cc b/runtime/elf_file.cc
index b3b24baf80..2f7c38a71f 100644
--- a/runtime/elf_file.cc
+++ b/runtime/elf_file.cc
@@ -64,15 +64,16 @@ bool ElfFile::Setup(File* file, bool writable, bool program_header_only, std::st
prot = PROT_READ;
flags = MAP_PRIVATE;
}
- int64_t file_length = file_->GetLength();
- if (file_length < 0) {
- errno = -file_length;
+ int64_t temp_file_length = file_->GetLength();
+ if (temp_file_length < 0) {
+ errno = -temp_file_length;
*error_msg = StringPrintf("Failed to get length of file: '%s' fd=%d: %s",
file_->GetPath().c_str(), file_->Fd(), strerror(errno));
return false;
}
+ size_t file_length = static_cast<size_t>(temp_file_length);
if (file_length < sizeof(llvm::ELF::Elf32_Ehdr)) {
- *error_msg = StringPrintf("File size of %lld bytes not large enough to contain ELF header of "
+ *error_msg = StringPrintf("File size of %zd bytes not large enough to contain ELF header of "
"%zd bytes: '%s'", file_length, sizeof(llvm::ELF::Elf32_Ehdr),
file_->GetPath().c_str());
return false;
@@ -89,7 +90,7 @@ bool ElfFile::Setup(File* file, bool writable, bool program_header_only, std::st
// then remap to cover program header
size_t program_header_size = header_->e_phoff + (header_->e_phentsize * header_->e_phnum);
if (file_length < program_header_size) {
- *error_msg = StringPrintf("File size of %lld bytes not large enough to contain ELF program "
+ *error_msg = StringPrintf("File size of %zd bytes not large enough to contain ELF program "
"header of %zd bytes: '%s'", file_length,
sizeof(llvm::ELF::Elf32_Ehdr), file_->GetPath().c_str());
return false;
@@ -632,7 +633,14 @@ bool ElfFile::Load(bool executable, std::string* error_msg) {
// non-zero, the segments require the specific address specified,
// which either was specified in the file because we already set
// base_address_ after the first zero segment).
- int64_t file_length = file_->GetLength();
+ int64_t temp_file_length = file_->GetLength();
+ if (temp_file_length < 0) {
+ errno = -temp_file_length;
+ *error_msg = StringPrintf("Failed to get length of file: '%s' fd=%d: %s",
+ file_->GetPath().c_str(), file_->Fd(), strerror(errno));
+ return false;
+ }
+ size_t file_length = static_cast<size_t>(temp_file_length);
if (program_header.p_vaddr == 0) {
std::string reservation_name("ElfFile reservation for ");
reservation_name += file_->GetPath();
@@ -666,7 +674,7 @@ bool ElfFile::Load(bool executable, std::string* error_msg) {
flags |= MAP_PRIVATE;
}
if (file_length < (program_header.p_offset + program_header.p_memsz)) {
- *error_msg = StringPrintf("File size of %lld bytes not large enough to contain ELF segment "
+ *error_msg = StringPrintf("File size of %zd bytes not large enough to contain ELF segment "
"%d of %d bytes: '%s'", file_length, i,
program_header.p_offset + program_header.p_memsz,
file_->GetPath().c_str());
diff --git a/runtime/indirect_reference_table.h b/runtime/indirect_reference_table.h
index 51b238c527..21e942efa5 100644
--- a/runtime/indirect_reference_table.h
+++ b/runtime/indirect_reference_table.h
@@ -326,7 +326,7 @@ class IndirectReferenceTable {
* Extract the table index from an indirect reference.
*/
static uint32_t ExtractIndex(IndirectRef iref) {
- uint32_t uref = (uint32_t) iref;
+ uintptr_t uref = reinterpret_cast<uintptr_t>(iref);
return (uref >> 2) & 0xffff;
}
@@ -337,8 +337,8 @@ class IndirectReferenceTable {
IndirectRef ToIndirectRef(const mirror::Object* /*o*/, uint32_t tableIndex) const {
DCHECK_LT(tableIndex, 65536U);
uint32_t serialChunk = slot_data_[tableIndex].serial;
- uint32_t uref = serialChunk << 20 | (tableIndex << 2) | kind_;
- return (IndirectRef) uref;
+ uintptr_t uref = serialChunk << 20 | (tableIndex << 2) | kind_;
+ return reinterpret_cast<IndirectRef>(uref);
}
/*
diff --git a/runtime/jdwp/jdwp_event.cc b/runtime/jdwp/jdwp_event.cc
index 4aa7f13254..e372c2672d 100644
--- a/runtime/jdwp/jdwp_event.cc
+++ b/runtime/jdwp/jdwp_event.cc
@@ -638,13 +638,14 @@ void JdwpState::SetWaitForEventThread(ObjectId threadId) {
* go to sleep indefinitely.
*/
while (event_thread_id_ != 0) {
- VLOG(jdwp) << StringPrintf("event in progress (%#llx), %#llx sleeping", event_thread_id_, threadId);
+ VLOG(jdwp) << StringPrintf("event in progress (%#" PRIx64 "), %#" PRIx64 " sleeping",
+ event_thread_id_, threadId);
waited = true;
event_thread_cond_.Wait(self);
}
if (waited || threadId != 0) {
- VLOG(jdwp) << StringPrintf("event token grabbed (%#llx)", threadId);
+ VLOG(jdwp) << StringPrintf("event token grabbed (%#" PRIx64 ")", threadId);
}
if (threadId != 0) {
event_thread_id_ = threadId;
@@ -664,7 +665,7 @@ void JdwpState::ClearWaitForEventThread() {
MutexLock mu(self, event_thread_lock_);
CHECK_NE(event_thread_id_, 0U);
- VLOG(jdwp) << StringPrintf("cleared event token (%#llx)", event_thread_id_);
+ VLOG(jdwp) << StringPrintf("cleared event token (%#" PRIx64 ")", event_thread_id_);
event_thread_id_ = 0;
@@ -820,7 +821,8 @@ bool JdwpState::PostLocationEvent(const JdwpLocation* pLoc, ObjectId thisPtr, in
if (match_count != 0) {
VLOG(jdwp) << "EVENT: " << match_list[0]->eventKind << "(" << match_count << " total) "
<< basket.className << "." << Dbg::GetMethodName(pLoc->method_id)
- << StringPrintf(" thread=%#llx dex_pc=%#llx)", basket.threadId, pLoc->dex_pc);
+ << StringPrintf(" thread=%#" PRIx64 " dex_pc=%#" PRIx64 ")",
+ basket.threadId, pLoc->dex_pc);
suspend_policy = scanSuspendPolicy(match_list, match_count);
VLOG(jdwp) << " suspend_policy=" << suspend_policy;
@@ -885,7 +887,7 @@ bool JdwpState::PostThreadChange(ObjectId threadId, bool start) {
if (match_count != 0) {
VLOG(jdwp) << "EVENT: " << match_list[0]->eventKind << "(" << match_count << " total) "
- << StringPrintf("thread=%#llx", basket.threadId) << ")";
+ << StringPrintf("thread=%#" PRIx64, basket.threadId) << ")";
suspend_policy = scanSuspendPolicy(match_list, match_count);
VLOG(jdwp) << " suspend_policy=" << suspend_policy;
@@ -968,8 +970,8 @@ bool JdwpState::PostException(const JdwpLocation* pThrowLoc,
FindMatchingEvents(EK_EXCEPTION, &basket, match_list, &match_count);
if (match_count != 0) {
VLOG(jdwp) << "EVENT: " << match_list[0]->eventKind << "(" << match_count << " total)"
- << StringPrintf(" thread=%#llx", basket.threadId)
- << StringPrintf(" exceptId=%#llx", exceptionId)
+ << StringPrintf(" thread=%#" PRIx64, basket.threadId)
+ << StringPrintf(" exceptId=%#" PRIx64, exceptionId)
<< " caught=" << basket.caught << ")"
<< " throw: " << *pThrowLoc;
if (pCatchLoc->class_id == 0) {
@@ -1036,7 +1038,7 @@ bool JdwpState::PostClassPrepare(JdwpTypeTag tag, RefTypeId refTypeId, const std
FindMatchingEvents(EK_CLASS_PREPARE, &basket, match_list, &match_count);
if (match_count != 0) {
VLOG(jdwp) << "EVENT: " << match_list[0]->eventKind << "(" << match_count << " total) "
- << StringPrintf("thread=%#llx", basket.threadId) << ") " << signature;
+ << StringPrintf("thread=%#" PRIx64, basket.threadId) << ") " << signature;
suspend_policy = scanSuspendPolicy(match_list, match_count);
VLOG(jdwp) << " suspend_policy=" << suspend_policy;
diff --git a/runtime/jdwp/jdwp_handler.cc b/runtime/jdwp/jdwp_handler.cc
index 523d89278a..6522a62300 100644
--- a/runtime/jdwp/jdwp_handler.cc
+++ b/runtime/jdwp/jdwp_handler.cc
@@ -48,7 +48,7 @@ std::string DescribeMethod(const MethodId& method_id) {
std::string DescribeRefTypeId(const RefTypeId& ref_type_id) {
std::string signature("unknown");
Dbg::GetSignature(ref_type_id, &signature);
- return StringPrintf("%#llx (%s)", ref_type_id, signature.c_str());
+ return StringPrintf("%#" PRIx64 " (%s)", ref_type_id, signature.c_str());
}
// Helper function: write a variable-width value into the output input buffer.
@@ -99,8 +99,9 @@ static JdwpError FinishInvoke(JdwpState*, Request& request, ExpandBuf* pReply,
int32_t arg_count = request.ReadSigned32("argument count");
- VLOG(jdwp) << StringPrintf(" --> thread_id=%#llx object_id=%#llx", thread_id, object_id);
- VLOG(jdwp) << StringPrintf(" class_id=%#llx method_id=%x %s.%s", class_id,
+ VLOG(jdwp) << StringPrintf(" --> thread_id=%#" PRIx64 " object_id=%#" PRIx64,
+ thread_id, object_id);
+ VLOG(jdwp) << StringPrintf(" class_id=%#" PRIx64 " method_id=%x %s.%s", class_id,
method_id, Dbg::GetClassName(class_id).c_str(),
Dbg::GetMethodName(method_id).c_str());
VLOG(jdwp) << StringPrintf(" %d args:", arg_count);
@@ -111,7 +112,8 @@ static JdwpError FinishInvoke(JdwpState*, Request& request, ExpandBuf* pReply,
argTypes[i] = request.ReadTag();
size_t width = Dbg::GetTagWidth(argTypes[i]);
argValues[i] = request.ReadValue(width);
- VLOG(jdwp) << " " << argTypes[i] << StringPrintf("(%zd): %#llx", width, argValues[i]);
+ VLOG(jdwp) << " " << argTypes[i] << StringPrintf("(%zd): %#" PRIx64, width,
+ argValues[i]);
}
uint32_t options = request.ReadUnsigned32("InvokeOptions bit flags");
@@ -143,7 +145,8 @@ static JdwpError FinishInvoke(JdwpState*, Request& request, ExpandBuf* pReply,
expandBufAdd1(pReply, JT_OBJECT);
expandBufAddObjectId(pReply, exceptObjId);
- VLOG(jdwp) << " --> returned " << resultTag << StringPrintf(" %#llx (except=%#llx)", resultValue, exceptObjId);
+ VLOG(jdwp) << " --> returned " << resultTag
+ << StringPrintf(" %#" PRIx64 " (except=%#" PRIx64 ")", resultValue, exceptObjId);
/* show detailed debug output */
if (resultTag == JT_STRING && exceptObjId == 0) {
@@ -526,7 +529,7 @@ static JdwpError RT_ClassObject(JdwpState*, Request& request, ExpandBuf* pReply)
if (status != ERR_NONE) {
return status;
}
- VLOG(jdwp) << StringPrintf(" --> ObjectId %#llx", class_object_id);
+ VLOG(jdwp) << StringPrintf(" --> ObjectId %#" PRIx64, class_object_id);
expandBufAddObjectId(pReply, class_object_id);
return ERR_NONE;
}
@@ -936,7 +939,7 @@ static JdwpError TR_Name(JdwpState*, Request& request, ExpandBuf* pReply)
if (error != ERR_NONE) {
return error;
}
- VLOG(jdwp) << StringPrintf(" Name of thread %#llx is \"%s\"", thread_id, name.c_str());
+ VLOG(jdwp) << StringPrintf(" Name of thread %#" PRIx64 " is \"%s\"", thread_id, name.c_str());
expandBufAddUtf8String(pReply, name);
return ERR_NONE;
@@ -1335,7 +1338,7 @@ static JdwpError ER_Set(JdwpState* state, Request& request, ExpandBuf* pReply)
ObjectId thread_id = request.ReadThreadId();
uint32_t size = request.ReadUnsigned32("step size");
uint32_t depth = request.ReadUnsigned32("step depth");
- VLOG(jdwp) << StringPrintf(" Step: thread=%#llx", thread_id)
+ VLOG(jdwp) << StringPrintf(" Step: thread=%#" PRIx64, thread_id)
<< " size=" << JdwpStepSize(size) << " depth=" << JdwpStepDepth(depth);
mod.step.threadId = thread_id;
@@ -1640,7 +1643,7 @@ static std::string DescribeCommand(Request& request) {
std::string result;
result += "REQUEST: ";
result += GetCommandName(request);
- result += StringPrintf(" (length=%d id=0x%06x)", request.GetLength(), request.GetId());
+ result += StringPrintf(" (length=%zu id=0x%06x)", request.GetLength(), request.GetId());
return result;
}
diff --git a/runtime/jdwp/jdwp_main.cc b/runtime/jdwp/jdwp_main.cc
index 127ebfa039..928f53dcd5 100644
--- a/runtime/jdwp/jdwp_main.cc
+++ b/runtime/jdwp/jdwp_main.cc
@@ -156,11 +156,11 @@ void JdwpState::SendBufferedRequest(uint32_t type, const std::vector<iovec>& iov
errno = 0;
ssize_t actual = netState->WriteBufferedPacket(iov);
if (static_cast<size_t>(actual) != expected) {
- PLOG(ERROR) << StringPrintf("Failed to send JDWP packet %c%c%c%c to debugger (%d of %d)",
- static_cast<uint8_t>(type >> 24),
- static_cast<uint8_t>(type >> 16),
- static_cast<uint8_t>(type >> 8),
- static_cast<uint8_t>(type),
+ PLOG(ERROR) << StringPrintf("Failed to send JDWP packet %c%c%c%c to debugger (%zd of %zu)",
+ static_cast<char>(type >> 24),
+ static_cast<char>(type >> 16),
+ static_cast<char>(type >> 8),
+ static_cast<char>(type),
actual, expected);
}
}
@@ -175,7 +175,7 @@ void JdwpState::SendRequest(ExpandBuf* pReq) {
errno = 0;
ssize_t actual = netState->WritePacket(pReq);
if (static_cast<size_t>(actual) != expandBufGetLength(pReq)) {
- PLOG(ERROR) << StringPrintf("Failed to send JDWP packet to debugger (%d of %d)",
+ PLOG(ERROR) << StringPrintf("Failed to send JDWP packet to debugger (%zd of %zu)",
actual, expandBufGetLength(pReq));
}
}
@@ -607,7 +607,7 @@ void JdwpState::ExitAfterReplying(int exit_status) {
std::ostream& operator<<(std::ostream& os, const JdwpLocation& rhs) {
os << "JdwpLocation["
<< Dbg::GetClassName(rhs.class_id) << "." << Dbg::GetMethodName(rhs.method_id)
- << "@" << StringPrintf("%#llx", rhs.dex_pc) << " " << rhs.type_tag << "]";
+ << "@" << StringPrintf("%#" PRIx64, rhs.dex_pc) << " " << rhs.type_tag << "]";
return os;
}
diff --git a/runtime/jdwp/jdwp_request.cc b/runtime/jdwp/jdwp_request.cc
index a9dd1e1790..7b15d6de11 100644
--- a/runtime/jdwp/jdwp_request.cc
+++ b/runtime/jdwp/jdwp_request.cc
@@ -16,6 +16,8 @@
#include "jdwp/jdwp.h"
+#include <inttypes.h>
+
#include "base/stringprintf.h"
#include "jdwp/jdwp_priv.h"
@@ -98,7 +100,7 @@ MethodId Request::ReadMethodId() {
ObjectId Request::ReadObjectId(const char* specific_kind) {
ObjectId id = Read8BE();
- VLOG(jdwp) << StringPrintf(" %s id %#llx", specific_kind, id);
+ VLOG(jdwp) << StringPrintf(" %s id %#" PRIx64, specific_kind, id);
return id;
}
diff --git a/runtime/mem_map.cc b/runtime/mem_map.cc
index b07cf5c53f..d3b823668e 100644
--- a/runtime/mem_map.cc
+++ b/runtime/mem_map.cc
@@ -16,7 +16,6 @@
#include "mem_map.h"
-#define __STDC_FORMAT_MACROS 1
#include <inttypes.h>
#include <backtrace/BacktraceMap.h>