-- X86 disassembler. -- Copyright (C) 2006 Tristan Gingold -- -- GHDL is free software; you can redistribute it and/or modify it under -- the terms of the GNU General Public License as published by the Free -- Software Foundation; either version 2, or (at your option) any later -- version. -- -- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY -- WARRANTY; without even the implied warranty of MERCHANTABILITY or -- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- for more details. -- -- You should have received a copy of the GNU General Public License -- along with GCC; see the file COPYING. If not, write to the Free -- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. with System.Address_To_Access_Conversions; package body Disa_X86 is type Byte is new Interfaces.Unsigned_8; type Bf_2 is mod 2 ** 2; type Bf_3 is mod 2 ** 3; type Byte_Vector is array (Natural) of Byte; package Bv_Addr2acc is new System.Address_To_Access_Conversions (Object => Byte_Vector); use Bv_Addr2acc; type Cstring_Acc is access constant String; type Index_Type is ( N_None, N_Push, N_Pop, N_Ret, N_Mov, N_Add, N_Or, N_Adc, N_Sbb, N_And, N_Sub, N_Xor, N_Cmp, N_Into, N_Jmp, N_Jcc, N_Setcc, N_Call, N_Int, N_Cdq, N_Imul, N_Mul, N_Leave, N_Test, N_Lea, N_O, N_No, N_B, N_AE, N_E, N_Ne, N_Be, N_A, N_S, N_Ns, N_P, N_Np, N_L, N_Ge, N_Le, N_G, N_Not, N_Neg, N_Cbw, N_Div, N_Idiv, N_Movsx, N_Movzx, N_Nop, N_Hlt, N_Inc, N_Dec, N_Rol, N_Ror, N_Rcl, N_Rcr, N_Shl, N_Shr, N_Sar, N_Fadd, N_Fmul, N_Fcom, N_Fcomp, N_Fsub, N_Fsubr, N_Fdiv, N_Fdivr, G_1, G_2, G_3, G_5 ); type Names_Type is array (Index_Type range <>) of Cstring_Acc; subtype S is String; Names : constant Names_Type := (N_None => new S'("none"), N_Push => new S'("push"), N_Pop => new S'("pop"), N_Ret => new S'("ret"), N_Mov => new S'("mov"), N_Add => new S'("add"), N_Or => new S'("or"), N_Adc => new S'("adc"), N_Sbb => new S'("sbb"), N_And => new S'("and"), N_Sub => new S'("sub"), N_Xor => new S'("xor"), N_Cmp => new S'("cmp"), N_Into => new S'("into"), N_Jmp => new S'("jmp"), N_Jcc => new S'("j"), N_Int => new S'("int"), N_Cdq => new S'("cdq"), N_Call => new S'("call"), N_Imul => new S'("imul"), N_Mul => new S'("mul"), N_Leave => new S'("leave"), N_Test => new S'("test"), N_Setcc => new S'("set"), N_Lea => new S'("lea"), N_O => new S'("o"), N_No => new S'("no"), N_B => new S'("b"), N_AE => new S'("ae"), N_E => new S'("e"), N_Ne => new S'("ne"), N_Be => new S'("be"), N_A => new S'("a"), N_S => new S'("s"), N_Ns => new S'("ns"), N_P => new S'("p"), N_Np => new S'("np"), N_L => new S'("l"), N_Ge => new S'("ge"), N_Le => new S'("le"), N_G => new S'("g"), N_Not => new S'("not"), N_Neg => new S'("neg"), N_Cbw => new S'("cbw"), N_Div => new S'("div"), N_Idiv => new S'("idiv"), N_Movsx => new S'("movsx"), N_Movzx => new S'("movzx"), N_Nop => new S'("nop"), N_Hlt => new S'("hlt"), N_Inc => new S'("inc"), N_Dec => new S'("dec"), N_Rol => new S'("rol"), N_Ror => new S'("ror"), N_Rcl => new S'("rcl"), N_Rcr => new S'("rcr"), N_Shl => new S'("shl"), N_Shr => new S'("shr"), N_Sar => new S'("sar"), N_Fadd => new S'("fadd"), N_Fmul => new S'("fmul"), N_Fcom => new S'("fcom"), N_Fcomp => new S'("fcomp"), N_Fsub => new S'("fsub"), N_Fsubr => new S'("fsubr"), N_Fdiv => new S'("fdiv"), N_Fdivr => new S'("fdivr") ); -- Format of an instruction. -- MODRM_SRC_8 : modrm byte follow, and modrm is source, witdh = 8bits -- MODRM_DST_8 : modrm byte follow, and modrm is dest, width = 8 bits. -- MODRM_SRC_W : modrm byte follow, and modrm is source, width = 16/32 bits -- MODRM_DST_W : modrm byte follow, and modrm is dest, width =16/32 bits. -- MODRM_IMM_W : modrm byte follow, with an opcode in the reg field, -- followed by an immediat, width = 16/32 bits. -- MODRM_IMM_8 : modrm byte follow, with an opcode in the reg field, -- followed by an immediat, width = 8 bits. -- IMM : the opcode is followed by an immediate value. -- PREFIX : the opcode is a prefix (1 byte). -- OPCODE : inherent addressing. -- OPCODE2 : a second byte specify the instruction. -- REG_IMP : register is in the 3 LSB of the opcode. -- REG_IMM_W : register is in the 3 LSB of the opcode, followed by an -- immediat, width = 16/32 bits. -- DISP_W : a wide displacement (16/32 bits). -- DISP_8 : short displacement (8 bits). -- INVALID : bad opcode. type Format_Type is (Modrm_Src, Modrm_Dst, Modrm_Imm, Modrm_Imm_S, Modrm, Modrm_Ax, Modrm_Imm8, Imm, Imm_S, Imm_8, Eax_Imm, Prefix, Opcode, Opcode2, Reg_Imp, Reg_
#!/usr/bin/env python
#
# Copyright 2009, Google Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""upload_gmock.py v0.1.0 -- uploads a Google Mock patch for review.
This simple wrapper passes all command line flags and
--cc=googlemock@googlegroups.com to upload.py.
USAGE: upload_gmock.py [options for upload.py]
"""
__author__ = 'wan@google.com (Zhanyong Wan)'
import os
import sys
CC_FLAG = '--cc='
GMOCK_GROUP = 'googlemock@googlegroups.com'
def main():
# Finds the path to upload.py, assuming it is in the same directory
# as this file.
my_dir = os.path.dirname(os.path.abspath(__file__))
upload_py_path = os.path.join(my_dir, 'upload.py')
# Adds Google Mock discussion group to the cc line if it's not there
# already.
upload_py_argv = [upload_py_path]
found_cc_flag = False
for arg in sys.argv[1:]:
if arg.startswith(CC_FLAG):
found_cc_flag = True
cc_line = arg[len(CC_FLAG):]
cc_list = [addr for addr in cc_line.split(',') if addr]
if GMOCK_GROUP not in cc_list:
cc_list.append(GMOCK_GROUP)
upload_py_argv.append(CC_FLAG + ','.join(cc_list))
else:
upload_py_argv.append(arg)
if not found_cc_flag:
upload_py_argv.append(CC_FLAG + GMOCK_GROUP)
# Invokes upload.py with the modified command line flags.
os.execv(upload_py_path, upload_py_argv)
if __name__ == '__main__':
main()