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: GetLoadedLibraries routine under NativeSymbolDebuggingContext #24825

Closed
wants to merge 2 commits into from

Conversation

gireeshpunathil
Copy link
Member

@gireeshpunathil gireeshpunathil commented Dec 4, 2018

Add a static function GetLoadedLibraries under NativeSymbolDebuggingContext abstraction that provides a list of shared objects - either the current process depended on or loaded.

Used in node-report, but given its independent existence and potential for re-use, placing it under NativeSymbolDebuggingContext API.

/cc @addaleax

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • 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 Dec 4, 2018
src/debug_utils.h Outdated Show resolved Hide resolved
src/debug_utils.cc Show resolved Hide resolved
src/debug_utils.cc Outdated Show resolved Hide resolved
Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

Gireesh, are you the original author or did you take this code (or parts of it) from somewhere else?

src/debug_utils.cc Outdated Show resolved Hide resolved
src/debug_utils.cc Outdated Show resolved Hide resolved
src/debug_utils.cc Outdated Show resolved Hide resolved
src/debug_utils.cc Outdated Show resolved Hide resolved
src/debug_utils.cc Outdated Show resolved Hide resolved
src/debug_utils.cc Show resolved Hide resolved
src/debug_utils.cc Outdated Show resolved Hide resolved
src/debug_utils.cc Outdated Show resolved Hide resolved
src/debug_utils.cc Outdated Show resolved Hide resolved
src/debug_utils.cc Outdated Show resolved Hide resolved
@gireeshpunathil
Copy link
Member Author

@bnoordhuis - I am not the original author of this; its concept come from https://github.com/nodejs/node-report then ran some churn through #22712 before it landed up here as a refactoring measure. #22712 's commit metadata lists all the original authors under Co-authored By: tag. Do you see anything more? thanks.

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

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

That's fine. I got a sense of déjà vu while reading the code but now I know where it's coming from.

src/debug_utils.cc Outdated Show resolved Hide resolved
Add a static function GetLoadedLibraries under
NativeSymbolDebuggingContext abstraction that provides a list of
shared objects - either the current process depended on or loaded.
@gireeshpunathil
Copy link
Member Author

@Trott
Copy link
Member

Trott commented Dec 5, 2018

@gireeshpunathil
Copy link
Member Author

Resume Build CI: https://ci.nodejs.org/job/node-test-commit/24016/

@danbev
Copy link
Contributor

danbev commented Dec 7, 2018

Re-run of failing node-test-commit-windows-fanned
Re-run of failing node-test-commit-windows-fanned

@bzoz
Copy link
Contributor

bzoz commented Dec 11, 2018

This does not compile on Windows:

06:07:23 src\debug_utils.cc(403): error C2664: 'DWORD GetModuleFileNameExA(HANDLE,HMODULE,LPSTR,DWORD)': cannot convert argument 3 from 'WCHAR [260]' to 'LPSTR' [c:\workspace\node-compile-windows\node_lib.vcxproj]
06:07:23   src\debug_utils.cc(406): note: Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
06:07:23 src\debug_utils.cc(407): error C2664: 'void std::vector<std::string,std::allocator<_Kty>>::push_back(_Ty &&)': cannot convert argument 1 from 'WCHAR [260]' to 'const std::string &' [c:\workspace\node-compile-windows\node_lib.vcxproj]
06:07:23           with
06:07:23           [
06:07:23               _Kty=std::string,
06:07:23               _Ty=std::string
06:07:23           ]
06:07:23   src\debug_utils.cc(407): note: Reason: cannot convert from 'WCHAR [260]' to 'const std::string'
06:07:23   src\debug_utils.cc(407): note: No constructor could take the source type, or constructor overload resolution was ambiguous

