1 /* 2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2018 SAP SE. All rights reserved. 4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5 * 6 * This code is free software; you can redistribute it and/or modify it 7 * under the terms of the GNU General Public License version 2 only, as 8 * published by the Free Software Foundation. 9 * 10 * This code is distributed in the hope that it will be useful, but WITHOUT 11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 13 * version 2 for more details (a copy is included in the LICENSE file that 14 * accompanied this code). 15 * 16 * You should have received a copy of the GNU General Public License version 17 * 2 along with this work; if not, write to the Free Software Foundation, 18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 19 * 20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * questions. 23 * 24 */ 25 26 27 /* 28 * This class provides tools to analyze the JVM's data structures carefully, 29 * especially for the purpose of creating detailed error reports 30 * (when VMError::is_error_reported()). 31 * Attention: They don't acquire locks! Use with care! 32 */ 33 34 class vmErrorHelper { 35 static bool is_oop_aligned(oop obj) { return is_object_aligned(obj); } 36 static bool is_ptr_aligned(intptr_t ptr) { return is_aligned(ptr, sizeof(void*)); } 37 38 static bool is_range_in_committed_java_heap(const void* from, const void* to); 39 static bool is_range_in_committed_c_heap(const void* from, const void* to); 40 41 static void* load_klass_raw(oop obj); 42 static void* load_oop_raw(oop obj, int offset); 43 44 public: 45 static oop decode_oop_raw(narrowOop narrow_oop) { 46 return (oop)(void*)( (uintptr_t)Universe::narrow_oop_base() + 47 ((uintptr_t)narrow_oop << Universe::narrow_oop_shift())); 48 } 49 static Klass* decode_klass_raw(narrowKlass narrow_klass) { 50 return (Klass*)(void*)( (uintptr_t)Universe::narrow_klass_base() + 51 ((uintptr_t)narrow_klass << Universe::narrow_klass_shift())); 52 } 53 54 static bool is_readable_range(const void* from, const void* to); 55 56 static bool is_valid_symbol(Symbol* s); 57 static bool is_valid_klass(Klass* k); 58 static bool is_valid_oop(oop obj); 59 static oop oop_or_null(address addr); 60 61 static void dump_code_blob(address addr, CodeBlob* cb, outputStream* st, bool verbose); 62 };