protected CoreFile(ThreadManager manager, ProcessStart start) : base(manager, start) { info = Inferior.GetTargetMemoryInfo(manager.AddressDomain); bfd = (Bfd)NativeLanguage.OperatingSystem.LoadExecutable( info, start.TargetApplication, true); core_file = start.CoreFile; core_bfd = bfd.OpenCoreFile(core_file); #if FIXME string crash_program = core_bfd.CrashProgram; string[] crash_program_args = crash_program.Split(' '); if (crash_program_args [0] != application) { throw new TargetException( TargetError.CannotStartTarget, "Core file (generated from {0}) doesn't match executable {1}.", crash_program, application); } bool ok; try { DateTime core_date = Directory.GetLastWriteTime(core_file); DateTime app_date = Directory.GetLastWriteTime(application); ok = app_date < core_date; } catch { ok = false; } if (!ok) { throw new TargetException( TargetError.CannotStartTarget, "Executable {0} is more recent than core file {1}.", application, core_file); } #endif read_note_section(); main_thread = (CoreFileThread)threads [0]; TargetMemoryAccess target_access = ((CoreFileThread)threads [0]).TargetAccess; // bfd.UpdateSharedLibraryInfo (null, target_access); TargetAddress mdb_debug_info = bfd.GetSectionAddress(".mdb_debug_info"); if (!mdb_debug_info.IsNull) { mdb_debug_info = main_thread.ReadAddress(mdb_debug_info); debugger_info = MonoDebuggerInfo.Create(target_access, mdb_debug_info); read_thread_table(); CreateMonoLanguage(debugger_info); mono_language.InitializeCoreFile(target_access); mono_language.Update(target_access); } }
protected X86_Opcodes(Process process) { this.process = process; target_info = Inferior.GetTargetMemoryInfo (AddressDomain.Global); if (!Inferior.IsRunningOnWindows) disassembler = new BfdDisassembler (null, Is64BitMode); }
internal TargetReader(byte[] data, TargetMemoryInfo info) { if ((info == null) || (data == null)) throw new ArgumentNullException (); this.reader = new TargetBinaryReader (data, info); this.info = info; this.data = data; }
protected X86_Opcodes(Process process) { this.process = process; target_info = Inferior.GetTargetMemoryInfo(AddressDomain.Global); if (!Inferior.IsRunningOnWindows) { disassembler = new BfdDisassembler(null, Is64BitMode); } }
internal TargetReader(byte[] data, TargetMemoryInfo info) { if ((info == null) || (data == null)) { throw new ArgumentNullException(); } this.reader = new TargetBinaryReader(data, info); this.info = info; this.data = data; }
protected CoreFile(ThreadManager manager, ProcessStart start) : base(manager, start) { info = Inferior.GetTargetMemoryInfo (manager.AddressDomain); bfd = (Bfd) NativeLanguage.OperatingSystem.LoadExecutable ( info, start.TargetApplication, true); core_file = start.CoreFile; core_bfd = bfd.OpenCoreFile (core_file); #if FIXME string crash_program = core_bfd.CrashProgram; string[] crash_program_args = crash_program.Split (' '); if (crash_program_args [0] != application) throw new TargetException ( TargetError.CannotStartTarget, "Core file (generated from {0}) doesn't match executable {1}.", crash_program, application); bool ok; try { DateTime core_date = Directory.GetLastWriteTime (core_file); DateTime app_date = Directory.GetLastWriteTime (application); ok = app_date < core_date; } catch { ok = false; } if (!ok) throw new TargetException ( TargetError.CannotStartTarget, "Executable {0} is more recent than core file {1}.", application, core_file); #endif read_note_section (); main_thread = (CoreFileThread) threads [0]; TargetMemoryAccess target_access = ((CoreFileThread) threads [0]).TargetAccess; // bfd.UpdateSharedLibraryInfo (null, target_access); TargetAddress mdb_debug_info = bfd.GetSectionAddress (".mdb_debug_info"); if (!mdb_debug_info.IsNull) { mdb_debug_info = main_thread.ReadAddress (mdb_debug_info); debugger_info = MonoDebuggerInfo.Create (target_access, mdb_debug_info); read_thread_table (); CreateMonoLanguage (debugger_info); mono_language.InitializeCoreFile (target_access); mono_language.Update (target_access); } }
public override NativeExecutableReader LoadExecutable(TargetMemoryInfo memory, string filename, bool load_native_symtabs) { check_disposed(); Bfd bfd = (Bfd)bfd_hash [filename]; if (bfd != null) { return(bfd); } bfd = new Bfd(this, memory, filename, TargetAddress.Null, true); bfd_hash.Add(filename, bfd); main_bfd = bfd; return(bfd); }
void read_dynamic_info(Inferior inferior) { if (has_dynlink_info) { if (!dyld_all_image_infos.IsNull) { do_update_shlib_info(inferior); } return; } TargetMemoryInfo info = Inferior.GetTargetMemoryInfo(AddressDomain.Global); Bfd dyld_image = new Bfd(this, info, "/usr/lib/dyld", TargetAddress.Null, true); dyld_all_image_infos = dyld_image.LookupSymbol("dyld_all_image_infos"); if (dyld_all_image_infos.IsNull) { return; } int size = 2 * inferior.TargetLongIntegerSize + 2 * inferior.TargetAddressSize; TargetReader reader = new TargetReader(inferior.ReadMemory(dyld_all_image_infos, size)); reader.ReadLongInteger(); // version reader.ReadLongInteger(); // infoArrayCount reader.ReadAddress(); // infoArray TargetAddress dyld_image_notifier = reader.ReadAddress(); has_dynlink_info = true; Instruction insn = inferior.Architecture.ReadInstruction(inferior, dyld_image_notifier); if ((insn == null) || !insn.CanInterpretInstruction) { throw new InternalError("Unknown dynlink breakpoint: {0}", dyld_image_notifier); } dynlink_breakpoint = new DynlinkBreakpoint(this, insn); dynlink_breakpoint.Insert(inferior); do_update_shlib_info(inferior); check_loaded_library(inferior, main_bfd); }
public Bfd(OperatingSystemBackend os, TargetMemoryInfo info, string filename, TargetAddress base_address, bool is_loaded) { this.os = os; this.info = info; this.filename = filename; this.base_address = base_address; this.is_loaded = is_loaded; this.symfile = new BfdSymbolFile(this); bfd = bfd_glue_openr(filename, null); if (bfd == IntPtr.Zero) { throw new SymbolTableException("Can't read symbol file: {0}", filename); } if (bfd_glue_check_format_archive(bfd)) { IntPtr archive = bfd; bfd = IntPtr.Zero; while (true) { bfd = bfd_glue_openr_next_archived_file(archive, bfd); if (bfd == IntPtr.Zero) { throw new SymbolTableException("Can't read symbol file: {0}", filename); } if (bfd_glue_check_format_object(bfd)) { /* * At this point, just check for mach-o-le (OS X X86 binary). * When we want to support other architctures in fat binarys, * we need to somehow get the correct target string for the * process, and chech against that. */ if (bfd_glue_get_target_name(bfd) == "mach-o-le") { break; } } } } if (bfd_glue_check_format_object(bfd)) { is_coredump = false; } else if (bfd_glue_check_format_core(bfd)) { is_coredump = true; } else { throw new SymbolTableException("Not an object file: {0}", filename); } target = bfd_glue_get_target_name(bfd); if ((target == "elf32-i386") || (target == "elf64-x86-64")) { if (!is_coredump) { Section text = GetSectionByName(".text", false); Section bss = GetSectionByName(".bss", false); if ((text != null) && (bss != null)) { if (!base_address.IsNull) { start_address = new TargetAddress( info.AddressDomain, base_address.Address + text.vma); } else { start_address = new TargetAddress( info.AddressDomain, text.vma); } if (!base_address.IsNull) { end_address = new TargetAddress( info.AddressDomain, base_address.Address + bss.vma + bss.size); } else { end_address = new TargetAddress( info.AddressDomain, bss.vma + bss.size); } } } read_bfd_symbols(); if (DwarfReader.IsSupported(this)) { has_debugging_info = true; } Section plt_section = GetSectionByName(".plt", false); Section got_section = GetSectionByName(".got", false); if ((plt_section != null) && (got_section != null)) { plt_start = new TargetAddress( info.AddressDomain, base_address.Address + plt_section.vma); plt_end = plt_start + plt_section.size; got_start = new TargetAddress( info.AddressDomain, base_address.Address + got_section.vma); has_got = true; } } else if (target == "mach-o-le") { if (!is_coredump) { read_sections(); long start = 0xffffffff; long end = 0; foreach (Section section in sections) { long relocated = base_address.Address + section.vma; if (relocated < start) { start = relocated; } if (relocated + section.size > end) { end = relocated + section.size; } } start_address = new TargetAddress(info.AddressDomain, start); end_address = new TargetAddress(info.AddressDomain, end); } read_bfd_symbols(); if (DwarfReader.IsSupported(this)) { has_debugging_info = true; } has_got = false; } else { throw new SymbolTableException( "Symbol file {0} has unknown target architecture {1}", filename, target); } long entry_point_addr = bfd_glue_get_start_address(bfd); entry_point = entry_point_addr != 0 ? new TargetAddress(info.AddressDomain, entry_point_addr) : TargetAddress.Null; module = os.Process.Session.GetModule(filename); if (module == null) { module = os.Process.Session.CreateModule(filename, symfile); OnModuleChanged(); } else { module.LoadModule(symfile); } os.Process.SymbolTableManager.AddSymbolFile(symfile); }
public abstract NativeExecutableReader LoadExecutable(TargetMemoryInfo memory, string filename, bool load_native_symtabs);
public override NativeExecutableReader LoadExecutable(TargetMemoryInfo memory, string filename, bool load_native_symtabs) { throw new NotImplementedException(); }
public DieMember(DwarfBinaryReader reader, CompilationUnit comp_unit, AbbrevEntry abbrev) : base(reader, comp_unit, abbrev) { this.target_info = reader.TargetMemoryInfo; }
public DwarfReader(Bfd bfd, Module module) { this.bfd = bfd; this.module = module; this.filename = bfd.FileName; this.target_info = bfd.TargetMemoryInfo; debug_info_reader = create_reader (".debug_info", false); DwarfBinaryReader reader = DebugInfoReader; reader.ReadInitialLength (out is64bit); int version = reader.ReadInt16 (); if (version < 2) throw new DwarfException ( bfd, "Wrong DWARF version: {0}", version); reader.ReadOffset (); address_size = reader.ReadByte (); if ((address_size != 4) && (address_size != 8)) throw new DwarfException ( bfd, "Unknown address size: {0}", address_size); debug_abbrev_reader = create_reader (".debug_abbrev", false); debug_line_reader = create_reader (".debug_line", false); debug_aranges_reader = create_reader (".debug_aranges", true); debug_pubnames_reader = create_reader (".debug_pubnames", true); debug_pubtypes_reader = create_reader (".debug_pubtypes", true); debug_str_reader = create_reader (".debug_str", true); debug_loc_reader = create_reader (".debug_loc", false); debug_ranges_reader = create_reader (".debug_ranges", true); compile_unit_hash = Hashtable.Synchronized (new Hashtable ()); method_source_hash = Hashtable.Synchronized (new Hashtable ()); method_hash = Hashtable.Synchronized (new Hashtable ()); source_file_hash = Hashtable.Synchronized (new Hashtable ()); if (bfd.IsLoaded) { aranges = ArrayList.Synchronized (read_aranges ()); symtab = new DwarfSymbolTable (this, aranges); pubnames = read_pubnames (); // pubtypes = read_pubtypes (); } long offset = 0; while (offset < reader.Size) { CompileUnitBlock block = new CompileUnitBlock (this, offset); compile_unit_hash.Add (offset, block); offset += block.length; } }
internal StackFrame(TargetMemoryInfo info, ServerStackFrame frame) { this.address = new TargetAddress (info.AddressDomain, frame.Address); this.stack = new TargetAddress (info.AddressDomain, frame.StackPointer); this.frame = new TargetAddress (info.AddressDomain, frame.FrameAddress); }
protected void SetupInferior() { IntPtr data = IntPtr.Zero; try { check_error (mono_debugger_server_get_signal_info ( server_handle, out data)); signal_info = (SignalInfo) Marshal.PtrToStructure ( data, typeof (SignalInfo)); has_signals = true; } finally { g_free (data); } target_info = GetTargetMemoryInfo (address_domain); try { string cwd; string[] cmdline_args; string application = GetApplication (out cwd, out cmdline_args); exe = process.OperatingSystem.LoadExecutable ( target_info, application, start.LoadNativeSymbolTable); } catch (Exception e) { if (error_handler != null) error_handler (this, String.Format ( "Can't read symbol file {0}", start.TargetApplication), e); else Console.WriteLine ("Can't read symbol file {0}: {1}", start.TargetApplication, e); return; } arch = process.Architecture; }