Tracing the functions stack through gdb

2007-04-26 Thread Elazar Leibovich

Problem:
I wish to hack and solve Bidirectionality related bugs in Lyx.
However, I don't want to read all and understand all the code in Lyx,
but only the code related to cursor movement, character insertion,
etc.
How can I find the relevant pieces of code quickly?
Suggested Solution:
Run Lyx with a debugger, have the debugger print constantly which
functions from lyx sources (so that printf() wouldn't litter the
output) are being called, now press left, and watch the execution
flow, based on that locate the required code.

Is there any way to do that with gdb? Any other smart solution?

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Tracing the functions stack through gdb

2007-04-26 Thread Moshe Gorohovsky
Hi Elazar,

Put some fprintfs into the code, start with main().
Save the output to a file.
This is a quick way to circumvent all the gdb hassle.
This requires some code understanding.

Example:
== ce.h 
#include cstdio

static char *cefilename = ce.txt;

#define ceprintf(...) \
do { \
  FILE *dfp = fopen(cefilename, a); \
  fprintf(dfp, __VA_ARGS__); \
  fclose(dfp); \
} \
while (0)

 End of ce.h ===

LyX main() fuction:

#include ce.h

..
main() {
  ...
  ceprintf(Starting main()\n);
  ...
  ceprintf(Calling somefunc or somemethod.\n);
  someclass.somemethod(foo, bar);
  ceprintf(back from somemethod.\n);
  ...
}

=

Check ce.txt file in your cwd.

Moshe.

Elazar Leibovich wrote:
 Problem:
 I wish to hack and solve Bidirectionality related bugs in Lyx.
 However, I don't want to read all and understand all the code in Lyx,
 but only the code related to cursor movement, character insertion,
 etc.
 How can I find the relevant pieces of code quickly?
 Suggested Solution:
 Run Lyx with a debugger, have the debugger print constantly which
 functions from lyx sources (so that printf() wouldn't litter the
 output) are being called, now press left, and watch the execution
 flow, based on that locate the required code.
 
 Is there any way to do that with gdb? Any other smart solution?
 
 =
 To unsubscribe, send mail to [EMAIL PROTECTED] with
 the word unsubscribe in the message body, e.g., run the command
 echo unsubscribe | mail [EMAIL PROTECTED]
 

-- 
Moshe Gorohovsky

A6 CC A7 E1 C2 BD 8C 1B  30 8E A4 C3 4C 09 88 47   Tk Open Systems Ltd.
---
 - Tel: +972.2.679.5364, http://www.tkos.co.il -

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Tracing the functions stack through gdb

2007-04-26 Thread Moshe Gorohovsky
Hi Elazar,

Using the cpp macro that I have mentioned in my previous post
eliminates the need to recompile all the LyX source files
with debug information. No more g++ -g !

Elazar Leibovich wrote:
 Problem:
 I wish to hack and solve Bidirectionality related bugs in Lyx.
 However, I don't want to read all and understand all the code in Lyx,
 but only the code related to cursor movement, character insertion,
 etc.
 How can I find the relevant pieces of code quickly?
 Suggested Solution:
 Run Lyx with a debugger, have the debugger print constantly which
 functions from lyx sources (so that printf() wouldn't litter the
 output) are being called, now press left, and watch the execution
 flow, based on that locate the required code.
 
 Is there any way to do that with gdb? Any other smart solution?
 
 =
 To unsubscribe, send mail to [EMAIL PROTECTED] with
 the word unsubscribe in the message body, e.g., run the command
 echo unsubscribe | mail [EMAIL PROTECTED]
 

-- 
Moshe Gorohovsky

A6 CC A7 E1 C2 BD 8C 1B  30 8E A4 C3 4C 09 88 47   Tk Open Systems Ltd.
---
  - Tel: +972.2.679.5364, http://www.tkos.co.il -

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]



Re: Tracing the functions stack through gdb

2007-04-26 Thread Baruch Even
* Elazar Leibovich [EMAIL PROTECTED] [070426 16:24]:
 Problem:
 I wish to hack and solve Bidirectionality related bugs in Lyx.
 However, I don't want to read all and understand all the code in Lyx,
 but only the code related to cursor movement, character insertion,
 etc.
 How can I find the relevant pieces of code quickly?

The best suggestion would be to ask the developers of LyX, some of them
are also available on IRC and can easily point you to the best places to
look at.

 Suggested Solution:
 Run Lyx with a debugger, have the debugger print constantly which
 functions from lyx sources (so that printf() wouldn't litter the
 output) are being called, now press left, and watch the execution
 flow, based on that locate the required code.

I'd go for grepping the source with left right and cursor, as far
as I remember this code was done in one large event loop so you should
be able to find it from there, try to search for the above keywords in
an area of a switch block.

Baruch

=
To unsubscribe, send mail to [EMAIL PROTECTED] with
the word unsubscribe in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]