Re: [Geany-Devel] About Malloc memory for each tab?
Am 24.10.2015 um 02:30 schrieb Matthew Brush: FWIW, doc->id is basically not very useful, it just tells the index into some internal array of GeanyDocument objects, but is not unique to each document/tab per se (it gets recycled for new documents and such). doc->id is unique these days, via an ever-incrementing document counter. What you are refering to is stored in doc->index. Best regards ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] About Malloc memory for each tab?
Hi Matthew, Thanks for your explanation about the process of page switch. It is very helpful for me. I want to recognize all malloc or new memory allocation functions related with one tab page. I hope to log all this memory allocation functions information related with this one tab no any other tabs. So I need one concrete identification for each tab. I will look at GtkNotebook widget. Best Regards, Pengfei On Fri, Oct 23, 2015 at 8:30 PM, Matthew Brush wrote: > On 15-10-23 09:21 AM, Pengfei Sun wrote: > >> Hi Lex, >> >> I have one question about tab switch in the geany. I know the different >> tab >> has different doc->id. I think there is only one thread which manages all >> tabs, right? I wonder when we switch different tabs to edit the document. >> How does geany manage or recognize different tabs? g_main_context_check >> will be called in g_main_loop_run. Whether the data structure GMainContext >> will include some information which can recognize the different tab? >> >> > Hi, > > I know you weren't addressing me, but you might want to look into GTK+, > the event-driven GUI toolkit Geany uses. When user changes a tab, the > GtkNotebook widget emits a signal telling Geany about the event, and then > Geany asks the GtkNotebook for the widget contained in the selected tab > page, which (eventually) contains the Scintilla widget, via the GTK+ widget > hierarchy. > > If you're trying to track down the control flow via GDB or other debugger, > the event-driven model is going to send you on a wild goose chase through > hell :) > > FWIW, doc->id is basically not very useful, it just tells the index into > some internal array of GeanyDocument objects, but is not unique to each > document/tab per se (it gets recycled for new documents and such). > > Cheers, > Matthew Brush > > > ___ > Devel mailing list > Devel@lists.geany.org > https://lists.geany.org/cgi-bin/mailman/listinfo/devel > ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] About Malloc memory for each tab?
On 15-10-23 09:21 AM, Pengfei Sun wrote: Hi Lex, I have one question about tab switch in the geany. I know the different tab has different doc->id. I think there is only one thread which manages all tabs, right? I wonder when we switch different tabs to edit the document. How does geany manage or recognize different tabs? g_main_context_check will be called in g_main_loop_run. Whether the data structure GMainContext will include some information which can recognize the different tab? Hi, I know you weren't addressing me, but you might want to look into GTK+, the event-driven GUI toolkit Geany uses. When user changes a tab, the GtkNotebook widget emits a signal telling Geany about the event, and then Geany asks the GtkNotebook for the widget contained in the selected tab page, which (eventually) contains the Scintilla widget, via the GTK+ widget hierarchy. If you're trying to track down the control flow via GDB or other debugger, the event-driven model is going to send you on a wild goose chase through hell :) FWIW, doc->id is basically not very useful, it just tells the index into some internal array of GeanyDocument objects, but is not unique to each document/tab per se (it gets recycled for new documents and such). Cheers, Matthew Brush ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] About Malloc memory for each tab?
On 24 October 2015 at 02:21, Pengfei Sun wrote: > Hi Lex, > > I have one question about tab switch in the geany. I know the different tab > has different doc->id. I think there is only one thread which manages all > tabs, right? I wonder when we switch different tabs to edit the document. > How does geany manage or recognize different tabs? g_main_context_check will > be called in g_main_loop_run. Whether the data structure GMainContext will > include some information which can recognize the different tab? Look in notebook.c > > Thank you very much! > > Best Regards, > Pengfei ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] About Malloc memory for each tab?
Hi Lex, I have one question about tab switch in the geany. I know the different tab has different doc->id. I think there is only one thread which manages all tabs, right? I wonder when we switch different tabs to edit the document. How does geany manage or recognize different tabs? g_main_context_check will be called in g_main_loop_run. Whether the data structure GMainContext will include some information which can recognize the different tab? Thank you very much! Best Regards, Pengfei On Fri, Oct 16, 2015 at 3:14 PM, Pengfei Sun wrote: > Thanks Lex. > > On Thu, Oct 15, 2015 at 5:33 PM, Lex Trotman wrote: > >> On 16 October 2015 at 06:42, Pengfei Sun wrote: >> > Hi Lex, >> > >> > I checked again the gap buffer and heap memory dump. I made mistakes >> last >> > time. scintilla_send_message returned the virtual address which was the >> > address of text in the heap. However, I also found parts of text (each >> line) >> > which locate in different address in the heap. So I made the mistake. >> > >> > I still have one question about memory allocation of geany. When you >> type >> > some text in the one window of geany, which function is responsible for >> > allocating the memory space in the heap? g_new, g_new0, g_malloc, >> > g_slice_alloc?? I remembered you mentioned that "The buffer itself is >> > allocated by Scintilla which means its allocated by C++ new". But I >> don't >> > find the exact location in the source code of geany. >> >> Splitvector.h:94 >> >> > >> > Thank you very much! >> > >> > Best Regards, >> > Pengfei >> > >> > On Wed, Oct 14, 2015 at 5:13 AM, Lex Trotman wrote: >> >> >> >> On 13 October 2015 at 04:43, Pengfei Sun >> wrote: >> >> > Hi Lex, >> >> > >> >> > Thanks for you hint about scintilla. Matthew also mentioned to use >> the >> >> > scintilla. I tried his patch, but there is still one problem about >> the >> >> > address of buffer. I don't know why the address of output is not >> >> > consistent >> >> > with address of buffer in the dumped heap memory? >> >> >> >> The Scintilla buffer is a gap buffer, its contents are moved depending >> >> on user actions, and depending on what else Geany is doing it can copy >> >> all or parts of the buffer to C memory. So your string can appear in >> >> lots of places in memory, C heap, C++ heap (which may or may not be >> >> the same as the C heap) not just in the buffer. >> >> >> >> Cheers >> >> Lex >> >> >> >> > >> >> > Best Regards, >> >> > Pengfei >> >> > >> >> > On Fri, Oct 9, 2015 at 7:12 PM, Lex Trotman >> wrote: >> >> >> >> >> >> On 10 October 2015 at 08:42, Pengfei Sun >> wrote: >> >> >> > Hi Lex, >> >> >> > >> >> >> > Thanks for your suggestions. >> >> >> > >> >> >> > I work on memory forensics. My part of project is to locate >> memory of >> >> >> > the >> >> >> > sensitive data. For example, when I use the geany open one >> sensitive >> >> >> > file, >> >> >> > and the content will be in the memory (heap). I hope I can locate >> all >> >> >> > memory >> >> >> > related this sensitive file. And later I can do some analysis or >> >> >> > protection. >> >> >> > >> >> >> >> >> >> The buffer itself is allocated by Scintilla which means its >> allocated >> >> >> by C++ new. >> >> >> >> >> >> > Now, I override malloc and can log all malloc functions to get >> return >> >> >> > address and size (I think g_malloc is a wrapper of malloc). But I >> >> >> > still >> >> >> > cannot building the mapping between the special file and related >> heap >> >> >> > memory. I know each open or created file have different ID >> >> >> > (GeanyDocument->id). However, I still cannot figure out how to >> trace >> >> >> > the >> >> >> > related memory of different ID. Assume I have open three files, so >> >> >> > there >> >> >> > are >> >> >> > three windows and three different GeanyDocument->id. I write or >> >> >> > change >> >> >> > some >> >> >> > things among these three windows. Meanwhile, I log all >> >> >> > malloc/realloc/calloc >> >> >> > functions. I try to figure out which malloc belong to window 1, >> which >> >> >> > belong >> >> >> > to window2 or window 3? Do you have any further suggestions for >> my >> >> >> > case? >> >> >> > >> >> >> >> >> >> Use only one window :) >> >> >> >> >> >> > Thank you very much. >> >> >> > >> >> >> > Best Regards, >> >> >> > Pengfei >> >> >> > >> >> >> > On Fri, Oct 9, 2015 at 5:45 PM, Lex Trotman >> wrote: >> >> >> >> >> >> >> >> On 10 October 2015 at 05:05, Pengfei Sun >> >> >> >> wrote: >> >> >> >> > Dear All, >> >> >> >> > >> >> >> >> > I am always using geany, but now this is the first time I >> prepare >> >> >> >> > to >> >> >> >> > look at >> >> >> >> > geany source code. I have one question about memory allocation. >> >> >> >> > When >> >> >> >> > we >> >> >> >> > open >> >> >> >> > one new file, there will be one new window in geany. How could >> I >> >> >> >> > track >> >> >> >> > all >> >> >> >> > memory allocation(g_malloc) related with this window? Or would >> it >> >> >> >> > be >> >>
Re: [Geany-Devel] About Malloc memory for each tab?
Thanks Lex. On Thu, Oct 15, 2015 at 5:33 PM, Lex Trotman wrote: > On 16 October 2015 at 06:42, Pengfei Sun wrote: > > Hi Lex, > > > > I checked again the gap buffer and heap memory dump. I made mistakes last > > time. scintilla_send_message returned the virtual address which was the > > address of text in the heap. However, I also found parts of text (each > line) > > which locate in different address in the heap. So I made the mistake. > > > > I still have one question about memory allocation of geany. When you type > > some text in the one window of geany, which function is responsible for > > allocating the memory space in the heap? g_new, g_new0, g_malloc, > > g_slice_alloc?? I remembered you mentioned that "The buffer itself is > > allocated by Scintilla which means its allocated by C++ new". But I don't > > find the exact location in the source code of geany. > > Splitvector.h:94 > > > > > Thank you very much! > > > > Best Regards, > > Pengfei > > > > On Wed, Oct 14, 2015 at 5:13 AM, Lex Trotman wrote: > >> > >> On 13 October 2015 at 04:43, Pengfei Sun wrote: > >> > Hi Lex, > >> > > >> > Thanks for you hint about scintilla. Matthew also mentioned to use the > >> > scintilla. I tried his patch, but there is still one problem about the > >> > address of buffer. I don't know why the address of output is not > >> > consistent > >> > with address of buffer in the dumped heap memory? > >> > >> The Scintilla buffer is a gap buffer, its contents are moved depending > >> on user actions, and depending on what else Geany is doing it can copy > >> all or parts of the buffer to C memory. So your string can appear in > >> lots of places in memory, C heap, C++ heap (which may or may not be > >> the same as the C heap) not just in the buffer. > >> > >> Cheers > >> Lex > >> > >> > > >> > Best Regards, > >> > Pengfei > >> > > >> > On Fri, Oct 9, 2015 at 7:12 PM, Lex Trotman wrote: > >> >> > >> >> On 10 October 2015 at 08:42, Pengfei Sun > wrote: > >> >> > Hi Lex, > >> >> > > >> >> > Thanks for your suggestions. > >> >> > > >> >> > I work on memory forensics. My part of project is to locate memory > of > >> >> > the > >> >> > sensitive data. For example, when I use the geany open one > sensitive > >> >> > file, > >> >> > and the content will be in the memory (heap). I hope I can locate > all > >> >> > memory > >> >> > related this sensitive file. And later I can do some analysis or > >> >> > protection. > >> >> > > >> >> > >> >> The buffer itself is allocated by Scintilla which means its allocated > >> >> by C++ new. > >> >> > >> >> > Now, I override malloc and can log all malloc functions to get > return > >> >> > address and size (I think g_malloc is a wrapper of malloc). But I > >> >> > still > >> >> > cannot building the mapping between the special file and related > heap > >> >> > memory. I know each open or created file have different ID > >> >> > (GeanyDocument->id). However, I still cannot figure out how to > trace > >> >> > the > >> >> > related memory of different ID. Assume I have open three files, so > >> >> > there > >> >> > are > >> >> > three windows and three different GeanyDocument->id. I write or > >> >> > change > >> >> > some > >> >> > things among these three windows. Meanwhile, I log all > >> >> > malloc/realloc/calloc > >> >> > functions. I try to figure out which malloc belong to window 1, > which > >> >> > belong > >> >> > to window2 or window 3? Do you have any further suggestions for my > >> >> > case? > >> >> > > >> >> > >> >> Use only one window :) > >> >> > >> >> > Thank you very much. > >> >> > > >> >> > Best Regards, > >> >> > Pengfei > >> >> > > >> >> > On Fri, Oct 9, 2015 at 5:45 PM, Lex Trotman > wrote: > >> >> >> > >> >> >> On 10 October 2015 at 05:05, Pengfei Sun > >> >> >> wrote: > >> >> >> > Dear All, > >> >> >> > > >> >> >> > I am always using geany, but now this is the first time I > prepare > >> >> >> > to > >> >> >> > look at > >> >> >> > geany source code. I have one question about memory allocation. > >> >> >> > When > >> >> >> > we > >> >> >> > open > >> >> >> > one new file, there will be one new window in geany. How could I > >> >> >> > track > >> >> >> > all > >> >> >> > memory allocation(g_malloc) related with this window? Or would > it > >> >> >> > be > >> >> >> > possible to track all related functions with this window? > >> >> >> > >> >> >> The only way to track all allocations is to track Glib/GTK > >> >> >> operations > >> >> >> (some of these functions use Gslice, which does its own > allocations > >> >> >> from large blocks and may not show on malloc, or will show > >> >> >> allocating > >> >> >> the large block not all of which is for the one window). > >> >> >> > >> >> >> Also track g_malloc that Geany uses, though you can force that to > >> >> >> always malloc I think. > >> >> >> > >> >> >> Also track malloc in case some libraries use it. > >> >> >> > >> >> >> And to track C++ new as used by the editing component (which again > >> >> >> need not
Re: [Geany-Devel] About Malloc memory for each tab?
On 16 October 2015 at 06:42, Pengfei Sun wrote: > Hi Lex, > > I checked again the gap buffer and heap memory dump. I made mistakes last > time. scintilla_send_message returned the virtual address which was the > address of text in the heap. However, I also found parts of text (each line) > which locate in different address in the heap. So I made the mistake. > > I still have one question about memory allocation of geany. When you type > some text in the one window of geany, which function is responsible for > allocating the memory space in the heap? g_new, g_new0, g_malloc, > g_slice_alloc?? I remembered you mentioned that "The buffer itself is > allocated by Scintilla which means its allocated by C++ new". But I don't > find the exact location in the source code of geany. Splitvector.h:94 > > Thank you very much! > > Best Regards, > Pengfei > > On Wed, Oct 14, 2015 at 5:13 AM, Lex Trotman wrote: >> >> On 13 October 2015 at 04:43, Pengfei Sun wrote: >> > Hi Lex, >> > >> > Thanks for you hint about scintilla. Matthew also mentioned to use the >> > scintilla. I tried his patch, but there is still one problem about the >> > address of buffer. I don't know why the address of output is not >> > consistent >> > with address of buffer in the dumped heap memory? >> >> The Scintilla buffer is a gap buffer, its contents are moved depending >> on user actions, and depending on what else Geany is doing it can copy >> all or parts of the buffer to C memory. So your string can appear in >> lots of places in memory, C heap, C++ heap (which may or may not be >> the same as the C heap) not just in the buffer. >> >> Cheers >> Lex >> >> > >> > Best Regards, >> > Pengfei >> > >> > On Fri, Oct 9, 2015 at 7:12 PM, Lex Trotman wrote: >> >> >> >> On 10 October 2015 at 08:42, Pengfei Sun wrote: >> >> > Hi Lex, >> >> > >> >> > Thanks for your suggestions. >> >> > >> >> > I work on memory forensics. My part of project is to locate memory of >> >> > the >> >> > sensitive data. For example, when I use the geany open one sensitive >> >> > file, >> >> > and the content will be in the memory (heap). I hope I can locate all >> >> > memory >> >> > related this sensitive file. And later I can do some analysis or >> >> > protection. >> >> > >> >> >> >> The buffer itself is allocated by Scintilla which means its allocated >> >> by C++ new. >> >> >> >> > Now, I override malloc and can log all malloc functions to get return >> >> > address and size (I think g_malloc is a wrapper of malloc). But I >> >> > still >> >> > cannot building the mapping between the special file and related heap >> >> > memory. I know each open or created file have different ID >> >> > (GeanyDocument->id). However, I still cannot figure out how to trace >> >> > the >> >> > related memory of different ID. Assume I have open three files, so >> >> > there >> >> > are >> >> > three windows and three different GeanyDocument->id. I write or >> >> > change >> >> > some >> >> > things among these three windows. Meanwhile, I log all >> >> > malloc/realloc/calloc >> >> > functions. I try to figure out which malloc belong to window 1, which >> >> > belong >> >> > to window2 or window 3? Do you have any further suggestions for my >> >> > case? >> >> > >> >> >> >> Use only one window :) >> >> >> >> > Thank you very much. >> >> > >> >> > Best Regards, >> >> > Pengfei >> >> > >> >> > On Fri, Oct 9, 2015 at 5:45 PM, Lex Trotman wrote: >> >> >> >> >> >> On 10 October 2015 at 05:05, Pengfei Sun >> >> >> wrote: >> >> >> > Dear All, >> >> >> > >> >> >> > I am always using geany, but now this is the first time I prepare >> >> >> > to >> >> >> > look at >> >> >> > geany source code. I have one question about memory allocation. >> >> >> > When >> >> >> > we >> >> >> > open >> >> >> > one new file, there will be one new window in geany. How could I >> >> >> > track >> >> >> > all >> >> >> > memory allocation(g_malloc) related with this window? Or would it >> >> >> > be >> >> >> > possible to track all related functions with this window? >> >> >> >> >> >> The only way to track all allocations is to track Glib/GTK >> >> >> operations >> >> >> (some of these functions use Gslice, which does its own allocations >> >> >> from large blocks and may not show on malloc, or will show >> >> >> allocating >> >> >> the large block not all of which is for the one window). >> >> >> >> >> >> Also track g_malloc that Geany uses, though you can force that to >> >> >> always malloc I think. >> >> >> >> >> >> Also track malloc in case some libraries use it. >> >> >> >> >> >> And to track C++ new as used by the editing component (which again >> >> >> need not use malloc). >> >> >> >> >> >> One question is why do you want to do this,what are you trying to >> >> >> achieve? There might be a better way. >> >> >> >> >> >> Geany is mostly event driven (though a few things are timer driven) >> >> >> so >> >> >> if you only perform actions on one window most code run will relate >> >> >> to >> >> >> that wind
Re: [Geany-Devel] About Malloc memory for each tab?
Hi Lex, I checked again the gap buffer and heap memory dump. I made mistakes last time. scintilla_send_message returned the virtual address which was the address of text in the heap. However, I also found parts of text (each line) which locate in different address in the heap. So I made the mistake. I still have one question about memory allocation of geany. When you type some text in the one window of geany, which function is responsible for allocating the memory space in the heap? g_new, g_new0, g_malloc, g_slice_alloc?? I remembered you mentioned that "The buffer itself is allocated by Scintilla which means its allocated by C++ new". But I don't find the exact location in the source code of geany. Thank you very much! Best Regards, Pengfei On Wed, Oct 14, 2015 at 5:13 AM, Lex Trotman wrote: > On 13 October 2015 at 04:43, Pengfei Sun wrote: > > Hi Lex, > > > > Thanks for you hint about scintilla. Matthew also mentioned to use the > > scintilla. I tried his patch, but there is still one problem about the > > address of buffer. I don't know why the address of output is not > consistent > > with address of buffer in the dumped heap memory? > > The Scintilla buffer is a gap buffer, its contents are moved depending > on user actions, and depending on what else Geany is doing it can copy > all or parts of the buffer to C memory. So your string can appear in > lots of places in memory, C heap, C++ heap (which may or may not be > the same as the C heap) not just in the buffer. > > Cheers > Lex > > > > > Best Regards, > > Pengfei > > > > On Fri, Oct 9, 2015 at 7:12 PM, Lex Trotman wrote: > >> > >> On 10 October 2015 at 08:42, Pengfei Sun wrote: > >> > Hi Lex, > >> > > >> > Thanks for your suggestions. > >> > > >> > I work on memory forensics. My part of project is to locate memory of > >> > the > >> > sensitive data. For example, when I use the geany open one sensitive > >> > file, > >> > and the content will be in the memory (heap). I hope I can locate all > >> > memory > >> > related this sensitive file. And later I can do some analysis or > >> > protection. > >> > > >> > >> The buffer itself is allocated by Scintilla which means its allocated > >> by C++ new. > >> > >> > Now, I override malloc and can log all malloc functions to get return > >> > address and size (I think g_malloc is a wrapper of malloc). But I > still > >> > cannot building the mapping between the special file and related heap > >> > memory. I know each open or created file have different ID > >> > (GeanyDocument->id). However, I still cannot figure out how to trace > the > >> > related memory of different ID. Assume I have open three files, so > there > >> > are > >> > three windows and three different GeanyDocument->id. I write or change > >> > some > >> > things among these three windows. Meanwhile, I log all > >> > malloc/realloc/calloc > >> > functions. I try to figure out which malloc belong to window 1, which > >> > belong > >> > to window2 or window 3? Do you have any further suggestions for my > >> > case? > >> > > >> > >> Use only one window :) > >> > >> > Thank you very much. > >> > > >> > Best Regards, > >> > Pengfei > >> > > >> > On Fri, Oct 9, 2015 at 5:45 PM, Lex Trotman wrote: > >> >> > >> >> On 10 October 2015 at 05:05, Pengfei Sun > wrote: > >> >> > Dear All, > >> >> > > >> >> > I am always using geany, but now this is the first time I prepare > to > >> >> > look at > >> >> > geany source code. I have one question about memory allocation. > When > >> >> > we > >> >> > open > >> >> > one new file, there will be one new window in geany. How could I > >> >> > track > >> >> > all > >> >> > memory allocation(g_malloc) related with this window? Or would it > be > >> >> > possible to track all related functions with this window? > >> >> > >> >> The only way to track all allocations is to track Glib/GTK operations > >> >> (some of these functions use Gslice, which does its own allocations > >> >> from large blocks and may not show on malloc, or will show allocating > >> >> the large block not all of which is for the one window). > >> >> > >> >> Also track g_malloc that Geany uses, though you can force that to > >> >> always malloc I think. > >> >> > >> >> Also track malloc in case some libraries use it. > >> >> > >> >> And to track C++ new as used by the editing component (which again > >> >> need not use malloc). > >> >> > >> >> One question is why do you want to do this,what are you trying to > >> >> achieve? There might be a better way. > >> >> > >> >> Geany is mostly event driven (though a few things are timer driven) > so > >> >> if you only perform actions on one window most code run will relate > to > >> >> that window. > >> >> > >> >> Cheers > >> >> Lex > >> >> > >> >> > > >> >> > Thank you very much! > >> >> > > >> >> > Best Regards, > >> >> > Pengfei > >> >> > > >> >> > > >> >> > ___ > >> >> > Devel mailing list > >> >> > Devel@lists.geany.org > >> >> > https://lis
Re: [Geany-Devel] About Malloc memory for each tab?
On 13 October 2015 at 04:43, Pengfei Sun wrote: > Hi Lex, > > Thanks for you hint about scintilla. Matthew also mentioned to use the > scintilla. I tried his patch, but there is still one problem about the > address of buffer. I don't know why the address of output is not consistent > with address of buffer in the dumped heap memory? The Scintilla buffer is a gap buffer, its contents are moved depending on user actions, and depending on what else Geany is doing it can copy all or parts of the buffer to C memory. So your string can appear in lots of places in memory, C heap, C++ heap (which may or may not be the same as the C heap) not just in the buffer. Cheers Lex > > Best Regards, > Pengfei > > On Fri, Oct 9, 2015 at 7:12 PM, Lex Trotman wrote: >> >> On 10 October 2015 at 08:42, Pengfei Sun wrote: >> > Hi Lex, >> > >> > Thanks for your suggestions. >> > >> > I work on memory forensics. My part of project is to locate memory of >> > the >> > sensitive data. For example, when I use the geany open one sensitive >> > file, >> > and the content will be in the memory (heap). I hope I can locate all >> > memory >> > related this sensitive file. And later I can do some analysis or >> > protection. >> > >> >> The buffer itself is allocated by Scintilla which means its allocated >> by C++ new. >> >> > Now, I override malloc and can log all malloc functions to get return >> > address and size (I think g_malloc is a wrapper of malloc). But I still >> > cannot building the mapping between the special file and related heap >> > memory. I know each open or created file have different ID >> > (GeanyDocument->id). However, I still cannot figure out how to trace the >> > related memory of different ID. Assume I have open three files, so there >> > are >> > three windows and three different GeanyDocument->id. I write or change >> > some >> > things among these three windows. Meanwhile, I log all >> > malloc/realloc/calloc >> > functions. I try to figure out which malloc belong to window 1, which >> > belong >> > to window2 or window 3? Do you have any further suggestions for my >> > case? >> > >> >> Use only one window :) >> >> > Thank you very much. >> > >> > Best Regards, >> > Pengfei >> > >> > On Fri, Oct 9, 2015 at 5:45 PM, Lex Trotman wrote: >> >> >> >> On 10 October 2015 at 05:05, Pengfei Sun wrote: >> >> > Dear All, >> >> > >> >> > I am always using geany, but now this is the first time I prepare to >> >> > look at >> >> > geany source code. I have one question about memory allocation. When >> >> > we >> >> > open >> >> > one new file, there will be one new window in geany. How could I >> >> > track >> >> > all >> >> > memory allocation(g_malloc) related with this window? Or would it be >> >> > possible to track all related functions with this window? >> >> >> >> The only way to track all allocations is to track Glib/GTK operations >> >> (some of these functions use Gslice, which does its own allocations >> >> from large blocks and may not show on malloc, or will show allocating >> >> the large block not all of which is for the one window). >> >> >> >> Also track g_malloc that Geany uses, though you can force that to >> >> always malloc I think. >> >> >> >> Also track malloc in case some libraries use it. >> >> >> >> And to track C++ new as used by the editing component (which again >> >> need not use malloc). >> >> >> >> One question is why do you want to do this,what are you trying to >> >> achieve? There might be a better way. >> >> >> >> Geany is mostly event driven (though a few things are timer driven) so >> >> if you only perform actions on one window most code run will relate to >> >> that window. >> >> >> >> Cheers >> >> Lex >> >> >> >> > >> >> > Thank you very much! >> >> > >> >> > Best Regards, >> >> > Pengfei >> >> > >> >> > >> >> > ___ >> >> > Devel mailing list >> >> > Devel@lists.geany.org >> >> > https://lists.geany.org/cgi-bin/mailman/listinfo/devel >> >> > >> >> ___ >> >> Devel mailing list >> >> Devel@lists.geany.org >> >> https://lists.geany.org/cgi-bin/mailman/listinfo/devel >> > >> > >> > >> > ___ >> > Devel mailing list >> > Devel@lists.geany.org >> > https://lists.geany.org/cgi-bin/mailman/listinfo/devel >> > >> ___ >> Devel mailing list >> Devel@lists.geany.org >> https://lists.geany.org/cgi-bin/mailman/listinfo/devel > > > > ___ > Devel mailing list > Devel@lists.geany.org > https://lists.geany.org/cgi-bin/mailman/listinfo/devel > ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] About Malloc memory for each tab?
Hi Lex, Thanks for you hint about scintilla. Matthew also mentioned to use the scintilla. I tried his patch, but there is still one problem about the address of buffer. I don't know why the address of output is not consistent with address of buffer in the dumped heap memory? Best Regards, Pengfei On Fri, Oct 9, 2015 at 7:12 PM, Lex Trotman wrote: > On 10 October 2015 at 08:42, Pengfei Sun wrote: > > Hi Lex, > > > > Thanks for your suggestions. > > > > I work on memory forensics. My part of project is to locate memory of the > > sensitive data. For example, when I use the geany open one sensitive > file, > > and the content will be in the memory (heap). I hope I can locate all > memory > > related this sensitive file. And later I can do some analysis or > protection. > > > > The buffer itself is allocated by Scintilla which means its allocated > by C++ new. > > > Now, I override malloc and can log all malloc functions to get return > > address and size (I think g_malloc is a wrapper of malloc). But I still > > cannot building the mapping between the special file and related heap > > memory. I know each open or created file have different ID > > (GeanyDocument->id). However, I still cannot figure out how to trace the > > related memory of different ID. Assume I have open three files, so there > are > > three windows and three different GeanyDocument->id. I write or change > some > > things among these three windows. Meanwhile, I log all > malloc/realloc/calloc > > functions. I try to figure out which malloc belong to window 1, which > belong > > to window2 or window 3? Do you have any further suggestions for my case? > > > > Use only one window :) > > > Thank you very much. > > > > Best Regards, > > Pengfei > > > > On Fri, Oct 9, 2015 at 5:45 PM, Lex Trotman wrote: > >> > >> On 10 October 2015 at 05:05, Pengfei Sun wrote: > >> > Dear All, > >> > > >> > I am always using geany, but now this is the first time I prepare to > >> > look at > >> > geany source code. I have one question about memory allocation. When > we > >> > open > >> > one new file, there will be one new window in geany. How could I track > >> > all > >> > memory allocation(g_malloc) related with this window? Or would it be > >> > possible to track all related functions with this window? > >> > >> The only way to track all allocations is to track Glib/GTK operations > >> (some of these functions use Gslice, which does its own allocations > >> from large blocks and may not show on malloc, or will show allocating > >> the large block not all of which is for the one window). > >> > >> Also track g_malloc that Geany uses, though you can force that to > >> always malloc I think. > >> > >> Also track malloc in case some libraries use it. > >> > >> And to track C++ new as used by the editing component (which again > >> need not use malloc). > >> > >> One question is why do you want to do this,what are you trying to > >> achieve? There might be a better way. > >> > >> Geany is mostly event driven (though a few things are timer driven) so > >> if you only perform actions on one window most code run will relate to > >> that window. > >> > >> Cheers > >> Lex > >> > >> > > >> > Thank you very much! > >> > > >> > Best Regards, > >> > Pengfei > >> > > >> > > >> > ___ > >> > Devel mailing list > >> > Devel@lists.geany.org > >> > https://lists.geany.org/cgi-bin/mailman/listinfo/devel > >> > > >> ___ > >> Devel mailing list > >> Devel@lists.geany.org > >> https://lists.geany.org/cgi-bin/mailman/listinfo/devel > > > > > > > > ___ > > Devel mailing list > > Devel@lists.geany.org > > https://lists.geany.org/cgi-bin/mailman/listinfo/devel > > > ___ > Devel mailing list > Devel@lists.geany.org > https://lists.geany.org/cgi-bin/mailman/listinfo/devel > ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] About Malloc memory for each tab?
Hi Matthew, Thanks for your illustration and patch. I have patched the code to geany source code. Now I can get the memory address of buffer as your mentioned. When I tried your patch, I also dumped the whole memory and checked the heap memory. For example, I wrote several characters in one line. Your patch can give me the output "** The buffer for file '/home/sun/Desktop/1' is at 0x8c98cd0:0x8c98ce9", which means the start address is 0x8c98cd0, and the end address is 0x8c98ce9. However, when I dumped the heap memory and found out the address of same characters string. They are not the same. The heap start address is 08882000. So the real virtual address is 0x8882000 + 0x002e0568 (offset) = 0x8b62568. Do you have any idea about this situation? 002e0560 00 00 00 00 11 00 00 00 77 75 6a 69 61 63 68 75 002e0570 61 6e 00 00 19 00 00 00 01 00 00 00 01 00 00 00 Thank you very much! Best Regards, Pengfei On Fri, Oct 9, 2015 at 8:06 PM, Matthew Brush wrote: > On 15-10-09 04:43 PM, Matthew Brush wrote: > >> On 15-10-09 03:42 PM, Pengfei Sun wrote: >> >>> [...] Do you have any further suggestions for my case? >>> >>> > I made a quick and dirty patch that will log on the terminal wherever in > (virtual) memory the buffer is stored, whenever it moves, per-file. See > attachment. > > Cheers, > Matthew Brush > > > ___ > Devel mailing list > Devel@lists.geany.org > https://lists.geany.org/cgi-bin/mailman/listinfo/devel > > ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] About Malloc memory for each tab?
On 15-10-09 04:43 PM, Matthew Brush wrote: On 15-10-09 03:42 PM, Pengfei Sun wrote: [...] Do you have any further suggestions for my case? I made a quick and dirty patch that will log on the terminal wherever in (virtual) memory the buffer is stored, whenever it moves, per-file. See attachment. Cheers, Matthew Brush diff --git a/src/editor.c b/src/editor.c index 1336588..840e979 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1075,6 +1075,23 @@ static gboolean on_editor_notify(G_GNUC_UNUSED GObject *object, GeanyEditor *edi if (nt->modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT)) { document_update_tag_list_in_idle(doc); + +/* Tracking Scintilla buffer in memory */ +{ + static const gchar *old_start = NULL; + static const gchar *old_end = NULL; + const gchar *start = + (const gchar *) scintilla_send_message(sci, SCI_GETCHARACTERPOINTER, 0, 0); + gsize len = scintilla_send_message(sci, SCI_GETTEXTLENGTH, 0, 0); + const gchar *end = start + len; + if (start != old_start || end != old_end) + { + g_print("** The buffer for file '%s' is at %p:%p\n", doc->real_path, start, end); + old_start = start; + old_end = end; + } +} + } break; ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] About Malloc memory for each tab?
On 15-10-09 03:42 PM, Pengfei Sun wrote: Hi Lex, Thanks for your suggestions. I work on memory forensics. My part of project is to locate memory of the sensitive data. For example, when I use the geany open one sensitive file, and the content will be in the memory (heap). I hope I can locate all memory related this sensitive file. And later I can do some analysis or protection. Now, I override malloc and can log all malloc functions to get return address and size (I think g_malloc is a wrapper of malloc). But I still cannot building the mapping between the special file and related heap memory. I know each open or created file have different ID (GeanyDocument->id). However, I still cannot figure out how to trace the related memory of different ID. Assume I have open three files, so there are three windows and three different GeanyDocument->id. I write or change some things among these three windows. Meanwhile, I log all malloc/realloc/calloc functions. I try to figure out which malloc belong to window 1, which belong to window2 or window 3? Do you have any further suggestions for my case? Hi, To get from GeanyDocument to where the text buffer is stored: - First get to the Scintilla widget: doc->editor->sci - Then get a pointer to Scintilla buffer: scintilla_send_message(doc->editor->sci, SCI_GETCHARACTERPOINTER, 0, 0); - That call will close the editing gap, so if you call: scintilla_send_message(doc->editor->sci, SCI_GETTEXTLENGTH, 0, 0); You can have the lower and upper addresses of the complete contiguous document buffer. But as Lex mentioned, the address no doubt changes as Scintilla grows and shrinks the buffer, so you can only know for sure where it lives between call to SCI_GETCHARACTERPOINTER and the next time the buffer is changed. You mentioned in Github Issue about wanting to know about tag allocations, in `tagmanager/src/tm_tag.c` at the top is where you could hook into allocation of the tag structures (TAG_NEW/TAG_FREE macros, or else the log_tag_*() functions). Happy Hacking, Matthew Brush ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] About Malloc memory for each tab?
On 10 October 2015 at 09:12, Lex Trotman wrote: > On 10 October 2015 at 08:42, Pengfei Sun wrote: >> Hi Lex, >> >> Thanks for your suggestions. >> >> I work on memory forensics. My part of project is to locate memory of the >> sensitive data. For example, when I use the geany open one sensitive file, >> and the content will be in the memory (heap). I hope I can locate all memory >> related this sensitive file. And later I can do some analysis or protection. >> > > The buffer itself is allocated by Scintilla which means its allocated > by C++ new. PS and its re-allocated as the size changes with editing actions. > >> Now, I override malloc and can log all malloc functions to get return >> address and size (I think g_malloc is a wrapper of malloc). But I still >> cannot building the mapping between the special file and related heap >> memory. I know each open or created file have different ID >> (GeanyDocument->id). However, I still cannot figure out how to trace the >> related memory of different ID. Assume I have open three files, so there are >> three windows and three different GeanyDocument->id. I write or change some >> things among these three windows. Meanwhile, I log all malloc/realloc/calloc >> functions. I try to figure out which malloc belong to window 1, which belong >> to window2 or window 3? Do you have any further suggestions for my case? >> > > Use only one window :) > >> Thank you very much. >> >> Best Regards, >> Pengfei >> >> On Fri, Oct 9, 2015 at 5:45 PM, Lex Trotman wrote: >>> >>> On 10 October 2015 at 05:05, Pengfei Sun wrote: >>> > Dear All, >>> > >>> > I am always using geany, but now this is the first time I prepare to >>> > look at >>> > geany source code. I have one question about memory allocation. When we >>> > open >>> > one new file, there will be one new window in geany. How could I track >>> > all >>> > memory allocation(g_malloc) related with this window? Or would it be >>> > possible to track all related functions with this window? >>> >>> The only way to track all allocations is to track Glib/GTK operations >>> (some of these functions use Gslice, which does its own allocations >>> from large blocks and may not show on malloc, or will show allocating >>> the large block not all of which is for the one window). >>> >>> Also track g_malloc that Geany uses, though you can force that to >>> always malloc I think. >>> >>> Also track malloc in case some libraries use it. >>> >>> And to track C++ new as used by the editing component (which again >>> need not use malloc). >>> >>> One question is why do you want to do this,what are you trying to >>> achieve? There might be a better way. >>> >>> Geany is mostly event driven (though a few things are timer driven) so >>> if you only perform actions on one window most code run will relate to >>> that window. >>> >>> Cheers >>> Lex >>> >>> > >>> > Thank you very much! >>> > >>> > Best Regards, >>> > Pengfei >>> > >>> > >>> > ___ >>> > Devel mailing list >>> > Devel@lists.geany.org >>> > https://lists.geany.org/cgi-bin/mailman/listinfo/devel >>> > >>> ___ >>> Devel mailing list >>> Devel@lists.geany.org >>> https://lists.geany.org/cgi-bin/mailman/listinfo/devel >> >> >> >> ___ >> Devel mailing list >> Devel@lists.geany.org >> https://lists.geany.org/cgi-bin/mailman/listinfo/devel >> ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] About Malloc memory for each tab?
On 10 October 2015 at 08:42, Pengfei Sun wrote: > Hi Lex, > > Thanks for your suggestions. > > I work on memory forensics. My part of project is to locate memory of the > sensitive data. For example, when I use the geany open one sensitive file, > and the content will be in the memory (heap). I hope I can locate all memory > related this sensitive file. And later I can do some analysis or protection. > The buffer itself is allocated by Scintilla which means its allocated by C++ new. > Now, I override malloc and can log all malloc functions to get return > address and size (I think g_malloc is a wrapper of malloc). But I still > cannot building the mapping between the special file and related heap > memory. I know each open or created file have different ID > (GeanyDocument->id). However, I still cannot figure out how to trace the > related memory of different ID. Assume I have open three files, so there are > three windows and three different GeanyDocument->id. I write or change some > things among these three windows. Meanwhile, I log all malloc/realloc/calloc > functions. I try to figure out which malloc belong to window 1, which belong > to window2 or window 3? Do you have any further suggestions for my case? > Use only one window :) > Thank you very much. > > Best Regards, > Pengfei > > On Fri, Oct 9, 2015 at 5:45 PM, Lex Trotman wrote: >> >> On 10 October 2015 at 05:05, Pengfei Sun wrote: >> > Dear All, >> > >> > I am always using geany, but now this is the first time I prepare to >> > look at >> > geany source code. I have one question about memory allocation. When we >> > open >> > one new file, there will be one new window in geany. How could I track >> > all >> > memory allocation(g_malloc) related with this window? Or would it be >> > possible to track all related functions with this window? >> >> The only way to track all allocations is to track Glib/GTK operations >> (some of these functions use Gslice, which does its own allocations >> from large blocks and may not show on malloc, or will show allocating >> the large block not all of which is for the one window). >> >> Also track g_malloc that Geany uses, though you can force that to >> always malloc I think. >> >> Also track malloc in case some libraries use it. >> >> And to track C++ new as used by the editing component (which again >> need not use malloc). >> >> One question is why do you want to do this,what are you trying to >> achieve? There might be a better way. >> >> Geany is mostly event driven (though a few things are timer driven) so >> if you only perform actions on one window most code run will relate to >> that window. >> >> Cheers >> Lex >> >> > >> > Thank you very much! >> > >> > Best Regards, >> > Pengfei >> > >> > >> > ___ >> > Devel mailing list >> > Devel@lists.geany.org >> > https://lists.geany.org/cgi-bin/mailman/listinfo/devel >> > >> ___ >> Devel mailing list >> Devel@lists.geany.org >> https://lists.geany.org/cgi-bin/mailman/listinfo/devel > > > > ___ > Devel mailing list > Devel@lists.geany.org > https://lists.geany.org/cgi-bin/mailman/listinfo/devel > ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] About Malloc memory for each tab?
Hi Lex, Thanks for your suggestions. I work on memory forensics. My part of project is to locate memory of the sensitive data. For example, when I use the geany open one sensitive file, and the content will be in the memory (heap). I hope I can locate all memory related this sensitive file. And later I can do some analysis or protection. Now, I override malloc and can log all malloc functions to get return address and size (I think g_malloc is a wrapper of malloc). But I still cannot building the mapping between the special file and related heap memory. I know each open or created file have different ID (GeanyDocument->id). However, I still cannot figure out how to trace the related memory of different ID. Assume I have open three files, so there are three windows and three different GeanyDocument->id. I write or change some things among these three windows. Meanwhile, I log all malloc/realloc/calloc functions. I try to figure out which malloc belong to window 1, which belong to window2 or window 3? Do you have any further suggestions for my case? Thank you very much. Best Regards, Pengfei On Fri, Oct 9, 2015 at 5:45 PM, Lex Trotman wrote: > On 10 October 2015 at 05:05, Pengfei Sun wrote: > > Dear All, > > > > I am always using geany, but now this is the first time I prepare to > look at > > geany source code. I have one question about memory allocation. When we > open > > one new file, there will be one new window in geany. How could I track > all > > memory allocation(g_malloc) related with this window? Or would it be > > possible to track all related functions with this window? > > The only way to track all allocations is to track Glib/GTK operations > (some of these functions use Gslice, which does its own allocations > from large blocks and may not show on malloc, or will show allocating > the large block not all of which is for the one window). > > Also track g_malloc that Geany uses, though you can force that to > always malloc I think. > > Also track malloc in case some libraries use it. > > And to track C++ new as used by the editing component (which again > need not use malloc). > > One question is why do you want to do this,what are you trying to > achieve? There might be a better way. > > Geany is mostly event driven (though a few things are timer driven) so > if you only perform actions on one window most code run will relate to > that window. > > Cheers > Lex > > > > > Thank you very much! > > > > Best Regards, > > Pengfei > > > > > > ___ > > Devel mailing list > > Devel@lists.geany.org > > https://lists.geany.org/cgi-bin/mailman/listinfo/devel > > > ___ > Devel mailing list > Devel@lists.geany.org > https://lists.geany.org/cgi-bin/mailman/listinfo/devel > ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Re: [Geany-Devel] About Malloc memory for each tab?
On 10 October 2015 at 05:05, Pengfei Sun wrote: > Dear All, > > I am always using geany, but now this is the first time I prepare to look at > geany source code. I have one question about memory allocation. When we open > one new file, there will be one new window in geany. How could I track all > memory allocation(g_malloc) related with this window? Or would it be > possible to track all related functions with this window? The only way to track all allocations is to track Glib/GTK operations (some of these functions use Gslice, which does its own allocations from large blocks and may not show on malloc, or will show allocating the large block not all of which is for the one window). Also track g_malloc that Geany uses, though you can force that to always malloc I think. Also track malloc in case some libraries use it. And to track C++ new as used by the editing component (which again need not use malloc). One question is why do you want to do this,what are you trying to achieve? There might be a better way. Geany is mostly event driven (though a few things are timer driven) so if you only perform actions on one window most code run will relate to that window. Cheers Lex > > Thank you very much! > > Best Regards, > Pengfei > > > ___ > Devel mailing list > Devel@lists.geany.org > https://lists.geany.org/cgi-bin/mailman/listinfo/devel > ___ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel