forked from qt-creator/qt-creator
Debugger: Support setting substitute path by regexp
This is useful when there are multiple build machines with different path, and the user would like to match anything up to some known directory to his local project (variable support will also be useful - will try to add that later). Syntax: (/home/.*)/KnownSubdir -> /home/my/project Capture group will be replaced by the value. In this example the substitute path will be (in case a source string found such as /home/SomeUser/SomeProject/KnownSubdir/foo.cpp): /home/SomeUser/SomeProject -> /home/my/project Change-Id: I19d03c9388161d8456a86676086dcb06dc3d7370 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
63da3cb9e0
commit
f0e2708d3e
@@ -101,33 +101,23 @@ static void parseProgramHeader(const uchar *s, ElfProgramHeader *sh, const ElfDa
|
||||
sh->memsz = getWord(s, context);
|
||||
}
|
||||
|
||||
class ElfMapper
|
||||
ElfMapper::ElfMapper(const ElfReader *reader) : file(reader->m_binary) {}
|
||||
|
||||
bool ElfMapper::map()
|
||||
{
|
||||
public:
|
||||
ElfMapper(const ElfReader *reader) : file(reader->m_binary) {}
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
|
||||
bool map()
|
||||
{
|
||||
if (!file.open(QIODevice::ReadOnly))
|
||||
return false;
|
||||
|
||||
fdlen = file.size();
|
||||
ustart = file.map(0, fdlen);
|
||||
if (ustart == 0) {
|
||||
// Try reading the data into memory instead.
|
||||
raw = file.readAll();
|
||||
start = raw.constData();
|
||||
fdlen = raw.size();
|
||||
}
|
||||
return true;
|
||||
fdlen = file.size();
|
||||
ustart = file.map(0, fdlen);
|
||||
if (ustart == 0) {
|
||||
// Try reading the data into memory instead.
|
||||
raw = file.readAll();
|
||||
start = raw.constData();
|
||||
fdlen = raw.size();
|
||||
}
|
||||
|
||||
public:
|
||||
QFile file;
|
||||
QByteArray raw;
|
||||
union { const char *start; const uchar *ustart; };
|
||||
quint64 fdlen;
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
ElfReader::ElfReader(const QString &binary)
|
||||
: m_binary(binary)
|
||||
@@ -298,19 +288,22 @@ ElfReader::Result ElfReader::readIt()
|
||||
return Ok;
|
||||
}
|
||||
|
||||
QByteArray ElfReader::readSection(const QByteArray &name)
|
||||
QSharedPointer<ElfMapper> ElfReader::readSection(const QByteArray &name)
|
||||
{
|
||||
QSharedPointer<ElfMapper> mapper;
|
||||
readIt();
|
||||
int i = m_elfData.indexOf(name);
|
||||
if (i == -1)
|
||||
return QByteArray();
|
||||
return mapper;
|
||||
|
||||
ElfMapper mapper(this);
|
||||
if (!mapper.map())
|
||||
return QByteArray();
|
||||
mapper.reset(new ElfMapper(this));
|
||||
if (!mapper->map())
|
||||
return mapper;
|
||||
|
||||
const ElfSectionHeader §ion = m_elfData.sectionHeaders.at(i);
|
||||
return QByteArray(mapper.start + section.offset, section.size);
|
||||
mapper->start += section.offset;
|
||||
mapper->fdlen = section.size;
|
||||
return mapper;
|
||||
}
|
||||
|
||||
static QByteArray cutout(const char *s)
|
||||
|
||||
Reference in New Issue
Block a user