How remote debugging is implemented in general - remote-debugging

I have been using remote debugging from JDeveloper to Weblogic server for quite sometime and found it's very useful. But I am interested in understanding how remote debugging is implemented technically.
When I make any java code change and rebuild the class in jdeveloper on a remote machine from where I am debugging the server, the code changes are automatically picked up the server. How does this happen? Does the tool send the compiled java class on the network to server?
Can any one please share any documents / links explaining the technicalities of remote debugging.
Thanks & Regards,
Harish

Not sure if you're asking about remote debugging in general, or for the particular tools you're describing.
I don't know much about Java/jdeveloper, but in general remote debugging works as follows:
On the target machine, a special server process hooks into the executable you want to debug, just like a debugger would when running locally. This server doesn't have to know about symbols and source code, just have the executable running. Using system commands it can ask it to stop and examine its memory space.
On the host machine the debugger itself runs and also has a copy of the executable, and of its source code. The debugger communicates with the server on the target machine using some kind of protocol (TCP/IP or maybe serial for embedded devices) and asks it to step, examines certain memory locations it knows about from the debug info in the executable, can show the source code being debugged to the user, etc.
Read, for example, on gdbserver which is probably the most popular remote debugging server out there.
Hope this helps :)

Related

How exactly does the WiX 'Service Install' work internally?

