location.cpp revision 0:a61af66fc99e
1102909Sjhb/* 2318Srgrimes * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved. 362114Speter * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4318Srgrimes * 561640Speter * This code is free software; you can redistribute it and/or modify it 6102909Sjhb * under the terms of the GNU General Public License version 2 only, as 761640Speter * published by the Free Software Foundation. 861640Speter * 999812Sbde * This code is distributed in the hope that it will be useful, but WITHOUT 1061640Speter * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1161640Speter * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1265639Salex * version 2 for more details (a copy is included in the LICENSE file that 1365639Salex * accompanied this code). 1465639Salex * 1593731Sjhb * You should have received a copy of the GNU General Public License version 1693731Sjhb * 2 along with this work; if not, write to the Free Software Foundation, 1793731Sjhb * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18102909Sjhb * 19318Srgrimes * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20102909Sjhb * CA 95054 USA or visit www.sun.com if you need additional information or 21102909Sjhb * have any questions. 22102909Sjhb * 23102909Sjhb */ 24102909Sjhb 25102909Sjhb#include "incls/_precompiled.incl" 26102909Sjhb#include "incls/_location.cpp.incl" 27102909Sjhb 28102909Sjhbvoid Location::print_on(outputStream* st) const { 29102909Sjhb if(type() == invalid && !legal_offset_in_bytes(offset() * BytesPerInt)) { 30128514Sbde // product of Location::invalid_loc() or Location::Location(). 31102909Sjhb switch (where()) { 32121595Snjl case on_stack: st->print("empty"); break; 33102909Sjhb case in_register: st->print("invalid"); break; 34102909Sjhb } 35102909Sjhb return; 36121595Snjl } 37102909Sjhb switch (where()) { 38318Srgrimes case on_stack: st->print("stack[%d]", stack_offset()); break; 393743Swollman case in_register: st->print("reg %s [%d]", reg()->name(), register_number()); break; 403743Swollman default: st->print("Wrong location where %d", where()); 413743Swollman } 423743Swollman switch (type()) { 43318Srgrimes case normal: break; 443743Swollman case oop: st->print(",oop"); break; 453743Swollman case int_in_long: st->print(",int"); break; 463743Swollman case lng: st->print(",long"); break; 47112498Sru case float_in_dbl: st->print(",float"); break; 48112498Sru case dbl: st->print(",double"); break; 49112498Sru case addr: st->print(",address"); break; 503743Swollman default: st->print("Wrong location type %d", type()); 51318Srgrimes } 523743Swollman} 533743Swollman 5445681Speter 5551898SbdeLocation::Location(DebugInfoReadStream* stream) { 5651898Sbde _value = (uint16_t) stream->read_int(); 5751898Sbde} 5851898Sbde 5951898Sbde 6051898Sbdevoid Location::write_on(DebugInfoWriteStream* stream) { 6151898Sbde stream->write_int(_value & 0x0000FFFF); 6245681Speter} 6345681Speter 6445681Speter 6545681Speter// Valid argument to Location::new_stk_loc()? 6645681Speterbool Location::legal_offset_in_bytes(int offset_in_bytes) { 6745681Speter if ((offset_in_bytes % BytesPerInt) != 0) return false; 6846840Speter return (offset_in_bytes / BytesPerInt) < (OFFSET_MASK >> OFFSET_SHIFT); 6946840Speter} 7046840Speter