pseudo_inst.cc (11320:42ecb523c64a) | pseudo_inst.cc (11359:b0b976a1ceda) |
---|---|
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); | 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 | 595 596 // copy out target filename 597 char fn[100]; 598 std::string filename; 599 CopyStringOut(tc, fn, filename_addr, 100); 600 filename = std::string(fn); 601 |
602 OutputStream *out; |
|
603 if (offset == 0) { 604 // create a new file (truncate) | 603 if (offset == 0) { 604 // create a new file (truncate) |
605 os = simout.create(filename, true, true); | 605 out = 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.) | 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); | 610 out = simout.open(filename, ios::in | ios::out | ios::binary, true); |
612 } | 611 } |
612 613 ostream *os(out->stream()); |
|
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 | 614 if (!os) 615 panic("could not open file %s\n", filename); 616 617 // seek to offset 618 os->seekp(offset); 619 620 // copy out data and write to file 621 char *buf = new char[len]; 622 CopyOut(tc, buf, vaddr, len); 623 os->write(buf, len); 624 if (os->fail() || os->bad()) 625 panic("Error while doing writefile!\n"); 626 |
626 simout.close(os); | 627 simout.close(out); |
627 628 delete [] buf; 629 630 return len; 631} 632 633void 634debugbreak(ThreadContext *tc) --- 133 unchanged lines hidden --- | 628 629 delete [] buf; 630 631 return len; 632} 633 634void 635debugbreak(ThreadContext *tc) --- 133 unchanged lines hidden --- |