Get address of the breakpoint in Lauterbach - trace32

On setting breakpoint using the command,
Break.set function
And the breakpoint is set at the start of the function. We want to get the address of the breakpoint.
How can we get the address of the breakpoint?

Break.List opens a window which shows all breakpoints
sYmbol.RANGE(<symbol>) can be used to get the address (range) of a symbol, e.g.
AREA
PRINT sYmbol.RANGE(<symbol>)

Related

Omnet++> Caused a Debugging error

I was debugging on Omnet++ program and I was trying to find the value of a constant so I went around with the options in the debugger.
Then when I wanted to debug again I got this error
Error in final launch sequence Failed to execute MI command:
-exec-run Error message from debugger back end:
Warning:\nCannot insert breakpoint 1.\nCannot access memory at address 0x0\n
Warning:\nCannot insert breakpoint 1.\nCannot access memory at address
0x0\n
The program runs fine but not with debugging
I searched online and found that this error has to do with GDB
accessing memory at address 0x0 means that I am trying to dereference a null pointer.
Also this error is shown in the debug tab of omnet++
terminated, exit value: 0 gdb (7.11.1)
Any one have an idea what might be the problem. Should I remove the Omnet++ and download it again?
I don't know why but I found this line in the breakpoints tab as shown in the picture, solved by removing it.

I can't access to a memory location with gdb/mi which I used to access with gdb

I'm trying to execute print *((int*)0x00401000) command on Kmines(a minesweeper game) with gdb and gdb/mi. While using gdb the command works and returns the output $1=0. But while using same command with gdb/mi it returns the ^error,msg="Cannot access memory at address 0x400000" error. Gdb can definitely access that location, there's no doubt for it. But why gdb/mi can't while gdb can?
I forgot to mention that I use non-stop mode. So because of it, gdb lets the debuggee run while it executes commands and gdb has to stop the process to access proc/pid/mem and read values from it.So gdb won't be able to access the memory if no thread has been stopped.
Edit: Some memory-examination functions such as disas works while some others such as print and x does not. So unfortunately, this answer is partially true.

Break debugging after a TRACE call

Is it possible to break debugging as TRACE(the debugger message output macro) is called, the message from trace appears on output, but I am unable to break the debugger as it does. (Am using visual studio 2003/windows).
I do not have the source code for this application. I'm simply attaching to the process.
Put a breakpoint on one of your TRACE calls. Do whatever you need to do to make it fire. Step In. Put another breakpoint in that code. Remove your first breakpoint.
Edit: Put a breakpoint on the OutputDebugStringW and OutputDebugStringA APIs in kernel32.dll - it's those APIs that the TRACE macro calls.
In the Breakpoints window, go New / Break at Function, and enter _OutputDebugStringW#4. Repeat for _OutputDebugStringA#4.

Redefining a breakpoint and referring to multiple breakpoints

Is there any way in gdb to redefine the location of a breakpoint without having to disable/delete it and make another one, say, two lines above it which is invariably assigned a different number even if we delete the previous one?
Is there any way in gdb to redefine the location of a breakpoint without having to disable/delete it and make another one
No.
Presumably you care about keeping the old breakpoint number because you've attached commands to disable and enable that breakpoint to other breakpoints. If so, you can use save breakpoints command to save breakpoint definitions to a file, adjust the location of the breakpoint there with an editor, then restart GDB and use source command to reload the breakpoints.

Getting the breakpoint number from gdb

I am writing gdb command scripts to simplify the debugging. One of the problems I have
is that I am setting a breakpoint, and I want to disable it afterwards, and only enable it after another breakpoint is hit.
What I want to do is this
$my_break_number = break SomeFile.cpp:231
disable $my_break_number
but unfortunately gdb doesn't work this way. I have read the manual, but I cannot find any information on how to do this. Hopefully there is some information I have missed.
gdb will automatically set a convenience variable $bpnum with the last set breakpoint number.
You can possibly use that after setting a breakpoint to disable it (I haven't tested when a breakpoint is ambiguous and creates multiple breakpoints, I think it will work and disable all breakpoint locations created.)
see: http://sourceware.org/gdb/current/onlinedocs/gdb/Set-Breaks.html#Set-Breaks
if you need to use the breakpoint number from commands, that is probably not what you want, but it works for the question as specified.
It sounds like you may want to use the Python GDB scripting, which gives you a lot better programmatic access to breakpoints than what is possible with "regular" command scripts.
Also info breakpoints gives useful information such as:
number of breakpoint, how many time the breakpoint was hit, address in memory, what function is it in, file and line number of breakpoint