postgres attaching a process - eclipse

How do we attach a sql query such as join query to an existing gdb process in eclipse? Whenever I try to fork the given process using debug configurations in eclipse, which is a shared library , I am getting the following error:
No source available for "__kernel_vsyscall() at 0xb729c424"
Also, whenever I set break points in a specific program in eclipse, control goes to main.c and finally the process never comes back to the actual program.
Is there any way that the process be constrained only to my specific program?

how do we attach a sql query such as join query to an existing gdb process in eclipse
Um, what?
Are you attempting to debug a PostgreSQL server backend? If so, see the PostgreSQL wiki page that provides lots of details on the topic.
Whenever I try to fork the given process using debug configurations in eclipse, which is a shared library
What is a shared library? Eclipse isn't. PostgreSQL isn't. So what's the shared library here?
Are you trying to debug a PostgreSQL extension? If so, see the above link for details on attaching to a PostgreSQL server backend.
No source available for "__kernel_vsyscall() at 0xb729c424"
That's normal. It's just telling you that there's no source code on record for the __kernel_vsyscall call that's the entrypoint into syscalls in linux-gate.so via glibc when using sysenter.
The stack below it should be more informative. Get a backtrace, then look at the lower stack frames.
See:
What is __kernel_vsyscall?
Having trouble finding the method __kernel_vsyscall within the Linux kernel
http://www.trilithium.com/johan/2005/08/linux-gate/
Your "also" is really a separate question, and it's pretty hard to answer it usefully with the total lack of information provided. Try posting a new, more detailed question on just that topic. Specify how you compiled the program, set it up for debugging, how you're running it, where you're trying to set breakpoints, etc.

Related

Connect PostgreSQL to HammerDB

As the title says, I want to connect PostgreSQL (I'm using the 9.6 x86 version) to HammerDB, an open source database load testing and benchmarking tool (I'm interested in the TPC-C Benchmark).
The thing is that I can do this connection by using MS SQL Server (2014), because it is relatively easy. However, I'm not used to use PostgreSQL. When I try to create Virtual Users on HammerDB (that's the 1st step to do, then you should be able to perform the transactions) I get the following error:
Error in Virtual User 1: Failed to load Pgtcl - Postgres Library Error
I did some research about this, and I found that, and I quote "PostgreSQL is VERY particular about the libraries in its PATH - they have to be the right ones and ONLY the right ones any other configuration will cause errors".
The problem is that HammerDB couldn't load library libpgtcl.dll. There they mention that to fix the problem, one should check that the PostgreSQL bin directory has been added to the path during install, but at this point I'm totally lost and I don't know what to do. I simply canĀ“t get what they mean and how to do it.
I hope at least one of you could help me. I would appreciate it a lot.
Sorry in advance for my mistakes in English, I'm a Spanish speaker.
Well, I have solved the problem, and it is very simple.
Everything is about Setting Windows PATH for PostgreSQL, and I found that here.
Open my Computer ==>
right click inside my computer and select properties ==>
Click on Advanced System Settings ==>
Environment Variables ==>
from the System Variables box select "PATH" ==>
Edit... ==>
Then add this at the end of whatever you find their
;C:\PostgreSQL\9.2\bin; C:\PostgreSQL\9.2\lib
after that continue to click OK
That's all. So this is what you should do if you are having trouble when trying to connect PostgreSQL to HammerDB, and in general, when trying to use PostgreSQL tools.

cannot load runtime-gdb.py