I have a problem with a web service that is installed and started with a .msi that is created with the WiX toolset.
The service can be installed and started on all the machines I tested so far (shown as running in the Services Manager) but on some machines it is not reachable (for example via a browser) and not shown in the list of listening ports on that machine (displayed with 'netstat -a').
I am trying to figure out what's going wrong but I am not really familiar with web service development and configuration. It's a third party service, thus I don't know how it works internally.
A good starting point for me would be to find out, what exactly happens when a service is installed and started during the execution of the .msi-file.
Maybe I could try to tackle the problem on a lower level then.
Below is my code in the ServiceInstall-Element:
<ServiceInstall
Id="ServiceID"
Type="ownProcess"
Vital="yes"
Name="ServiceName"
DisplayName="ServiceDisplayName"
Description="Lorem Ipsum"
Start="auto"
Account="LocalSystem"
ErrorControl="normal"
Interactive="no"
Arguments="action=run">
</ServiceInstall>
The argument is important - without it, the service won't start or run.
Maybe someone else encounterd the same or a similar problem and can help me out.
Thanks already in advance - each hint is appreciated.
EDIT I (15.04.18):
As it might be a problem with the specific service, I will add some further information here:
It's a third party software called CryptoLicensing:
http://www.ssware.com/cryptolicensing/cryptolicensing_net.htm
Part of this software is that specific program, that serves as a License Server and does the license registration, for example in a customer's network.
The service can be run as a Windows application or installed and run as a Windows service. In both cases it should be listening on a (pre-)specified port on the installed machine.
Whenever I start the .exe as an application, everything works as intended. The service is reachable (for example with the browser) and can be accessed from other machines in the network.
When the .exe is installed and started as a service, it does not work as intended on every machine. For example if I install and start the service on my laptop, it is shown as running in the Services Manager, but is not reachable on its assigned URL (not even on the localhost) nor is the specific port displayed in the active listening ports, for example with 'netstat -a'.
The service itself starts without any error messages and does not log any errors or exceptions as it seems to be running without any problems.
I contacted the vendor, but sometimes he doesn't reply quickly and he is not very specific in his replies.
Before asking the question I assumed that it was a problem with the Windows user rights and the WiX installer but during the discussion here I had the feeling that it might a problem with the service itself.
I hope this 'new' piece of information helps in isolating and location the problem.
Thanks to everyone who helped so far!
Hopefully not stating the obvious here, but WiX doesn't do much except populate the ServiceInstall table in the MSI file, so this is about why Windows Installer won't start the service. ServiceInstall table:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa371637(v=vs.85).aspx
Also, this isn't really about ServiceInstall - it's probably about the ServiceControl element in your WiX source, but it's not clear whether that's how you're starting it or if you're starting it manually later on. That does make a difference. What is the error message and where are you getting it, and is it a 1920 or 1921 error (in the context of ServiceControl).
The main reason a service will start on one system but not another is missing dependencies. If your service is C++ based (the post doesn't say) then there are probably dependencies on C runtimes, UCRT runtimes, MFC or ATL runtimes and so on.
First: are you sure this service is intended to run as LocalSystem? (MSDN, SO).
Second: did you check the event logs in detail for anything obvious? If the service is good you should find a hint at least. Something to start with. I find that I sometimes miss the actual logs in the event viewer because it is so "crowded". My take on it: empty the log and stop and restart the service.
Something locking / blocking: If the service installs and runs OK I would suspect other factors such as firewalls (hardware & software), security software in general (anti-virus, malware scanners), network configuration issues (proxies, WINS, DNS and all the complexities involved in networking). Is the service trying to reach an UNC path?
Diverse Machines: What are the target machines? Are they virtual, are they physical, are they test machines, are they operative SOE machines in corporate networks? Are they the same OS version and edition?
Further Ideas: It is not quite related, but maybe skim this list of suggestions for debugging from another answer (I am not sure why it was down-voted, I think it is an OK list to inspire debugging ideas): Windows Application Startup Error Exception code: 0xe0434352 (maybe just skim the bolded words for ideas - Recommended).
sc.exe: And finally, perhaps check the sc.exe tool (Service Control) and see if it can provide you with some useful information for debugging.
sc.exe in the context of killing hung services (sample use).
sc.exe from MSDN
Some further links:
Windows Services Frequently Asked Questions (FAQ). Content seems to be up to date - at face value at least. These guys claim to be experts on services. I have no idea who they are.
Essential Tools for Windows Services: SC.EXE
Run Service Control (sc.exe) command on secure port
After almost 20 months we finally (and accidentally) found a solution to the problem! For the few machines, on which the service did not run properly, setting the NoInteractiveServices value in the registry to 0 did the trick. A value of 1 (which is default) means that no service is allowed to run interactively, regardless of whether it has the SERVICE_INTERACTIVE_PROCESS property. More information on Interactive Services.
I am not completely satisfied with the solution, because on all the other machines NoInteractiveServices is set to 1 AND the service runs properly anyway. However, on the machines where the service did not run interactively this solution worked for us. Thus I will accept this as an answer.
If anyone has more information on this issue and can explain why this works, feel free to
add them - I would be very interested!

With QtCreator, how can I build my project on a remote server I have ssh access to?

I need to build an application on a remote server so it can be run locally, where it will issue commands to a website it is hosting. I'm building this application on my machine in QtCreator, but I would like to streamline testing the application by having it build on the remote server.
What is the best way to go about this?
That first sentence is so long and so confusing... -_-
That said Qt Creator supports remote deploying and debugging but not remote building (as far as I know; please someone correct me if I'm wrong).
The only remote-related thing about the building step is cross-compilation which again is performed locally (using a cross-compiler, specifying the sysroot etc.). Of course if the target platform is the same (architecture and installation wise) as the one you use for development the cross-compilation chaos can be completely omitted.
If you want to build Qt-based application (and not only run it) on the remote platform, you will have to setup the development infrastructure (Qt dev libraries, qmake etc.). However, I would suggest using your local system for the development unless the server provides a very noticeable boost during the building step. It's easier that way and makes sense especially if the application that you are building on the remote will be executed locally.
you have 3 options really:
run the IDE on the remote server and connect using vnc or x2go. This requires a relatively high bandwidth/low latency connection, or the GUI won't be reponsive. This is personally what I do at my work - although we have a dev server set up to mirror prod in our building - so the data connection is great.
sync your files using lsyncd and build via commandline. You code-completion will be based on your local machine, so won't be perfect, and you wont be able to double click compile errors, etc. If you are brave you could maybe set up a qt creator build configuration to do this for you, but includes would still be broken.
use another IDE. NetBeans supports remote builds. I have never personally used this feature, but I've heard that it works ok.

gdb debug remote core dump

I have a server written in C++ crashing in the production environment to which I have no direct access to. The crash generates a huge core dump ~34G which I cannot copy locally. I need to analyze the core dump but don't know how it can be done without copying it over. I tried running gdbserver on target but it doesn't take a core file as a parameter and seems only good for debugging running remote applications from a host machine. Is there a way this can be done?
I need to analyze the core dump but don't know how it can be done without copying it over.
You can't. You'll need to get the core dump to where you can run GDB.
I cannot ssh to the remote machine but can ask the sys admin to run something like gdbserver for me but he cannot analyze and debug the core file.
You don't need sysadmin to analyze anything. You just need to ask him to run a series of GDB commands, and send you the output. E.g.
where
thread apply all where
info registers
disas
... will get you a long way to understanding the problem, and will take your sysadmin less than 5 minutes.
I still will need to uncompress it to run it on gdb which I don't want to do on my local machine.
Also, talk to your manager. Your development setup is unreasonable. You have to be able to analyze production crashes locally, and that means you have to have access to a sufficiently beefy machine.

Remote C++ Development using SSH only inside Eclipse Environment

How do you integrate Remote Systems Explorer and CDT plugin inside eclipse ?
What I mean is that you can use Remote Systems Explorer (RSE) plugin to work on C++ code on a remote linux box inside Eclipse but when you try to compile, you basically run a shell command through SSH. The CDT plugin is unable to locate the remote system and off course the remote compiler.
Is there a way to integrate both the plugins so that we can use the parsing / suggestion features of CDT for the remote system as well; and also features like remote compilation, remote debugging using SSH only. If this is not possible, then what is the closest open source alternative to the above problem.
While I don't know how to integrate the plugins you mentioned I do something similar to what you want to achieve on a daily basis with SSH's X forwarding.
If the remote box has X libraries installed and you have a local X server running, you can just ssh -CXY ... into the development box and simply run eclipse (or any other X application) there. The process will live on the remote box and, therefore, have access to all the filesystems and tools, but the GUI elements and those alone will be displayed in your local X session. That, though, may require quite a bit of bandwidth. Please see man ssh and X documentation for security stuff and compression settings.
The PTP project is building a remote build for CDT. Not sure how good that works, but you could always use the Terminal view from RSE to manually call your remote build (make).
I have not used it myself, but maybe you could try NetBeans and see if it works for you.
According to page https://netbeans.org/kb/docs/cnd/remotedev-tutorial.html it has everything you need, even
[...] system includes, macro definitions, platform, etc. All of this information is gathered from the remote server and stored locally on your client system, so that when you edit locally the code assistance will work even when the project is set up to use a remote build host.

how to read list of running processes on a remote computer in C++

What can be done to know and list all running processes on a remote computer?
One idea is to have a server listening to our request on the remote machine and the other one is to use ssh.
The problem is i dont know whether there will be such a server running on the remote machine and i cannot use ssh because it needs authentication.
Is there any other way out ?
If you
cannot install a server program on the remote machine
cannot use anything that requires authentication
then you should not be allowed to know the list of all running processes on a machine. That request would be a security nightmare!
You can do something much simpler without (as many) security problems: scan the publicly-available ports for programs that are running. Programs like nmap.org let you know a fair bit of information about the publicly-running programs on machines.
I have done something similar in the past using SNMP. I don't have the specifics in front of me, but something like "snmpwalk -v2 -c public hostname prTable" got me the process table. I recall later configuring SNMP to generate errors when the number of processes didn't meet our specified requirement, like httpd must have at least 1 and less than 50.
I suggest you look at the code for a remote login, rlogin. You could remotely login to an account that has the privileges that you need. Once logged in, you can fetch a list of processes.
This looks like a good application for a script rather than a C or C++ program.