Setting Memory Breakpoints in Eclipse - eclipse

How do you set memory breakpoints in Eclipse? That is, I would like to set a conditional breakpoint that triggers when the data at a given memory location changes.
This question has been asked before, but the only provided answer doesn't address the question and is essentially the same information that can be found in the Eclipse Online help.
What I am looking for is more detailed information (or an example would be good) for setting a conditional breakpoint in Eclipse that will trigger when the data at a specific memory address changes.

You need to use a watchpoint. From the page:
Highlight the variable in the editor, or select it in the Outline
view.
Click Run > Toggle Watchpoint.
Do any of the following:
To stop execution when the watch expression is read, select the Read check box.
To stop execution when the watch expression is written to, select the Write check box.
The watchpoint appears in the Breakpoints view list.

Solution that works:
1/ Select the variable representing the pointer you want to break on in a given context in the "Variables" tab
2/ Right click, then select "Add Watchpoint (C/C++)
3/ In the field "Expression to watch", just replace the name of the variable by the memory address to break on.

Using a Watchpoint in Eclipse Oxygen:
In the Expressions view (Window > Show View > Expressions), add an Expression such as: *(uint8_t*)0x231cc528. The cast tells Eclipse the memory location size.
Right-click the added expression and select "Add Watchpoint".
The resulting Watchpoint may be edited and controlled in the "Breakpoints" view.
It may be important to edit the Watchpoint. If you want to e.g. detect changes done by other threads: right-click the Watchpoint in the "Breakpoints" view, select Breakpoint Properties... > Filter, UN-check "Restrict to Selected Processes and Threads"

Related

Disable line breaks after loops without body

Consider a Java while-loop without a body, for example this:
while (map.values().remove(value));
When formatting it (Shift + Alt + F), Eclipse breaks the line before the semicolon and indents it:
while (map.values().remove(value))
;
How can I configure the formatter to not add these line breaks?
Be aware that by setting this semicolon to a new line, you may avoid unintended endless loops and a long search to find them.
However, in Eclipse all code formatting properties are 1) in the project properties and 2) in the Eclipse properties. The project properties inherit from the Eclipse properties.
So if you open the project properties, type "format" in the search field. It will show you a "Formatter" menu item, that may depend on the current language (at least in Java it is called "Formatter"). Then, in this example, allow the project-specific settings, and then click edit. You will see a flood of possible details you can decide.
See here:
Then, in the tab "New Lines", uncheck the checkbox "Put empty statement on new line", in the section "Empty statements".
Often you have to try and search a bit because there are really many options. The part at right shows you a preview of the code formatting.

Increase Eclipse debugger toString buffer size

I commonly have fairly large toString() representations of data structures that I need to debug. But, when I highlight them in the Eclipse debugger they get truncated to 10000 chars with a "..." termination.
How do I change the limit? Preferably to unlimited.
This was answered Viewing complete strings while debugging in Eclipse by Eugene Kuleshov but it is not the selected answer so I am listing what I believe is the correct answer here.
From the Debug Perspective right click on the text pane in the Variables tab and select "Mac Length" Set the value to 0 for unlimited or whichever other number you prefer.
Have you tried setting up a Detail Formatter for your class (open Preferences and search for "detail")? Using a custom formatter might bypass the truncation.
For PHP Xdebug debugging with Eclipse PDT, two settings have to be configured:
Window > Preferences > PHP > Debug > Debuggers > select Xdebug > Configure > under General Settings > Max data: provide a sufficiently large value, e.g. 1000000. > Apply and Close > Apply and Close.
In the Variables debugger view, right click the lower "variable value" area. From the pop-up, select Max Length.... In the Configure Details Pane modal, provide the value 0.
Now Eclipse needs to be restarted for these settings to take effect.

Partial AutoComplete in eclipse?

I'm very happy with the way eclipse autocompletes for me, but I was wondering if it could do something more...
I often have very similarly named variables, such as myPlayerManagerPane and myCharacterManagerPane, I was wondering if there was a way that would allow me to get half way into the name, type a character or two and then autocomplete. This would let me copy and past lines of code for both, then surgically edit the variable names. It's gotten to the point where I'm trying to do this (I'm autocompleting on autopilot) and getting fun variables such as myCharacterManagerPaneManagerPane as I autocomplete a whole name, halfway through another.
Is there a way around this?
In Window > Preferences > Java > Editor > Content Assist, select "Completion overwrites", instead of "Completion inserts". This would overwrite the entire variable with the new one.
Alternatively, you can press Ctrl to toggle this behaviour when the content assist window pops up.
Your question (or rather, its prelude) can easily be confused with another one; namely,
Say I have two variables variableLabel and variableConfiguration, how can I have Eclipse complete the common prefix of the two variables, i.e. variable, before writing either L or C and having Eclipse "AutoComplete" complete the rest?
This is the question which lead me to this thread, so I feel I must answer it:
In Window > Preferences > Java > Editor > Content Assist, check "Insert common prefixes automatically". Pressing Ctrl+Space now results in the desired functionality.
Relevant StackOverflow question

Is there a key binding for Next Difference and Previous Difference in Eclipse Compare Editor?

In compare editor there are buttons
Next Difference
Previous Difference
Next Change
Previous Change
I'd like to assign key bindings for Next Difference and Previous Difference buttons. However in preferences I see only Select Next Change and Select Previous Change commands (both in category Compare). How can I assign key bindings to buttons referring to differences?
My Eclipse:
Version: Indigo Service Release 2
Build id: 20120216-1857
There are default shortcuts for these:
CTRL-. (next) and CTRL-, (previous)
Next Difference, Previous Difference:
No key mapping (still in Eclipse Neon ) :(
Next Change, Previous Change:
Set "When" to "Comparing in an Editor" worked for me.
In Eclipse Mars, it is still the same process as moeTi explained. I am adding some details. To set custom keyboard shortcuts, go to:
Open Window->Preferences
General->Keys
Here's a list of the commands you would want and the associated mapping:
Previous Difference (Select the previous difference in the comparison editor)
Command 'Previous' in category 'Navigate'
Next Difference (Select the next difference in the comparison editor)
The command 'Next' in category 'Navigate'
Copy Current Change from Right to Left (replace your code with theirs)
The command 'Copy from Right to Left' in category 'Compare'
Copy Current Change from Left to Right (generally not an option)
The command 'Copy from Left to Right' in category 'Compare'

Find all assignments to variable

Eclipse has an easy way to find all references to a variable, but is there a quick way to only look for assignments?
Quick? Hm... Find all references with Ctrl+Shift+G, then filter in the Search view (results) via the View menu (dropdown triangle). You can select Reads there to filter these.
Shortcut: Cursor to the variable, menu Search > Write Access > Workspace. No keybinding assigned by default, but you can do this as usual (Preferences > General > Keys).
Ctrl+Shift+U shows all usages of a variable, with different icons for read and write references.
You can also set different colors for read and write occurrences of the selected variable (in the right part of the editor). These colors are set in Eclipse preferences, in "General -> Editors -> Text editors -> Annotations". There is "Occurences" and "Write occurences". I set the same color, slightly darker for "Write occurence", so I can easily spot write occurences, without any key stroke.
Ctrl+Alt+U finds all the references within a class (local references) for a particular variable, on my ubuntu machine.