~itachi-san/telegram-desktop/breakpad

« back to all changes in this revision

Viewing changes to src/common/windows/pdb_source_line_writer.h

  • Committer: Ivan Penkov
  • Author(s): Greg Thompson
  • Date: 2024-07-12 18:37:06 UTC
  • Revision ID: git-v1:7f3ccb77337bc9d35b252fcddc4f6a983f80dd6b
[Windows] PDBSourceLineWriter improvements

COM calls that return a BSTR via an out param pass ownership of the
string's underlying memory to the caller. It is the caller's
responsibility to free the memory via SysFreeString. Be sure to use
CComBSTR in all such cases, so that this happens upon destruction of the
CComBSTR. This CL fixes three BSTR memory leaks.

The inline_origins_ member maps an inline origin's name to a unique
numerical identifier. Simplify the container by mapping a name only to
an id rather than a name to a struct holding the name and id.

These origins are printed ordered by id. Rather than using a std::set to
create a container sorted by id, leverage the fact that ids are ints
that are assigned sequentially to create the reverse mapping in a
std::vector. This greatly reduces heap usage, and reduces complexity to
O(N).

Combined, these changes reduce commit charge by 26% and runtime by 10%
when processing chrome.dll for a 32-bit win-dcheck build.

Change-Id: Ib8d6540c74622500989f1dc06f705d6846be303f
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/5682242
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
  bool UsesGUID(bool *uses_guid);
104
104
 
105
105
 private:
106
 
  // InlineOrigin represents INLINE_ORIGIN record in a symbol file. It's an
107
 
  // inlined function.
108
 
  struct InlineOrigin {
109
 
    // The unique id for an InlineOrigin.
110
 
    int id;
111
 
    // The name of the inlined function.
112
 
    wstring name;
113
 
  };
114
 
 
115
106
  // Line represents LINE record in a symbol file. It represents a source code
116
107
  // line.
117
108
  struct Line {
196
187
    map<DWORD, Line> line_map_;
197
188
  };
198
189
 
 
190
  // Returns the unique id for the inline origin with the same name as the given
 
191
  // callsite, creating a new id if needed.
 
192
  int GetCallsiteInlineOriginId(CComPtr<IDiaSymbol>& callsite);
 
193
 
199
194
  // Construct Line from IDiaLineNumber. The output Line is stored at line.
200
195
  // Return true on success.
201
196
  bool GetLine(IDiaLineNumber* dia_line, Line* line) const;
337
332
  // This maps unique filenames to file IDs.
338
333
  unordered_map<wstring, DWORD> unique_files_;
339
334
 
340
 
  // The INLINE_ORIGINS records. The key is the function name.
341
 
  std::map<wstring, InlineOrigin> inline_origins_;
 
335
  // The INLINE_ORIGINS records; inline origin name -> unique id.
 
336
  std::map<wstring, int> inline_origins_;
342
337
 
343
338
  // This is used for calculating post-transform symbol addresses and lengths.
344
339
  ImageMap image_map_;