I'm trying to debug a program written using Go inside eclipse. I can set and hit breakpoints pretty consistently, but I cannot view the contents of my variables. When I start debugging the program, I always get the following error on my console.
warning: File "/usr/local/go/src/pkg/runtime/runtime-gdb.py" auto-loading has been declined by your `auto-load safe-path' set to "$debugdir:$datadir/auto-load".
To enable execution of this file add
add-auto-load-safe-path /usr/local/go/src/pkg/runtime/runtime-gdb.py
line to your configuration file "/home/johnlawrie/.gdbinit".
To completely disable this security protection add
set auto-load safe-path /
line to your configuration file "/home/johnlawrie/.gdbinit".
For more information about this security protection see the
"Auto-loading safe path" section in the GDB manual. E.g., run from the shell:
info "(gdb)Auto-loading safe path"
Thinking that the problem might be due to the error message, I put the entry into my .gdbinit file as instructed. However, I get the same message every time I run as if I did nothing at all. This is the contents of my /home/johnlawrie/.gdbinit file
add-auto-load-safe-path /usr/local/go/src/pkg/runtime/runtime-gdb.py
Any ideas what I need to do to make this change take effect? I have tried logged off and back in.
Thanks,
John Lawrie
It did learn what was happening. When gdb is started from Eclipse/CDT, it is started with option -nx, which means it doesn't load .gdbinit in the home directory.
I was able to get this to work by creating a .gdbinit file as a peer to the src, bin, and pkg directories in my workspace and adding the following line to it
set auto-load safe-path /usr/local/go/
It should be add-auto-load-safe-path /usr/local/go/src/pkg/, not the path to the script.
Also keep in mind that gdb doesn't really work with Go, specially v1.3.
From http://golang.org/doc/gdb:
GDB does not understand Go programs well. The stack management,
threading, and runtime contain aspects that differ enough from the
execution model GDB expects that they can confuse the debugger, even
when the program is compiled with gccgo. As a consequence, although
GDB can be useful in some situations, it is not a reliable debugger
for Go programs, particularly heavily concurrent ones. Moreover, it is
not a priority for the Go project to address these issues, which are
difficult. In short, the instructions below should be taken only as a
guide to how to use GDB when it works, not as a guarantee of success.

Commands that only affect the local debugger

When doing remote debugging, some commands affect only the local debugger (the debugger on which the command is typed). Examples are:
.wtitle
.cls
.browse
.cmdtree
At the moment these are all looking like UI related commands. Are there more commands that are only executed on the local debugger?
My research effort:
I was googling for a list, but maybe the search terms are too common or I don't get them right.
I have also tried finding a reference in WinDbg help (.hh) itself. But the fact is not even documented on the affected commands I found so far.
I am aware that this is asking for a favorite external tools or reference. So if you really think this is off-topic, then vote for close.
All debugger processing, including all extension execution, is done in the core debugger process. So 99+% of commands all need to go to the debugger engine (the initial debugger instance)
The only commands that run only on the remote debugger are indeed a few UI related commands.
I will call out one pair of commands that is interesting on this topic which is the mostly commonly used remote debugger:
.srcpath sets the "source code path" in the debugger engine. This is where the debugger engine will get source information from if it's needed - for example, if a debugger extension wants to get to the source code.
.lsrcpath (l - for local) sets the "source code path" in the remote debugger. This path will be used in windbg (and cdb\kd also) to pull up source files in the UI.
Still not a complete list, but many commands that are not scriptable (MSDN) are affected:
.lscrfix // works on remote client only
.lsrcpath // works on remote client only
.open
.write_cmd_hist // writes local history only
.beep
.cls
.hh
.remote // Does not work in WinDbg anyway
However, the following ones from the list seem to work:
.idle_cmd
.restart
Regarding .write_cmd_hist: If you want to keep all commands executed during the debug session, it seems good to open a log file (.logopen) at the beginning of the session.

Debugging embedded system with Eclipse - HOW TO PRINT TO A LOGGING FILE?

I'm currently working on a project on STM32F4 and I'm using Eclipse. I've got some problems with the program - it seems to have a random behavior - sometimes it works fine, other times it has some errors. Sometimes when I try do debug with breakpoints I get the beautiful HardFault Handler and it really messes with my brains.
Sorry for the little off-topic paragraph, just wanted to let you know why I decided to use printing to a log file at some key moments in the program so I can see in which states and in which functions does the problem occur. I'm debugging through a JTAG interface with Eclipse (gdb) and I need to know if there is an easy method integrated in Eclipse that may help me use fprintf-like functions inside my program to write to a file on the disk.
If no, any other solutions?
Thanks
I do not like to connect the debug output log to the Jtag communication port because the log will not be available after development.
I usually build an SystemLog library that can send the log messages through any medium that is available (UART, USB, Ethernet or SDCARD). That's what I'd recommend you to do. It will help you through the development, and the support team on the event of any failure on field.
If stdlib is available in your project you should use the snprintf family functions to build your SystemLog.
Also, you can integrate the log output to the eclipse console by calling a serial console communicator (if you use UART) on you makefile, in this case, your makefile will have to flash the target as well.

Eclipse plugin for psql/PostgreSQL code?

Do you have recommendations for a good PostgreSQL editor plugin for Eclipse?
The PostgreSQL code I have isn't very complex. However I'd like to edit it with syntax-coloring, decent auto-identation, code completion, etc., and it would be sweet to be able to send blocks or entire files to a jdbc connection and get the results. Up until now, I have edited my .sql files with Emacs, and try things by copying/pasting segments into a psql terminal I have next to Emacs. Some of my code uses the psql primitives such as \set var value etc. For example:
\set t mytable
drop table if exists :t;
create table :t (...);
However I would be happy to eliminate this and refactor the code to be proper PL/pgSQL functions. Or perhaps better, implement the dependency and procedural logic in Java and issue the sql queries via JDBC. I still need to edit the sql files and try bits and pieces of them during development.
I tried the "official" Data Tools Platform (http://eclipse.org/datatools/) and configured it to use my localhost:5432 (which in fact is a port-forward via SSH to the actual PostgreSQL server that I'm using). However, connecting to the DB hangs for several minutes (Eclipse doesn't even refresh the screen). In general it feels quite heavy/slow
and I'm always afraid of if hanging without ability to interrupt it (it happened a few times and the only solution is to kill Eclipse; as you probably know, killing Eclipse isn't good as it's very hard/impossible to recover unsaved files).
The other plugin I tried is Toby's PL/SQL editor (https://sourceforge.net/projects/plsqleditor/), which seems very nice and promising, except the last signs of life on the sourceforge forums appear to be around 2007. Also I couldn't configure it to use the postgresql-9.0-801.jdbc4.jar that I have, and so I am unable to connect to my DB.
Any suggestions gladly appreciated.
A free Eclipse plugin for Oracle and PostgreSQL can be found at http://www.toadworld.com/products/toad-extension-for-eclipse/default.aspx
The plugin is in development.