diff options
| author | babenko <[email protected]> | 2025-02-01 22:00:57 +0300 |
|---|---|---|
| committer | babenko <[email protected]> | 2025-02-01 22:16:41 +0300 |
| commit | a0eafa50f69b88e2c366b50bc97196686ec4d8e8 (patch) | |
| tree | f0e83688395774d6f0b940d346e815d248258ab0 /library/cpp/yt/string | |
| parent | 8cb823cc499768ee83daaba6fb81de16054071ad (diff) | |
Refactor and improve crash handler stderr dumps
1. Prevent concurrent crashes to interleave in stderr
2. Cleaner and more compact formatting of registers dump
3. Omit `OLDMASK` (nobody seems to know what is it for)
4. Don't print the top backtrace frame twice
5. Code cosmetics
commit_hash:f7a4c960b3400d6dfb0f8f60317aa524611d2fd0
Diffstat (limited to 'library/cpp/yt/string')
| -rw-r--r-- | library/cpp/yt/string/raw_formatter.h | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/library/cpp/yt/string/raw_formatter.h b/library/cpp/yt/string/raw_formatter.h index 6956330883b..23ea7f9af08 100644 --- a/library/cpp/yt/string/raw_formatter.h +++ b/library/cpp/yt/string/raw_formatter.h @@ -84,11 +84,12 @@ public: } } - //! Appends a single character and updates the internal cursor. - void AppendChar(char ch) + //! Appends a single character given number of times and updates the internal cursor. + void AppendChar(char ch, int count = 1) { - if (Cursor_ < End_) { + while (Cursor_ < End_ && count > 0) { *Cursor_++ = ch; + count--; } } @@ -97,6 +98,8 @@ public: { int digits = 0; + width = std::min(width, GetBytesRemaining()); + if (radix == 16) { // Optimize output of hex numbers. @@ -140,22 +143,6 @@ public: } } - //! Formats |number| as hexadecimal number and updates the internal cursor. - //! Padding will be added in front if needed. - void AppendNumberAsHexWithPadding(uintptr_t number, int width) - { - char* begin = Cursor_; - AppendString("0x"); - AppendNumber(number, 16); - // Move to right and add padding in front if needed. - if (Cursor_ < begin + width) { - auto delta = begin + width - Cursor_; - std::copy(begin, Cursor_, begin + delta); - std::fill(begin, begin + delta, ' '); - Cursor_ = begin + width; - } - } - //! Formats |guid| and updates the internal cursor. void AppendGuid(TGuid guid) { @@ -185,7 +172,6 @@ private: char* const Begin_; char* Cursor_; char* const End_; - }; template <size_t N> @@ -203,7 +189,6 @@ public: private: char Buffer_[N]; - }; //////////////////////////////////////////////////////////////////////////////// |
