Deleted Added
sdiff udiff text old ( 11320:42ecb523c64a ) new ( 11359:b0b976a1ceda )
full compact
1/*
2 * Copyright (c) 2010-2012, 2015 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 578 unchanged lines hidden (view full) ---

587}
588
589uint64_t
590writefile(ThreadContext *tc, Addr vaddr, uint64_t len, uint64_t offset,
591 Addr filename_addr)
592{
593 DPRINTF(PseudoInst, "PseudoInst::writefile(0x%x, 0x%x, 0x%x, 0x%x)\n",
594 vaddr, len, offset, filename_addr);
595 ostream *os;
596
597 // copy out target filename
598 char fn[100];
599 std::string filename;
600 CopyStringOut(tc, fn, filename_addr, 100);
601 filename = std::string(fn);
602
603 if (offset == 0) {
604 // create a new file (truncate)
605 os = simout.create(filename, true, true);
606 } else {
607 // do not truncate file if offset is non-zero
608 // (ios::in flag is required as well to keep the existing data
609 // intact, otherwise existing data will be zeroed out.)
610 os = simout.openFile(simout.directory() + filename,
611 ios::in | ios::out | ios::binary, true);
612 }
613 if (!os)
614 panic("could not open file %s\n", filename);
615
616 // seek to offset
617 os->seekp(offset);
618
619 // copy out data and write to file
620 char *buf = new char[len];
621 CopyOut(tc, buf, vaddr, len);
622 os->write(buf, len);
623 if (os->fail() || os->bad())
624 panic("Error while doing writefile!\n");
625
626 simout.close(os);
627
628 delete [] buf;
629
630 return len;
631}
632
633void
634debugbreak(ThreadContext *tc)

--- 133 unchanged lines hidden ---