Using lldb on mac os doesn't ask for Developer Tools Access - lldb

I'm following a tutorial on using lldb. I tried typing process attach -p and I got error: attach failed: Error 1. However in the tutorial a screen pops up asking for "developer tools access needs to take control of another process for debugging to continue". I think this is why it won't work. Why does it not pop up?

What were you trying to debug? On Darwin systems, only processes that opt into being debugged can be, and most shipping apps (including all the system ones) do not opt into being debugged.
Since this isn't an issue with the general permission to debug, but rather the target proces rejecting your attach attempt, you wouldn't see the "Developer Tools" dialog box. You machine is configured to debug, just not this process...
You can test this by building something yourself and then attaching to it.

Related

how to use lldb sbapi in xcode

`lldb::SBDebugger::Initialize();
lldb::SBListener sbListener;
lldb::SBTarget sbTarget;
lldb::SBError sbError;
sbTarget.ConnectRemote(sbListener, "connect://127.0.0.1:3333", nullptr, sbError);
if (sbError.IsValid()) {
printf("%s\n", sbError.GetCString());
//got an error "SBTarget is invalid"
}`
xcode 11.6 connect ios13.3.1 got an error "SBTarget is invalid"
how to use lldb sbapi in xcode
This isn't a supported use of lldb within Xcode.
Xcode knows nothing about new debuggers you make by hand, and since Xcode is the one that hooks debuggers up to the Console window, it wouldn't know to provide you a way to interact with them.
Also, lldb is an event-driven framework, but your new target is hooked up to an event listener that Xcode knows nothing about, so it won't know the drive its event loop.
Even if you did manage to get one of the debuggers in Xcode to wait for your new target's events, Xcode expects one target per debugger, so if you caused events for a second target to show up, Xcode would just get confused.
I think what you really want to do is to customize the startup sequence (essentially script the action of the Run part of Xcode's Build & Run button). That is a perfectly reasonable enhancement request. If you are so motivated, feel free to file a bug report. These days it looks like you use the Feedback Assistant app for that purpose. See:
https://developer.apple.com/bug-reporting/
But I don't think you are going to have much luck doing this without cooperation from Xcode.

How to debug child project process in Visual Studio

I have a solution with two console applications. Application B is started by application A. I would like to debug both, but at least application B.
I have tried to configure as debug profile for application B to start executable A instead of itself, and I have set up application B to be the startup project. When I hit Run application A is started as expected, which in turn starts application B, however I still get the warning on my breakpoint in application B that it won't be hit because the source code is different. I have tried to set dependency of A from B, and also of B from A, but neither made any difference.
Update: However, attaching to the already running process B works as expected. This can be a workaround but a quite cumbersome one.
What can be done to get this right?
What can be done to get this right?
Please try to use the Child Process Debugging Power Tool which is also suitable for VS2019.
We can easily debug this child project with this extension by Debug-->Other Debug Targets-->Child Process Debugging Settings.(If you are debugging .NET code, you must choose to enable mixed mode debugging which means that you debug two different types of projects.)
In the pop-up page, check the box to open the startup child process debugging and click Save. After that, default debug will support all child processes.
Note that by default, the same debug engine settings are used as the parent process debug.
More information you could refer to this blog. Hope it could help you.

Debugging Postgresql 9.3 with Eclipse CDT and GDB

i am from java background and have used debugger in eclipse(java).
i have installed postgresql 9.3 as stated in this link: https://wiki.postgresql.org/wiki/Working_with_Eclipse
The debugger works fine for the server(which waits and accepts incoming client connections).
When i connect a client with: $ psql test .Does the server create a new thread for the client?
Is it possible to attach debugger and set breakpoints in parser.c or executor.c in postgresql source files so that i can analyse how postgresql queries are executed?
I have tried attaching debugger and set breakpoints in parser.c and executed some queries in the client.But it doesnt stop at the breakpoint.
Thanks in Advance
When i connect a client with: $ psql test, Does the server create a new thread for the client?
No. The server creates a new postgres (or, on Windows, postgres.exe) process that communicates with the postmaster and other processes via shared memory and signals. PostgreSQL uses a shared-nothing-by-default multiprocessing architecture rather than a shared-everything-by-default multithreading architecture.
Is it possible to attach debugger and set breakpoints in parser.c or executor.c in postgresql source files so that i can analyse how postgresql queries are executed?
Yes, if your debugger can follow backend forks from the postmaster, or if you directly attach your debugger to the backend you wish to debug. The latter is more common unless you're debugging backend startup.
A typical workflow is:
Connect with psql
SELECT pg_backend_pid()
Connect the debugger to that process ID
Set breakpoints and watches as desired and resume execution
In the same psql session, run the query you want to debug backend execution of
Switch to the debugger when it traps and start debugging
This works on Linux with gdb and Windows with Visual Studio. Presumably it works with Eclipse too.
More at the developer FAQ.
It is possible to instead debug the postmaster and use gdb's multi-process debugging features with follow-fork-mode, detach-on-fork, schedule-multiple and non-stop options, but it's complicated to get right, noisy, and will be confusing if you're used to gdb's normal break behaviour. It's also a bit awkward because PostgreSQL uses signals that gdb also uses, so some hacks are required to work around that. See a blog post I wrote on the topic earlier.
I recommend keeping it simple and attaching using pg_backend_pid.

"stack.cpp not found" prevents debug in VS 2013 express

I'm a rookie at C in general and VS 2013 also. I am trying to use some C code provided by a vendor in VS 2013 express. It compiles and runs without problem using the command line compiler but I would like to use the IDE.
I started a new project, C++ for console app, and I have pasted the code into the IDE and saved it as xyy.c so that it builds successfully. I thought it would be nice to have it in a GUI, so I duplicated the effort with a Win32 app project. It also builds.
The program's job is to connect to a PCI card that has Plx chip as an interface and program an FPGA. The Win32 program succeeds, even though I can't see any of the info printed by the program. The console program fails and I think it is because it fails to find the driver for the Plx chip. I thought I would get a clue by single stepping through the Win32 program to see which driver was supposed to be found.
However, after the first pass through a while loop, I get a pop up that says "Source Not Found" and "stack.cpp not found". Google wasn't any help to me.
I be grateful for any suggestions.
You might have "Enable .NET Framework source stepping" enabled (see http://msdn.microsoft.com/en-us/library/cc667410.aspx). So when you are at Stack... and trying to step into, it will actually try, but you don't have the sources for that. There is also a new experience for using the .NET framework reference source that was announced recently: http://blogs.msdn.com/b/dotnet/archive/2014/02/24/a-new-look-for-net-reference-source.aspx
I faced the same problem. I advise at the moment of receiving the information "stack.cpp not found" to look at the stack trace and check if there is something like this: "RTC".
If there is, you need to change the flag along the path (for example, set the Default or a more convenient configuration for you):
Project Properties -> C/C++ -> Code Generation -> Basic Runtime Checks
More details: https://learn.microsoft.com/en-us/cpp/build/reference/rtc-run-time-error-checks?view=msvc-160

ld.exe: cannot open output file ... : Permission denied

I recently installed CodeBlocks with mingw32 on Windows 7 Ultimate 32bit in order to dust off my c skills, but this problem has me somewhat stumped.
I decided to fire off a short Fibonacci generator to make sure my setup was working, but I ran into a hurdle.
The program compiles, links and whatnot like a charm and I get a corresponding executable which runs as expected.
The problems occur if I try to compile again, then I get the following:
c:/codeblocks/mingw/bin/../lib/gcc/mingw32/4.4.1/../../../../mingw32/bin/ld.exe: cannot open output file bin\Debug\Fibonacci.exe: Permission denied
I can't even edit the permissions of the generated executable.
I've checked the usual suspects:
Executable is verily not running.
Path to executable is read/writable to mingw32 (otherwise it wouldn't be able to build in the first place)
I'm not running cygwin in any shape or form.
And now for the funny bit: Usually after a few minutes, any executables generated by mingw32 which are displaying this Access Denied behaviour will automatically vanish without any intervention from me.
I've googled this somewhat, but most of the other results were either vague or inapplicable.
I wonder whether there is some Windows 7 security setting playing havoc with my .exe's, but I'm not that knowledgeable about Win 7 as to know where to begin searching.
Any one have any ideas?
I had exactly the same problem right after switching off some (in my opinion unneccessary) Windows services. It turned out that when I switched ON again the "Application Experience" everything resumed working fine.
May be you simply have to turn on this service? To switch ON Application Experience:
Click the Windows start buttonn.
In the box labeled "Search programs and files" type services.msc and click the search button. A new window with title "Services" opens.
Right click on "Application Experience" line and select "Properties" from popup menu.
Change Startup type to "Automatic (delayed start)".
Restart computer.
Application Experiences should prevent the problem in the future.
Your program is still running. You have to kill it by closing the command line window.
If you press control alt delete, task manager, process`s (kill the ones that match your filename).
If you think the executable is locked by a process, try Process Explorer from SysInternals. In the File/handle, enter Fibonacci.exe and you should see who holds the file.
If it is not enough, you can use Process Monitor (from SysInternals, again) to follow the activity of all processes on your system on Fibonacci.exe.
With a little bit of analysis (call stacks), you'll may find out why the access to the file is denied and what make it disappear.
Problem Cause :
The process of the current program is still running without interuption.
(This is the reason why you haven't got this issue after a restart)
The fix is simple :
Go to cmd and type the command taskkill -im process_name.exe -f
Eg:
taskkill -im demo.exe -f
here,
demo - is my program name
The Best solution is go to console in eclipse IDE and click the red button to terminate the program.
You will see the your program is running and output can be seen there. :) !!
I had the same behaviour, and fixed it by running Code::Blocks as administrator.
Open task manager -> Processes -> Click on .exe (Fibonacci.exe) -> End Process
if it doesn't work
Close eclipse IDE (or whatever IDE you use) and repeat step 1.
I had a similar problem. Using a freeware utility called Unlocker (version 1.9.2), I found that my antivirus software (Panda free) had left a hanging lock on the executable file even though it didn't detect any threat. Unlocker was able to unlock it.
Got the same issue. Read this. Disabled the antivirus software (mcaffee). Et voila
Confirmed by the antivirus log:
Blocked by Access Protection rule d:\mingw64\x86_64-w64-mingw32\bin\ld.exe d:\workspace\cpp\bar\foo.exe User-defined Rules:ctx3 Action blocked : Create
It may be your Antivirus Software.
In my case Malwarebytes was holding a handle on my program's executable:
Using Process Explorer to close the handle, or just disabling antivirus for a bit work just fine.
i experienced a similar issue. Bitdefender automatically quarantined each exe-file i created by MinGW g++. Instead of the full exe-file i found a file with a weird extension 'qzquar'
testAutoPtr1.exe.48352.gzquar
When i opened quarantined items in Bitdefender i found my exe-file quarantined there.
I got this error when using the Atom editor and mingw (through a package called gpp-compiler) for C++. Closing the open console window fixed my issue.

Resources