Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: enhance C++ sprintf utility #32385

Closed
wants to merge 1 commit into from

Conversation

himself65
Copy link
Member

fix #32370

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Mar 20, 2020
@himself65 himself65 changed the title [WIP]src: enhance debug string format [WIP]src: enhance C++ sprintf utility Mar 20, 2020
@himself65 himself65 force-pushed the 20200320-debug branch 2 times, most recently from 43287bc to 658075e Compare March 20, 2020 08:32
@himself65 himself65 changed the title [WIP]src: enhance C++ sprintf utility src: enhance C++ sprintf utility Mar 20, 2020
@himself65 himself65 force-pushed the 20200320-debug branch 4 times, most recently from ddba87b to f363ae5 Compare March 20, 2020 09:23
template <unsigned BASE_BITS, typename T>
std::string ToBaseString(T&& value, bool upper = false) {
return ToStringHelper::BaseConvert<BASE_BITS>(std::forward<T>(value), upper);
}
Copy link
Member

Choose a reason for hiding this comment

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

I don’t think you need to do any templating for T, any value that’s passed to a function like this will be convertible to unsigned long long anyway.

Copy link
Member Author

@himself65 himself65 Mar 20, 2020

Choose a reason for hiding this comment

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

Of course ok, but we had code more template for other types if we do this.

btw, I inspired from this https://github.com/fmtlib/fmt/blob/5d32ccfc3130fdd122c344b37087ac7fd8c2b62e/include/fmt/format.h#L901-L913

src/debug_utils-inl.h Outdated Show resolved Hide resolved
src/debug_utils-inl.h Outdated Show resolved Hide resolved
Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Looks good, although it’s probably much simpler to go the %p route and just let the system snprintf do the work.

@himself65
Copy link
Member Author

Travis-ci fail because of timeout

https://travis-ci.com/github/nodejs/node/jobs/300545913#L3154-L3159

@gabrielschulhof
Copy link
Contributor

@himself65 I restarted the Travis job.

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Mar 25, 2020

gabrielschulhof pushed a commit that referenced this pull request Mar 26, 2020
PR-URL: #32385
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
@gabrielschulhof
Copy link
Contributor

Landed in dade90d.

@himself65 himself65 deleted the 20200320-debug branch March 26, 2020 02:48
MylesBorins pushed a commit that referenced this pull request Mar 26, 2020
PR-URL: #32385
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
@MylesBorins MylesBorins mentioned this pull request Mar 26, 2020
@addaleax addaleax mentioned this pull request Mar 29, 2020
2 tasks
@himself65 himself65 mentioned this pull request Mar 30, 2020
2 tasks
targos pushed a commit that referenced this pull request Apr 22, 2020
PR-URL: #32385
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

node::Debug does not understand %x
6 participants