Is there a way to tell LLDB to ignore a file, i.e. step over code in that file when debugging?
(This could be used as a workaround for 1, 2, 3)
There is a setting to avoid stepping into functions whose name match a regular expression,
(lldb) set list target.process.thread.step-avoid-regexp
step-avoid-regexp -- A regular expression defining functions step-in won't stop in.
e.g. put this in your ~/.lldbinit file
settings set target.process.thread.step-avoid-regexp ^[^ ]+ std::|^std::
but in Xcode 4.5.x that's the best that can be done. I mentioned in #2 of your links that inlined stepping support has been added to the LLDB sources at http://lldb.llvm.org/ but that won't be in Xcode until the next release.
Related
lldb just completes the builtin command but the variable.
It is really awkward but i prefer lldb rather than gdb.
So how can i make lldb work like gdb.
I'm assuming you are talking about the print (aka expr) command here. gdb uses its own built-in expression parser, so it knows what token your cursor is pointing at when you hit tab, and it can look it up in its symbols list.
lldb uses clang as its expression parser, and getting that to do partial parsing and completion is a more complicated task, and one we haven't gotten to yet.
I am trying to set breakpoints on all functions that start with "dc_api" but I must exclude functions that start with "dc_api_port_counter" and "dc_api_send_reply".
Regarding the "dc_api_port_counter" exclusion, note that I do want to include functions that start with "dc_api_port_something".
I used regex online tester and came up with the following regex:
dc_api_(?!port_counter|send_reply).*
However, when using it, I get the following error:
(gdb) rbreak dc_api_(?!port_counter|send_reply).*
!port_counter|send_reply).*: event not found
(gdb)
Appreciate your help.
There's no simple, built-in way to do this. However, it can be done a couple of ways.
First, use rbreak to set "too many" breakpoints. Then, the trick is to find an automated way to delete the extra breakpoints.
A straightforward way to do this is to write a bit of code in Python that loops over all the gdb breakpoints. For each breakpoint it would examine the location attribute, and, if it should be excluded, call the breakpoint's delete method.
I am having an annoying behavior in Sublime.
When I start typing out the line...
using namespace SomeNamespace;
The keywords 'using' and 'namespace' are properly colored the keyword coloring. Then when I add the semicolon to the end of the line, the namespace keyword goes white (default text color). I know this is not that significant, but it really annoys me.
Has anyone noticed this behavior before? The code compiles without errors or warnings, so I know sublime is not detecting some so of code problem.
Does anyone have any suggestions on how to fix this problem?
The problem is in this particular regex in the C++ syntax definition:
\b(namespace)\s+([A-Za-z_][_A-Za-z0-9:]*\b)?+(?!\s*?(;|=|,))
At the very end, in the negative lookahead - (?!...) - we see that semicolons are excluded from the match, meaning that if a semicolon is present at the very end of the line, there's no match.
To fix it, you'll need to install the very useful PackageResourceViewer plugin from Package Control. Then, open the Command Palette, type prv to bring up the PackageResourceViewer options, select the Extract Package one, then scroll down and select C++. There will now be a C++ directory in the directory opened by choosing Preferences -> Browse Packages.... Go into that directory and you'll see a bunch of files. Depending on what version of Sublime Text 3 you're using, you'll want to open either C++.tmLanguage or C++.sublime-syntax in Sublime. The .tmLanguage format is XML, so you can pick that for syntax highlighting if you wish, while the .sublime-syntax file is in YAML.
Once the appropriate file is open (you'll either have one or the other, not both), search for the regex above, or just search for namespace, you should find it pretty easily. Delete the ;| from near the end, making the whole thing:
\b(namespace)\s+([A-Za-z_][_A-Za-z0-9:]*\b)?+(?!\s*?(=|,))
Save the file, and that's it! Your C++ source files should update their behavior immediately - if not, just close and reopen them, and in the worst case you can just close them, restart Sublime, then reopen them.
I want to put breakpoint on all functions of a file. I came across this link : http://sourceware.org/gdb/download/onlinedocs/gdb/Set-Breaks.html#Set-Breaks
It suggest the use of rbreak command for this purpose. When i use "rbreak ." , it works fine as expected and puts breakpoint in all functions of a prog. But when is use
rbreak filename.c:.
This doesn't work at all and no breakpoint is put anywhere. I even tried a variation of this putting spaces around :, but even that doesn't work.
Any idea on how this can be done ? Is it possible at all ?
Any help will be greatly appreciated.
thanks,
vikas
rbreak filename.cpp:.* works fine for me.
Note that in order to put breakpoint in a file you need to compile the program with debug info, e.g
g++ -g filename.cpp
rbreak filename.c:.
That isn't supposed to work. From the document you linked to:
rbreak regex
Set breakpoints on all *functions* matching the regular expression regex.
This is different from locations, where filename.c:... is intended to be used.
I want to put breakpoint on all functions of a file.
This is an unusual request. In my many years of debugging, I've never needed to do that.
You'll have to prepare a list, and set the breakpoints individually. A recipe for doing this can be found here.
I have generated a parser code using Lemon Parser. I am not able to debug the generated code. Control shows some other source code than the currently executing statement. Breakpoints are displaced. I tried on gdb and Visual C++. Both have the same problem. Please tell me the way to debug it.
Let's say your input file is named mylexer.y in which case Lemon will generate myparser.c and myparser.h
Inside of myparser.c you will see lines such as this
#line 1 "myparser.y"
These are line directives. They are good for tracing syntax errors back to the file that was used to generate the code. They are not good for debugging.
To suppress them invoke Lemon with the -l option.
lemon -l myparser.y
To see other options not mentioned in the documentation use -?
lemon -?
The following is a certified WAG (Wild Ass Guess):
I would recommend looking at all of the macros being used by the parser generator and see if there are any escaped newlines in them. If there are, try removing all of them (by joining the lines together) and then recompile the file. Then looked at the code in the debugger -- things suddenly may be back to where they should be.
Backstory: Back in the 80's I developed and marketed a debugger called CDB. As I ported it to anything that had U*NX in it's name I became intimately familiar with the idiosyncrasies of the various compilers and how they emitted debug info in certain situations.
One widespread problem had to do with macros that had escaped newlines them. E.g.
#define foo(bar) bar + \
snort + something_else
x = foo(5);
y = 2;
If the line number for y = 2; should have been 5, many symbol tables would end up showing it as 6, and every line after it would be off-by-one. And each use of such a macro would throw the line numbers farther and farther off.
Check optimization, debug information options if you are building them as lib/dll.