i++) {
WCHAR module_name[MAX_PATH];
// Obtain and report the full pathname for each module
if (GetModuleFileNameEx(process_handle,
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe GetModuleFileNameExW to fix the compilation error?

Copy link
Member Author

Choose a reason for hiding this comment

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

thanks @bzoz . I have 2 options;

  • use TCHAR instead of wide characters: I am able to build it successfully with that.
  • use GetModuleFileNameExW and deal with the next error of converting the result into std::string through MultiByteToWideChar.

On an assumption that the module names wont be made with wide characters, do you think the second option is an overkill, and we can just go with TCHAR instead? pls let me know.

Copy link
Member

Choose a reason for hiding this comment

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

an assumption that the module names wont be made with wide characters

I’d definitely prefer not to make such an assumption…

Copy link
Member Author

Choose a reason for hiding this comment

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

sure, thanks @addaleax for the assertion. Pushed a fix that makes no assumptions on the module name format.

Use WCHAR for module names
@bzoz
Copy link
Contributor

bzoz commented Dec 11, 2018

@gireeshpunathil
Copy link
Member Author

gireeshpunathil commented Dec 11, 2018

@bzoz - just wondering; does CI resume pick-up the latest commit? or build from where it failed?

from https://ci.nodejs.org/job/node-test-commit-windows-fanned/23184/parameters/ it looks like it re-runs from the old commit?

@gireeshpunathil
Copy link
Member Author

I was wrong; it picked up the latest commit. thanks @bzoz !

@danbev
Copy link
Contributor

danbev commented Dec 14, 2018

Landed in 1c52dcc.

@danbev danbev closed this Dec 14, 2018
danbev pushed a commit that referenced this pull request Dec 14, 2018
Add a static function GetLoadedLibraries under
NativeSymbolDebuggingContext abstraction that provides a list of
shared objects - either the current process depended on or loaded.

PR-URL: #24825
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
BethGriggs pushed a commit that referenced this pull request Dec 18, 2018
Add a static function GetLoadedLibraries under
NativeSymbolDebuggingContext abstraction that provides a list of
shared objects - either the current process depended on or loaded.

PR-URL: #24825
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
@BethGriggs BethGriggs mentioned this pull request Dec 18, 2018
gireeshpunathil added a commit to gireeshpunathil/node that referenced this pull request Dec 20, 2018
the dl_iterate_phdr and its associated data structure in Linux
are fully available in freebsd as well, so opening it up for
freebsd means just opening up the platform specific identifiers.

Refs: nodejs#24825

PR-URL: nodejs#25106
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
MylesBorins pushed a commit that referenced this pull request Dec 25, 2018
the dl_iterate_phdr and its associated data structure in Linux
are fully available in freebsd as well, so opening it up for
freebsd means just opening up the platform specific identifiers.

Refs: #24825

PR-URL: #25106
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
MylesBorins pushed a commit that referenced this pull request Dec 26, 2018
the dl_iterate_phdr and its associated data structure in Linux
are fully available in freebsd as well, so opening it up for
freebsd means just opening up the platform specific identifiers.

Refs: #24825

PR-URL: #25106
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
refack pushed a commit to refack/node that referenced this pull request Jan 14, 2019
Add a static function GetLoadedLibraries under
NativeSymbolDebuggingContext abstraction that provides a list of
shared objects - either the current process depended on or loaded.

PR-URL: nodejs#24825
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
refack pushed a commit to refack/node that referenced this pull request Jan 14, 2019
the dl_iterate_phdr and its associated data structure in Linux
are fully available in freebsd as well, so opening it up for
freebsd means just opening up the platform specific identifiers.

Refs: nodejs#24825

PR-URL: nodejs#25106
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
BethGriggs pushed a commit that referenced this pull request Feb 12, 2019
Add a static function GetLoadedLibraries under
NativeSymbolDebuggingContext abstraction that provides a list of
shared objects - either the current process depended on or loaded.

PR-URL: #24825
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
@BethGriggs BethGriggs mentioned this pull request Feb 12, 2019
BethGriggs pushed a commit that referenced this pull request Feb 20, 2019
Add a static function GetLoadedLibraries under
NativeSymbolDebuggingContext abstraction that provides a list of
shared objects - either the current process depended on or loaded.

PR-URL: #24825
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
rvagg pushed a commit that referenced this pull request Feb 28, 2019
Add a static function GetLoadedLibraries under
NativeSymbolDebuggingContext abstraction that provides a list of
shared objects - either the current process depended on or loaded.

PR-URL: #24825
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
BethGriggs pushed a commit that referenced this pull request Apr 17, 2019
the dl_iterate_phdr and its associated data structure in Linux
are fully available in freebsd as well, so opening it up for
freebsd means just opening up the platform specific identifiers.

Refs: #24825

PR-URL: #25106
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
BethGriggs pushed a commit that referenced this pull request Apr 28, 2019
the dl_iterate_phdr and its associated data structure in Linux
are fully available in freebsd as well, so opening it up for
freebsd means just opening up the platform specific identifiers.

Refs: #24825

PR-URL: #25106
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
BethGriggs pushed a commit that referenced this pull request May 10, 2019
the dl_iterate_phdr and its associated data structure in Linux
are fully available in freebsd as well, so opening it up for
freebsd means just opening up the platform specific identifiers.

Refs: #24825

PR-URL: #25106
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
MylesBorins pushed a commit that referenced this pull request May 16, 2019
the dl_iterate_phdr and its associated data structure in Linux
are fully available in freebsd as well, so opening it up for
freebsd means just opening up the platform specific identifiers.

Refs: #24825

PR-URL: #25106
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.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.

9 participants