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

proccontrol: fix process attachment without an exe #147

Merged
merged 2 commits into from Aug 9, 2016

Conversation

cuviper
Copy link
Contributor

@cuviper cuviper commented Aug 9, 2016

This fixes two cases where the low-level process was assumed to have a valid executable path, but it may not if a process was attached without ever specifying the exe.

  • In computeAddrWidth we can rewrite the test to work with both big- and little-endian auxv.
  • In Codegen, we can get the executable path from the libraries() pool instead.

Fixes #146

In linux_process::computeAddrWidth(), it's trying to guess the address
size without disk access, but commit c8d7481 started opening the exe to
figure out its endianness.  This is especially a problem if a process
was attached without specifying its executable.

We can modify the auxv scan to look at *both* little-endian and big-
endian words.  If either are all zero, we know this is a 64-bit process.
We could even report which endian it is from this, although we still
wouldn't know that for 32-bit processes.
Commit c8d7481 made `Codegen::generate` start opening the executable to
determine the ABI version of the process.  However, the llproc exe isn't
always set, if the process was attached without specifying it.  We can
instead get the right path from `proc_->libraries().getExecutable()`.
@cuviper
Copy link
Contributor Author

cuviper commented Aug 9, 2016

cc @mcfadden8 -- please double-check that this still accomplishes what you needed for PPC64LE.

@mcfadden8
Copy link
Contributor

These changes appear to be right for PPC64LE. I'll download the branch and give the fix a try on the PPC64LE we have here.

@mcfadden8
Copy link
Contributor

mcfadden8 commented Aug 9, 2016

I am having difficulty compiling the latest version of the testsuite on PPC64LE. I am seeing the following compilation error:

$ make
[  0%] Built target testB_static
[  0%] Built target testB
[  0%] Built target testA_static
[  0%] Building CXX object CMakeFiles/testSuite.dir/src/JUnitOutputDriver.cpp.o
/g/g0/martymcf/devel/src/testsuite_9.2/src/JUnitOutputDriver.cpp: In constructor 'JUnitOutputDriver::JUnitOutputDriver(void*)':
/g/g0/martymcf/devel/src/testsuite_9.2/src/JUnitOutputDriver.cpp:13:50: error: 'getpid' was not declared in this scope
     results_log_name << "test_results" << getpid() << ".xml";
                                                  ^
make[2]: *** [CMakeFiles/testSuite.dir/src/JUnitOutputDriver.cpp.o] Error 1
make[1]: *** [CMakeFiles/testSuite.dir/all] Error 2
make: *** [all] Error 2

Has anyone else seen this?

I'll write up a separate PR in testsuite if I determine that this isn't somthing strange in my environment.

@cuviper
Copy link
Contributor Author

cuviper commented Aug 9, 2016

Yeah, I pulled the testsuite and I see the same getpid() error. That file needs to include the right headers to get that declaration. I'll just opened dyninst/testsuite#12.

@mcfadden8
Copy link
Contributor

Oops. I was writing dyninst/testsuite#11 while you were opening yours

@mcfadden8
Copy link
Contributor

I confirmed that I am able to successfully run the proccontrol testsuite on ppc64le against a version of proccontrol with the above patches applied. Thanks for catching/fixing this.

uname -a
Linux rzmist1 3.16.0-30-generic #40~14.04.1-Ubuntu SMP Thu Jan 15 17:42:36 UTC 2015 ppc64le ppc64le ppc64le GNU/Linux


./runTests -proccontrol
TEST                       COMP   OPT  ABI MODE     THREAD  LINK    PIC     RESULT
pc_addlibrary              g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_breakpoint              g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_detach                  g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_fork                    g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_fork_exec               g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_groups                  g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_irpc                    g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_launch                  g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_library                 g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_singlestep              g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_stat                    g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_temp_detach             g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_terminate               g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_terminate_stopped       g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_thread                  g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_thread_cont             g++    none 64  create   SPST    dynamic nonPIC  PASSED
pc_tls                     g++    none 64  create   SPST    dynamic nonPIC  PASSED

@cuviper
Copy link
Contributor Author

cuviper commented Aug 9, 2016

That's ok, I just cross-referenced it. 😄

@cuviper
Copy link
Contributor Author

cuviper commented Aug 9, 2016

Thanks for confirming! Let's merge it then, and I'll cherry-pick it for master too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants