Setting a breakpoint at a line number and character offset

View: New views
3 Messages — Rating Filter:   Alert me  

Setting a breakpoint at a line number and character offset

by andy_westken :: Rate this Message:

| View Threaded | Show Only this Message

Hi

I apologise if this question has been answered elsewhere, but my web searches were swamped by noise...

Is is possible to get gdb to set a breakpoint at a line number and a character offset (or column) on the line?

From what I understand, this is not possible (at least for Ubuntu and GnuWin32 versions of the debugger). But I wanted to cross-check before using this to justify an item in some coding conventions.

Thanks, Andy

P.S. My contention is that code of the following form is intrinsically evil, from a debugging perspective.

if(condition) function1() else function2();

whereas

if(condition)
    function1()
else
    function2();

is debuggable!

Re: Setting a breakpoint at a line number and character offset

by Charles Manning-2 :: Rate this Message:

| View Threaded | Show Only this Message

On Tuesday 26 July 2011 05:47:15 andy_westken wrote:
> Hi
>
> I apologise if this question has been answered elsewhere, but my web
> searches were swamped by noise...
>
> Is is possible to get gdb to set a breakpoint at a line number and a
> character offset (or column) on the line?

Only a line number AFAIK.

Setting it at an actual column offset would be challenging.

>
> From what I understand, this is not possible (at least for Ubuntu and
> GnuWin32 versions of the debugger). But I wanted to cross-check before
> using this to justify an item in some coding conventions.
>
> Thanks, Andy
>
> P.S. My contention is that code of the following form is intrinsically
> evil, from a debugging perspective.

Some might argue the corollary that debugging is evil from a coding
perspective :-).
>
> if(condition) function1() else function2();

I guess you could do something like:

break function1
condition 1 (condition)

>
> whereas
>
> if(condition)
>     function1()
> else
>     function2();
>
> is debuggable!




Re: Setting a breakpoint at a line number and character offset

by andy_westken :: Rate this Message:

| View Threaded | Show Only this Message

Charles Manning-2 wrote:
On Tuesday 26 July 2011 05:47:15 andy_westken wrote:
> Hi
>
> I apologise if this question has been answered elsewhere, but my web
> searches were swamped by noise...
>
> Is is possible to get gdb to set a breakpoint at a line number and a
> character offset (or column) on the line?

Only a line number AFAIK.

Setting it at an actual column offset would be challenging.
Thanks for the info.

Andy

P.S. Debugging is totally evil, but unfortunately necessary!