Skip to content

src: GetLoadedLibraries routine under NativeSymbolDebuggingContext - #24825

Closed
gireeshpunathil wants to merge 2 commits into
nodejs:masterfrom
gireeshpunathil:native_debug
Closed

gireeshpunathil wants to merge 2 commits into
nodejs:masterfrom
gireeshpunathil:native_debug

Conversation

@gireeshpunathil

@gireeshpunathil gireeshpunathil commented Dec 4, 2018 •

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Collaborator

@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
Comment thread src/debug_utils.h Resolved
Comment thread src/debug_utils.cc Resolved
Comment thread src/debug_utils.cc Resolved

@bnoordhuis bnoordhuis left a comment

Copy link
Copy Markdown
Member

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?

Comment thread src/debug_utils.cc Resolved
Comment thread src/debug_utils.cc Resolved
Comment thread src/debug_utils.cc Resolved
Comment thread src/debug_utils.cc Resolved
Comment thread src/debug_utils.cc Resolved
Comment thread src/debug_utils.cc Resolved
Comment thread src/debug_utils.cc Resolved
Comment thread src/debug_utils.cc Resolved
Comment thread src/debug_utils.cc Resolved
Comment thread src/debug_utils.cc Resolved
@gireeshpunathil

Copy link
Copy Markdown
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.

@bnoordhuis bnoordhuis left a comment

Copy link
Copy Markdown
Member

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.

Comment thread src/debug_utils.cc 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
Copy Markdown
Member Author

@Trott

Trott commented Dec 5, 2018

Copy link
Copy Markdown
Member

@gireeshpunathil

Copy link
Copy Markdown
Member Author

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

@danbev

danbev commented Dec 7, 2018 •

Copy link
Copy Markdown
Contributor

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

@bzoz

bzoz commented Dec 11, 2018

Copy link
Copy Markdown
Contributor

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

Comment thread src/debug_utils.cc Outdated
i++) {
WCHAR module_name[MAX_PATH];
// Obtain and report the full pathname for each module
if (GetModuleFileNameEx(process_handle,

Copy link
Copy Markdown
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?

ghost Dec 11, 2018

Copy link
Copy Markdown
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.

ghost Dec 11, 2018

Copy link
Copy Markdown
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…

ghost Dec 11, 2018

Copy link
Copy Markdown
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

ghost commented Dec 11, 2018 •

Copy link
Copy Markdown
Contributor

@gireeshpunathil

ghost commented Dec 11, 2018 •

Copy link
Copy Markdown
Member Author

@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

ghost commented Dec 11, 2018

Copy link
Copy Markdown
Member Author

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

@danbev

ghost commented Dec 14, 2018

Copy link
Copy Markdown
Contributor

Landed in 1c52dcc.

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