Skip to content

Commit

Permalink
Remove buildid.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielcdh committed May 12, 2014
1 parent d8e31e1 commit 1a5c89a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 35 deletions.
4 changes: 1 addition & 3 deletions profile_creator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ bool ProfileCreator::CreateProfile(const string &input_profile_name,
bool ProfileCreator::ReadSample(const string &input_profile_name,
const string &profiler) {
if (profiler == "perf") {
string build_id;
// Sets the regular expression to filter samples for a given binary.
char *dup_name = strdup(binary_.c_str());
char *strip_ptr = strstr(dup_name, ".unstripped");
Expand All @@ -66,10 +65,9 @@ bool ProfileCreator::ReadSample(const string &input_profile_name,
CHECK(file_base_name) << "Cannot find basename for: " << binary_;

ElfReader reader(binary_);
build_id = reader.GetBuildId();

sample_reader_ = new PerfDataSampleReader(
input_profile_name, file_base_name, build_id);
input_profile_name, file_base_name);
free(dup_name);
} else if (profiler == "text") {
sample_reader_ = new TextSampleReaderWriter(input_profile_name);
Expand Down
28 changes: 1 addition & 27 deletions sample_reader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,6 @@ namespace {
bool MatchBinary(const string &name, const string &full_name) {
return full_name == basename(name.c_str());
}

// Returns the binary file name for a given build_id.
// TODO(dehao): move this function to quipper::PerfParser.
string GetFileNameFromBuildID(quipper::PerfParser *parser,
const string &build_id) {
map<string, string> name_buildid_map;
parser->GetFilenamesToBuildIDs(&name_buildid_map);

string focus_binary;
for (const auto &name_buildid : name_buildid_map) {
if (name_buildid.second == build_id) {
focus_binary = name_buildid.first;
break;
}
}
if (focus_binary == "") {
LOG(ERROR) << "Cannot find binary with buildid " << build_id;
}
return focus_binary;
}
} // namespace

namespace autofdo {
Expand Down Expand Up @@ -225,13 +205,7 @@ bool PerfDataSampleReader::Append(const string &profile_file) {
return false;
}

string focus_binary;
if (build_id_ != "") {
focus_binary = GetFileNameFromBuildID(&parser, build_id_);
} else {
focus_binary = focus_binary_re_;
LOG(ERROR) << "No buildid found in binary";
}
string focus_binary = focus_binary_re_;

// If we can find build_id from binary, and the exact build_id was found
// in the profile, then we use focus_binary to match samples. Otherwise,
Expand Down
7 changes: 2 additions & 5 deletions sample_reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,12 @@ class TextSampleReaderWriter : public FileSampleReader {
class PerfDataSampleReader : public FileSampleReader {
public:
explicit PerfDataSampleReader(const string &profile_file,
const string &re,
const string &build_id) :
FileSampleReader(profile_file), focus_binary_re_(re),
build_id_(build_id) { }
const string &re) :
FileSampleReader(profile_file), focus_binary_re_(re) { }
virtual bool Append(const string &profile_file);

private:
const string focus_binary_re_;
const string build_id_;

DISALLOW_COPY_AND_ASSIGN(PerfDataSampleReader);
};
Expand Down

1 comment on commit 1a5c89a

@dnovillo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Please sign in to comment.