8204680: Disassembly does not display code strings in stubs
Reviewed-by: kvn
This commit is contained in:
parent
e9499fa513
commit
dd0ba10925
@ -337,6 +337,7 @@ public:
|
||||
|
||||
class CodeBuffer: public StackObj {
|
||||
friend class CodeSection;
|
||||
friend class StubCodeGenerator;
|
||||
|
||||
private:
|
||||
// CodeBuffers must be allocated on the stack except for a single
|
||||
|
@ -155,6 +155,7 @@ class decode_env {
|
||||
CodeStrings _strings;
|
||||
outputStream* _output;
|
||||
address _start, _end;
|
||||
ptrdiff_t _offset;
|
||||
|
||||
char _option_buf[512];
|
||||
char _print_raw;
|
||||
@ -191,7 +192,8 @@ class decode_env {
|
||||
void print_address(address value);
|
||||
|
||||
public:
|
||||
decode_env(CodeBlob* code, outputStream* output, CodeStrings c = CodeStrings());
|
||||
decode_env(CodeBlob* code, outputStream* output,
|
||||
CodeStrings c = CodeStrings(), ptrdiff_t offset = 0);
|
||||
|
||||
address decode_instructions(address start, address end);
|
||||
|
||||
@ -221,13 +223,15 @@ class decode_env {
|
||||
const char* options() { return _option_buf; }
|
||||
};
|
||||
|
||||
decode_env::decode_env(CodeBlob* code, outputStream* output, CodeStrings c) {
|
||||
decode_env::decode_env(CodeBlob* code, outputStream* output, CodeStrings c,
|
||||
ptrdiff_t offset) {
|
||||
memset(this, 0, sizeof(*this)); // Beware, this zeroes bits of fields.
|
||||
_output = output ? output : tty;
|
||||
_code = code;
|
||||
if (code != NULL && code->is_nmethod())
|
||||
_nm = (nmethod*) code;
|
||||
_strings.copy(c);
|
||||
_offset = offset;
|
||||
|
||||
// by default, output pc but not bytes:
|
||||
_print_pc = true;
|
||||
@ -354,7 +358,7 @@ void decode_env::print_insn_labels() {
|
||||
if (cb != NULL) {
|
||||
cb->print_block_comment(st, p);
|
||||
}
|
||||
_strings.print_block_comment(st, (intptr_t)(p - _start));
|
||||
_strings.print_block_comment(st, (intptr_t)(p - _start + _offset));
|
||||
if (_print_pc) {
|
||||
st->print(" " PTR_FORMAT ": ", p2i(p));
|
||||
}
|
||||
@ -507,10 +511,11 @@ void Disassembler::decode(CodeBlob* cb, outputStream* st) {
|
||||
env.decode_instructions(cb->code_begin(), cb->code_end());
|
||||
}
|
||||
|
||||
void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c) {
|
||||
void Disassembler::decode(address start, address end, outputStream* st, CodeStrings c,
|
||||
ptrdiff_t offset) {
|
||||
ttyLocker ttyl;
|
||||
if (!load_library()) return;
|
||||
decode_env env(CodeCache::find_blob_unsafe(start), st, c);
|
||||
decode_env env(CodeCache::find_blob_unsafe(start), st, c, offset);
|
||||
env.decode_instructions(start, end);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -75,7 +75,8 @@ class Disassembler {
|
||||
}
|
||||
static void decode(CodeBlob *cb, outputStream* st = NULL);
|
||||
static void decode(nmethod* nm, outputStream* st = NULL);
|
||||
static void decode(address begin, address end, outputStream* st = NULL, CodeStrings c = CodeStrings());
|
||||
static void decode(address begin, address end, outputStream* st = NULL,
|
||||
CodeStrings c = CodeStrings(), ptrdiff_t offset = 0);
|
||||
};
|
||||
|
||||
#endif // SHARE_VM_COMPILER_DISASSEMBLER_HPP
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -71,7 +71,7 @@ StubCodeGenerator::StubCodeGenerator(CodeBuffer* code, bool print_code) {
|
||||
}
|
||||
|
||||
StubCodeGenerator::~StubCodeGenerator() {
|
||||
if (_print_code) {
|
||||
if (PRODUCT_ONLY(_print_code) NOT_PRODUCT(true)) {
|
||||
CodeBuffer* cbuf = _masm->code();
|
||||
CodeBlob* blob = CodeCache::find_blob_unsafe(cbuf->insts()->start());
|
||||
if (blob != NULL) {
|
||||
@ -86,9 +86,19 @@ void StubCodeGenerator::stub_prolog(StubCodeDesc* cdesc) {
|
||||
|
||||
void StubCodeGenerator::stub_epilog(StubCodeDesc* cdesc) {
|
||||
if (_print_code) {
|
||||
CodeStrings cs;
|
||||
ptrdiff_t offset = 0;
|
||||
#ifndef PRODUCT
|
||||
// Find the code strings in the outer CodeBuffer.
|
||||
CodeBuffer *outer_cbuf = _masm->code_section()->outer();
|
||||
cs = outer_cbuf->strings();
|
||||
// The offset from the start of the outer CodeBuffer to the start
|
||||
// of this stub.
|
||||
offset = cdesc->begin() - outer_cbuf->insts()->start();
|
||||
#endif
|
||||
cdesc->print();
|
||||
tty->cr();
|
||||
Disassembler::decode(cdesc->begin(), cdesc->end());
|
||||
Disassembler::decode(cdesc->begin(), cdesc->end(), NULL, cs, offset);
|
||||
tty->cr();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user